mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 09:32:41 +00:00
fix: calculating SCDateSeries for next unit view
This commit is contained in:
@@ -62,12 +62,12 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* UUID subscription
|
* UUID subscription
|
||||||
*/
|
*/
|
||||||
private _uuidSubscription: Subscription;
|
private _eventUuidSubscription: Subscription;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The events to display
|
* The events to display
|
||||||
*/
|
*/
|
||||||
private uuids: SCUuid[];
|
private eventUuids: SCUuid[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Next event in calendar
|
* Next event in calendar
|
||||||
@@ -103,9 +103,9 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this._uuidSubscription = this.scheduleProvider.uuids$.subscribe(
|
this._eventUuidSubscription = this.scheduleProvider.uuids$.subscribe(
|
||||||
async result => {
|
async result => {
|
||||||
this.uuids = result;
|
this.eventUuids = result;
|
||||||
await this.loadNextEvent();
|
await this.loadNextEvent();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -131,13 +131,23 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
async loadNextEvent() {
|
async loadNextEvent() {
|
||||||
const dataSeries = await this.scheduleProvider.getDateSeries(
|
const dataSeries = await this.scheduleProvider.getDateSeries(
|
||||||
this.uuids,
|
this.eventUuids,
|
||||||
['P1W', 'P2W', 'P3W', 'P4W'],
|
undefined,
|
||||||
moment(moment.now()).startOf('week').toISOString(),
|
moment(moment.now()).startOf('week').toISOString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.nextEvent =
|
this.nextEvent = dataSeries.dates
|
||||||
(dataSeries && dataSeries.dates && dataSeries.dates[0]) || undefined;
|
.map(series => ({
|
||||||
|
time: new Date(
|
||||||
|
series.dates
|
||||||
|
.sort((a, b) => new Date(a).getTime() - new Date(b).getTime())
|
||||||
|
.find(date => new Date(date) > new Date()) ||
|
||||||
|
Number.POSITIVE_INFINITY,
|
||||||
|
).getTime(),
|
||||||
|
series,
|
||||||
|
}))
|
||||||
|
.sort(({time: a}, {time: b}) => a - b)
|
||||||
|
.find(({time}) => !!time)?.series;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,7 +157,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
|||||||
for (const sub of this.subscriptions) {
|
for (const sub of this.subscriptions) {
|
||||||
sub.unsubscribe();
|
sub.unsubscribe();
|
||||||
}
|
}
|
||||||
this._uuidSubscription.unsubscribe();
|
this._eventUuidSubscription.unsubscribe();
|
||||||
this.collapseAnimation.destroy();
|
this.collapseAnimation.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user