From bf8160e31eb96b2e1f5324fb443525eb7a1506f2 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 5 Jun 2021 15:55:59 +0530 Subject: [PATCH] Fix gist loading and code not updating issue --- cypress/integration/actions.spec.ts | 6 ++++++ src/lib/components/actions.svelte | 4 ++-- src/lib/util/fileLoaders/loader.ts | 13 ++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cypress/integration/actions.spec.ts b/cypress/integration/actions.spec.ts index 6a2a8268..bcef5906 100644 --- a/cypress/integration/actions.spec.ts +++ b/cypress/integration/actions.spec.ts @@ -17,4 +17,10 @@ describe('Check actions', () => { }); }); }); + + it('should load gists from URL', () => { + cy.get('#gist').type('https://gist.github.com/sidharthv96/6268a23e673a533dcb198f241fd7012a'); + cy.contains('Load Gist').click(); + cy.contains('Go shopping!!'); + }); }); diff --git a/src/lib/components/actions.svelte b/src/lib/components/actions.svelte index ef3c03b4..438fd566 100644 --- a/src/lib/components/actions.svelte +++ b/src/lib/components/actions.svelte @@ -121,8 +121,8 @@ if (!gistURL) { alert('Please enter a Gist URL first'); } - goto(`/edit?gist=${gistURL}`); - location.reload(); + window.location.href = `/edit?gist=${gistURL}`; + // location.reload(); }; let iUrl: string; diff --git a/src/lib/util/fileLoaders/loader.ts b/src/lib/util/fileLoaders/loader.ts index 9207b576..02b73aa2 100644 --- a/src/lib/util/fileLoaders/loader.ts +++ b/src/lib/util/fileLoaders/loader.ts @@ -38,9 +38,6 @@ export const loadDataFromUrl = async (): Promise => { state = { code, mermaid: config, - autoSync: true, - updateDiagram: true, - updateEditor: true, loader: { type: 'files', config: { @@ -48,8 +45,14 @@ export const loadDataFromUrl = async (): Promise => { configURL } } - }; + } as State; } - loaded && updateCodeStore(state); + loaded && + updateCodeStore({ + ...state, + autoSync: true, + updateDiagram: true, + updateEditor: true + }); // window.location.search = ''; };