store sync bugfix
This commit is contained in:
@@ -91,7 +91,7 @@ export const DEFAULT_STORES: StoreConfig[] = [
|
||||
{
|
||||
name: 'shapes',
|
||||
persistent: true,
|
||||
initialState: () => ({}),
|
||||
initialState: () => ({ shapes: {} }),
|
||||
},
|
||||
{
|
||||
name: 'indicators',
|
||||
@@ -285,7 +285,7 @@ export interface Shape {
|
||||
/**
|
||||
* Shapes store - persistent, stores TradingView drawings and annotations.
|
||||
*/
|
||||
export type ShapesStore = Record<string, Shape>;
|
||||
export type ShapesStore = { shapes: Record<string, Shape> };
|
||||
|
||||
/**
|
||||
* Parameter schema entry for a custom indicator.
|
||||
|
||||
@@ -90,7 +90,14 @@ export class WorkspaceManager {
|
||||
|
||||
const states = await this.containerSync.loadAllStores(persistentStores);
|
||||
for (const [storeName, state] of states) {
|
||||
this.registry.setState(storeName, state);
|
||||
let migratedState = state;
|
||||
// Migrate shapes from old flat format { shapeId: {...} } to wrapped { shapes: { shapeId: {...} } }
|
||||
if (storeName === 'shapes' && state && typeof state === 'object' && !('shapes' in (state as object))) {
|
||||
migratedState = { shapes: state };
|
||||
this.dirtyStores.add(storeName); // persist migrated format immediately
|
||||
this.logger.info({ store: storeName }, 'Migrated shapes store to wrapped format');
|
||||
}
|
||||
this.registry.setState(storeName, migratedState);
|
||||
this.logger.debug({ store: storeName }, 'Loaded persistent store');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user