Skip to content

Commit 76800f0

Browse files
committed
temp fixes
1 parent d35c9d6 commit 76800f0

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

app/composables/project_manager.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,14 @@ async function importProject(file) {
7474
}
7575

7676
await treeviewStore.importStores(snapshot.treeview || {});
77+
await dataStore.importStores(snapshot.data || {});
7778
await hybridViewerStore.initHybridViewer();
78-
await hybridViewerStore.importStores(snapshot.hybridViewer || {});
7979

8080
const items = snapshot?.data?.items || [];
81-
8281
await importWorkflowFromSnapshot(items);
8382
await hybridViewerStore.importStores(snapshot.hybridViewer || {});
84-
{
85-
await dataStyleStore.importStores(snapshot.dataStyle || {});
86-
}
87-
{
88-
await dataStyleStore.applyAllStylesFromState();
89-
}
83+
await dataStyleStore.importStores(snapshot.dataStyle || {});
84+
await dataStyleStore.applyAllStylesFromState();
9085

9186
treeviewStore.finalizeImportSelection();
9287
treeviewStore.isImporting = false;

app/stores/data.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,25 @@ export const useDataStore = defineStore("data", () => {
191191

192192
async function exportStores() {
193193
const items = await data_db.toArray();
194-
return { items };
194+
const modelComponents = await model_components_db.toArray();
195+
const modelComponentsRelations = await model_components_relation_db.toArray();
196+
return { items, modelComponents, modelComponentsRelations };
195197
}
196198

197-
async function importStores(_snapshot) {
199+
async function importStores(snapshot) {
198200
await clear();
201+
if (snapshot.modelComponents) {
202+
await model_components_db.bulkPut(snapshot.modelComponents);
203+
}
204+
if (snapshot.modelComponentsRelations) {
205+
await model_components_relation_db.bulkPut(snapshot.modelComponentsRelations);
206+
}
199207
}
200208

201209
async function clear() {
202210
await data_db.clear();
211+
await model_components_db.clear();
212+
await model_components_relation_db.clear();
203213
}
204214

205215
return {

tests/unit/composables/project_manager.nuxt.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ const dataStoreMock = {
104104
clear: vi.fn(),
105105
registerObject: vi.fn().mockResolvedValue(),
106106
addItem: vi.fn().mockResolvedValue(),
107+
importStores: vi.fn().mockResolvedValue(),
107108
};
108109
const dataStyleStoreMock = {
109110
importStores: vi.fn().mockResolvedValue(),
@@ -202,6 +203,7 @@ function verifyViewerCalls() {
202203

203204
function verifyStoreImports() {
204205
expect(treeviewStoreMock.importStores).toHaveBeenCalledWith(snapshotMock.treeview);
206+
expect(dataStoreMock.importStores).toHaveBeenCalledWith(snapshotMock.data);
205207
expect(hybridViewerStoreMock.initHybridViewer).toHaveBeenCalledWith();
206208
expect(hybridViewerStoreMock.importStores).toHaveBeenCalledWith(snapshotMock.hybridViewer);
207209
expect(hybridViewerStoreMock.setZScaling).toHaveBeenCalledWith(Z_SCALE);

0 commit comments

Comments
 (0)