sort statuses after rescheduling
This commit is contained in:
parent
05e4a87524
commit
1a243c3ee6
|
@ -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);
|
||||
|
|
|
@ -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>
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue