mirror of
https://github.com/ae-utbm/sith.git
synced 2025-04-29 12:56:47 +00:00
Merge pull request #1093 from ae-utbm/calendar
Remove cache workaround on news calendar moderation
This commit is contained in:
commit
73e9c3132b
@ -87,15 +87,8 @@ export class IcsCalendar extends inheritHtmlElement("div") {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async refreshEvents() {
|
refreshEvents() {
|
||||||
this.click(); // Remove focus from popup
|
this.click(); // Remove focus from popup
|
||||||
// We can't just refresh events because some ics files are in
|
|
||||||
// local browser cache (especially internal.ics)
|
|
||||||
// To invalidate the cache, we need to remove the source and add it again
|
|
||||||
this.calendar.removeAllEventSources();
|
|
||||||
for (const source of await this.getEventSources()) {
|
|
||||||
this.calendar.addEventSource(source);
|
|
||||||
}
|
|
||||||
this.calendar.refetchEvents();
|
this.calendar.refetchEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +107,7 @@ export class IcsCalendar extends inheritHtmlElement("div") {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await this.refreshEvents();
|
this.refreshEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
async unpublishNews(id: number) {
|
async unpublishNews(id: number) {
|
||||||
@ -132,7 +125,7 @@ export class IcsCalendar extends inheritHtmlElement("div") {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await this.refreshEvents();
|
this.refreshEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteNews(id: number) {
|
async deleteNews(id: number) {
|
||||||
@ -150,22 +143,23 @@ export class IcsCalendar extends inheritHtmlElement("div") {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await this.refreshEvents();
|
this.refreshEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getEventSources() {
|
async getEventSources() {
|
||||||
const cacheInvalidate = `?invalidate=${Date.now()}`;
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
url: `${await makeUrl(calendarCalendarInternal)}${cacheInvalidate}`,
|
url: `${await makeUrl(calendarCalendarInternal)}`,
|
||||||
format: "ics",
|
format: "ics",
|
||||||
className: "internal",
|
className: "internal",
|
||||||
|
cache: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
url: `${await makeUrl(calendarCalendarUnpublished)}${cacheInvalidate}`,
|
url: `${await makeUrl(calendarCalendarUnpublished)}`,
|
||||||
format: "ics",
|
format: "ics",
|
||||||
color: "red",
|
color: "red",
|
||||||
className: "unpublished",
|
className: "unpublished",
|
||||||
|
cache: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -348,6 +342,7 @@ export class IcsCalendar extends inheritHtmlElement("div") {
|
|||||||
headerToolbar: this.currentHeaderToolbar(),
|
headerToolbar: this.currentHeaderToolbar(),
|
||||||
footerToolbar: this.currentFooterToolbar(),
|
footerToolbar: this.currentFooterToolbar(),
|
||||||
eventSources: await this.getEventSources(),
|
eventSources: await this.getEventSources(),
|
||||||
|
lazyFetching: false,
|
||||||
windowResize: () => {
|
windowResize: () => {
|
||||||
this.calendar.changeView(this.currentView());
|
this.calendar.changeView(this.currentView());
|
||||||
this.calendar.setOption("headerToolbar", this.currentHeaderToolbar());
|
this.calendar.setOption("headerToolbar", this.currentHeaderToolbar());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user