fix(web): refresh memories hourly (#28114)

This commit is contained in:
Mees Frensel 2026-04-28 17:18:51 +02:00 committed by GitHub
parent da337578fb
commit 081c75bb21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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();