mirror of
https://github.com/immich-app/immich.git
synced 2026-04-29 12:30:39 -04:00
fix(web): refresh memories hourly (#28114)
This commit is contained in:
parent
da337578fb
commit
081c75bb21
@ -33,6 +33,8 @@ class MemoryManager {
|
||||
if (authManager.authenticated) {
|
||||
void this.initialize();
|
||||
}
|
||||
|
||||
this.scheduleHourlyRefresh();
|
||||
}
|
||||
|
||||
ready() {
|
||||
@ -132,6 +134,29 @@ class MemoryManager {
|
||||
const memories = await searchMemories({ $for: asLocalTimeISO(DateTime.now()) });
|
||||
this.memories = memories.filter((memory) => memory.assets.length > 0);
|
||||
}
|
||||
|
||||
private scheduleHourlyRefresh() {
|
||||
const now = DateTime.utc();
|
||||
let nextEvent = now.set({ minute: 0, second: 5 });
|
||||
|
||||
if (nextEvent <= now) {
|
||||
nextEvent = nextEvent.plus({ hours: 1 });
|
||||
}
|
||||
|
||||
const initialDelay = nextEvent.diff(now).as('milliseconds');
|
||||
|
||||
setTimeout(() => {
|
||||
this.#loading = this.load();
|
||||
|
||||
// Schedule subsequent events hourly
|
||||
setInterval(
|
||||
() => {
|
||||
this.#loading = this.load();
|
||||
},
|
||||
60 * 60 * 1000,
|
||||
);
|
||||
}, initialDelay);
|
||||
}
|
||||
}
|
||||
|
||||
export const memoryManager = new MemoryManager();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user