sort statuses after rescheduling

This commit is contained in:
Nicolas Constant 2019-09-07 16:21:25 -04:00
parent 05e4a87524
commit 1a243c3ee6
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
3 changed files with 19 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { Component, OnInit, Input, ViewChild, Output, EventEmitter } from '@angular/core';
import { AccountInfo } from '../../../../states/accounts.state';
import { ScheduledStatus } from '../../../../services/models/mastodon.interfaces';
@ -23,6 +23,7 @@ export class ScheduledStatusComponent implements OnInit {
avatar: string;
@Input() account: AccountInfo;
@Input() status: ScheduledStatus;
@Output() rescheduledEvent = new EventEmitter();
constructor(
private readonly scheduledStatusService: ScheduledStatusService,
@ -83,6 +84,7 @@ export class ScheduledStatusComponent implements OnInit {
.then(() => {
this.status.scheduled_at = scheduledTime;
this.rescheduling = false;
this.rescheduledEvent.next();
})
.catch(err => {
this.notificationService.notifyHttpError(err);

View File

@ -3,7 +3,10 @@
<div class="scheduled-statuses-display flexcroll">
<div *ngFor="let n of scheduledStatuses" class="scheduled-status">
<app-scheduled-status [account]="n.account" [status]="n.status"></app-scheduled-status>
<app-scheduled-status
(rescheduledEvent)="statusRescheduled()"
[account]="n.account"
[status]="n.status"></app-scheduled-status>
</div>
</div>
</div>

View File

@ -30,13 +30,21 @@ export class ScheduledStatusesComponent implements OnInit, OnDestroy {
});
});
this.scheduledStatuses.sort((x, y) => new Date(x.status.scheduled_at).getTime() -new Date(y.status.scheduled_at).getTime());
this.sortStatuses();
});
}
ngOnDestroy(): void {
if (this.statusSub) this.statusSub.unsubscribe();
}
private sortStatuses() {
this.scheduledStatuses.sort((x, y) => new Date(x.status.scheduled_at).getTime() - new Date(y.status.scheduled_at).getTime());
}
statusRescheduled() {
this.sortStatuses();
}
}
class ScheduledStatusWrapper {