/**
 * Persistence Slice - 持久化状态管理
 */
import { CanvasState } from './types';

export const createPersistenceActions = (set: any) => ({
    setDirty: (isDirty: boolean) => set((state: CanvasState) => {
        state.isDirty = isDirty;
    }),

    setSaving: (isSaving: boolean) => set((state: CanvasState) => {
        state.isSaving = isSaving;
    }),

    setLastSavedAt: (timestamp: number) => set((state: CanvasState) => {
        state.lastSavedAt = timestamp;
        state.isDirty = false;
    }),

    setCanvasState: (newState: Partial<CanvasState>) => set((state: CanvasState) => {
        Object.assign(state, newState);
    }),
});
