From f5e8ed6e37cf7afeb3378a4038d8c01bf7d35fc4 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 21 Jan 2025 09:50:02 +0100 Subject: [PATCH] Fix tests --- packages/builder/src/stores/builder/history.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/stores/builder/history.ts b/packages/builder/src/stores/builder/history.ts index 916e417872..6568c5abca 100644 --- a/packages/builder/src/stores/builder/history.ts +++ b/packages/builder/src/stores/builder/history.ts @@ -9,7 +9,7 @@ export const enum Operations { } interface Operator { - id?: string + id?: number type: Operations doc: T forwardPatch?: jsonpatch.Operation[] @@ -22,7 +22,7 @@ interface HistoryState { loading?: boolean } -export const initialState: HistoryState = { +export const initialState = { history: [], position: 0, loading: false, @@ -37,10 +37,10 @@ export interface HistoryStore > { wrapSaveDoc: ( fn: (doc: T) => Promise - ) => (doc: T, operationId?: string) => Promise + ) => (doc: T, operationId?: number) => Promise wrapDeleteDoc: ( fn: (doc: T) => Promise - ) => (doc: T, operationId?: string) => Promise + ) => (doc: T, operationId?: number) => Promise reset: () => void undo: () => Promise @@ -70,8 +70,8 @@ export const createHistoryStore = ({ // Wrapped versions of essential functions which we call ourselves when using // undo and redo - let saveFn: (doc: T, operationId?: string) => Promise - let deleteFn: (doc: T, operationId?: string) => Promise + let saveFn: (doc: T, operationId?: number) => Promise + let deleteFn: (doc: T, operationId?: number) => Promise /** * Internal util to set the loading flag @@ -112,7 +112,7 @@ export const createHistoryStore = ({ let position = state.position if (!operation.id) { // Every time a new operation occurs we discard any redo potential - operation.id = Math.random().toString() + operation.id = Math.random() history = [...history.slice(0, state.position), operation] position += 1 } else { @@ -133,7 +133,7 @@ export const createHistoryStore = ({ * @returns {function} a wrapped version of the save function */ const wrapSaveDoc = (fn: (doc: T) => Promise) => { - saveFn = async (doc: T, operationId?: string) => { + saveFn = async (doc: T, operationId?: number) => { // Only works on a single doc at a time if (!doc || Array.isArray(doc)) { return @@ -181,7 +181,7 @@ export const createHistoryStore = ({ * @returns {function} a wrapped version of the delete function */ const wrapDeleteDoc = (fn: (doc: T) => Promise) => { - deleteFn = async (doc: T, operationId?: string) => { + deleteFn = async (doc: T, operationId?: number) => { // Only works on a single doc at a time if (!doc || Array.isArray(doc)) { return