fix paused (#486)

* fix: prevent timer continue on paused count up

* refactor: throw if not found on delete
This commit is contained in:
Carlos Valente
2023-08-12 11:24:35 +02:00
committed by GitHub
parent 023aac4ead
commit f3610059ef
5 changed files with 28 additions and 46 deletions
@@ -16,7 +16,14 @@ import { EventLoader, eventLoader } from '../../classes/event-loader/EventLoader
import { eventTimer } from '../TimerService.js';
import { sendRefetch } from '../../adapters/websocketAux.js';
import { runtimeCacheStore } from '../../stores/cachingStore.js';
import { cachedAdd, cachedDelete, cachedEdit, cachedReorder, delayedRundownCacheKey } from './delayedRundown.utils.js';
import {
cachedAdd,
cachedClear,
cachedDelete,
cachedEdit,
cachedReorder,
delayedRundownCacheKey,
} from './delayedRundown.utils.js';
import { logger } from '../../classes/Logger.js';
import { clock } from '../Clock.js';
@@ -221,9 +228,6 @@ export async function deleteEvent(eventId) {
// notify event loader that rundown size has changed
updateChangeNumEvents();
// invalidate cache
runtimeCacheStore.invalidate(delayedRundownCacheKey);
// advice socket subscribers of change
sendRefetch();
}
@@ -233,7 +237,9 @@ export async function deleteEvent(eventId) {
* @returns {Promise<void>}
*/
export async function deleteAllEvents() {
await DataProvider.clearRundown();
await cachedClear();
// notify timer service of changed events
updateTimer();
forceReset();
}
@@ -118,7 +118,7 @@ export async function cachedDelete(eventId: string) {
if (delayedRundown.findIndex((event) => event.id === eventId) >= 0) {
invalidateFromError();
}
return;
throw new Error(`Event with id ${eventId} not found`);
}
let updatedRundown = DataProvider.getRundown();
@@ -171,6 +171,12 @@ export async function cachedReorder(eventId: string, from: number, to: number) {
return reorderedEvent;
}
export async function cachedClear() {
await DataProvider.clearRundown();
runtimeCacheStore.setCached(delayedRundownCacheKey, []);
console.log(DataProvider.getRundown(), getDelayedRundown());
}
/**
* Calculates all delays in a given rundown
* @param rundown