Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load product on page lang change and router param update #555

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions src/components/metadata-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
Expand Down Expand Up @@ -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';
Expand Down
7 changes: 1 addition & 6 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const routes = [
}
},
{
path: '/:lang/editor-metadata',
path: '/:lang/editor-metadata/:uid?',
name: 'metadataExisting',
component: MetadataEditorV,
props: { editExisting: true },
Expand All @@ -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',
Expand Down
Loading