import type { TimelineToken } from "atom.io" import type { Store } from "../store/index.ts" export function clearTimelineInStore( store: Store, token: TimelineToken, ): void { store.logger.info(`๐Ÿงน`, `timeline`, token.key, `clear`) const timelineData = store.timelines.get(token.key) if (!timelineData) { store.logger.error( `๐Ÿž`, `timeline`, token.key, `Failed to clear. This timeline has not been initialized.`, ) return } timelineData.at = 0 timelineData.history = [] timelineData.pendingRecord = null timelineData.pendingUndoStepLimit = null timelineData.selectorTime = null timelineData.timeTraveling = null timelineData.transactionKey = null timelineData.subject.next({ type: `timeline_update`, event: `clear`, at: 0, length: 0, }) store.logger.info( `๐Ÿงผ`, `timeline`, token.key, `"${token.key}" is now at 0 / 0`, ) }