From 8e0b07d566e9e80e13350170aa411506ea60d026 Mon Sep 17 00:00:00 2001 From: IshavSohal Date: Thu, 20 Feb 2025 11:14:37 -0500 Subject: [PATCH] Load product on page lang change and router param update --- server/index.js | 7 ++++++- src/components/metadata-editor.vue | 3 +-- src/router/index.ts | 7 +------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/server/index.js b/server/index.js index a5169d3af..d2e446eb8 100644 --- a/server/index.js +++ b/server/index.js @@ -637,6 +637,9 @@ wss.on('connection', (ws) => { const secret = generateKey(); lockedUuids[uuid] = secret; ws.uuid = uuid; + // This msg is not being received by lockStore upon loading product via router params (in particular + // from editor-main to editor-metadata). However the below msg is received (upon unlocking). Both + // messages sent at exact same time. ws.send(JSON.stringify({ status: 'success', secret })); broadcastToClients({ @@ -660,7 +663,9 @@ wss.on('connection', (ws) => { logger('INFO', `A client successfully unlocked the storyline ${uuid}.`); delete lockedUuids[uuid]; delete ws.uuid; - ws.send(JSON.stringify({ status: 'success' })); + // Gets sent at same time as above msg upon loading product via router params. Do we need this? + // A call to unlock the product already occurs upon switching pages + // ws.send(JSON.stringify({ status: 'success' })); broadcastToClients({ type: 'unlock', diff --git a/src/components/metadata-editor.vue b/src/components/metadata-editor.vue index 2e7458975..d2a7195bd 100644 --- a/src/components/metadata-editor.vue +++ b/src/components/metadata-editor.vue @@ -20,7 +20,7 @@ v-if="!currentRoute.includes('index-ca')" :to="{ name: editExisting ? 'metadataExisting' : 'metadataNew', - params: { lang: currLang === 'en' ? 'fr' : 'en' } + params: { lang: currLang === 'en' ? 'fr' : 'en', uid: uuid } }" class="sub-link" > @@ -746,7 +746,6 @@ export default class MetadataEditorV extends Vue { created(): void { this.loadExisting = this.editExisting; - // Generate UUID for new product this.uuid = (this.$route.params.uid as string) ?? (this.loadExisting ? undefined : uuidv4()); this.configLang = (this.$route.params.lang as string) || 'en'; diff --git a/src/router/index.ts b/src/router/index.ts index ef90777e1..903d54aae 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -32,7 +32,7 @@ const routes = [ } }, { - path: '/:lang/editor-metadata', + path: '/:lang/editor-metadata/:uid?', name: 'metadataExisting', component: MetadataEditorV, props: { editExisting: true }, @@ -45,11 +45,6 @@ const routes = [ props: { editExisting: false }, meta: { title: 'editor.window.title' } }, - { - path: '/:lang/editor-metadata/:uid', - component: MetadataEditorV, - meta: { title: 'editor.window.title' } - }, { path: '/:lang/editor-main/:uid', name: 'editor',