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>
|
|
@ -16,7 +16,7 @@ export class ScheduledStatusesComponent implements OnInit, OnDestroy {
|
|||
scheduledStatuses: ScheduledStatusWrapper[] = [];
|
||||
|
||||
constructor(
|
||||
private readonly scheduledStatusService: ScheduledStatusService) {
|
||||
private readonly scheduledStatusService: ScheduledStatusService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -27,20 +27,28 @@ export class ScheduledStatusesComponent implements OnInit, OnDestroy {
|
|||
notification.statuses.forEach(status => {
|
||||
let wrapper = new ScheduledStatusWrapper(notification.account, status);
|
||||
this.scheduledStatuses.push(wrapper);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
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 {
|
||||
constructor(
|
||||
constructor(
|
||||
public readonly account: AccountInfo,
|
||||
public status: ScheduledStatus) {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue