mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 13:44:12 +00:00
refactor: refetch on change
This commit is contained in:
committed by
Carlos Valente
parent
7b932ef0f7
commit
0abaf7724d
@@ -247,7 +247,11 @@ function notifyChanges(options: { timer?: boolean | string[]; external?: boolean
|
||||
|
||||
if (options.external) {
|
||||
// advice socket subscribers of change
|
||||
sendRefetch(Array.isArray(options.timer) ? options.timer : undefined);
|
||||
const payload = {
|
||||
changes: Array.isArray(options.timer) ? options.timer : undefined,
|
||||
revision: cache.getMetadata().revision,
|
||||
};
|
||||
sendRefetch(payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@ export function getMetadata() {
|
||||
lastEnd,
|
||||
totalDelay,
|
||||
totalDuration,
|
||||
revision,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -243,6 +244,12 @@ export function mutateCache<T extends object>(mutation: MutatingFn<T>) {
|
||||
|
||||
const { newEvent, newRundown, didMutate } = mutation({ ...params, persistedRundown });
|
||||
|
||||
// early return without calling side effects
|
||||
if (!didMutate) {
|
||||
isStale = false;
|
||||
return { newEvent, newRundown, didMutate };
|
||||
}
|
||||
|
||||
revision = revision + 1;
|
||||
persistedRundown = newRundown;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user