diff --git a/plugins/client-resources/src/index.ts b/plugins/client-resources/src/index.ts index 4304f5e2dd..490fa2ca9b 100644 --- a/plugins/client-resources/src/index.ts +++ b/plugins/client-resources/src/index.ts @@ -75,7 +75,7 @@ export default async () => { return connect(url.href, upgradeHandler, onUpgrade, onUnauthorized, onConnect) }, filterModel ? [...getPlugins(), ...(getMetadata(clientPlugin.metadata.ExtraPlugins) ?? [])] : undefined, - createModelPersistence(token) + createModelPersistence(getWSFromToken(token)) ) // Check if we had dev hook for client. client = hookClient(client) @@ -84,7 +84,7 @@ export default async () => { } } } -function createModelPersistence (token: string): TxPersistenceStore | undefined { +function createModelPersistence (workspace: string): TxPersistenceStore | undefined { let dbRequest: IDBOpenDBRequest | undefined let dbPromise: Promise = Promise.resolve(undefined) @@ -111,7 +111,7 @@ function createModelPersistence (token: string): TxPersistenceStore | undefined const transaction = db.transaction('model', 'readwrite') // (1) const models = transaction.objectStore('model') // (2) const model = await new Promise<{ id: string, model: LoadModelResponse } | undefined>((resolve) => { - const storedValue: IDBRequest<{ id: string, model: LoadModelResponse }> = models.get(token) + const storedValue: IDBRequest<{ id: string, model: LoadModelResponse }> = models.get(workspace) storedValue.onsuccess = function () { resolve(storedValue.result) } @@ -140,7 +140,7 @@ function createModelPersistence (token: string): TxPersistenceStore | undefined if (db !== undefined) { const transaction = db.transaction('model', 'readwrite') // (1) const models = transaction.objectStore('model') // (2) - models.put({ id: token, model }) + models.put({ id: workspace, model }) } } } @@ -163,3 +163,15 @@ async function hookClient (client: Promise): Promise @@ -115,5 +130,8 @@ {#if revokable}