From 071dc5be4baca548cf5f213b9b67ce7273b9861d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 5 May 2022 09:28:33 +0100 Subject: [PATCH] Update many usages of goto to redirect to improve routing history and fix many blocking navigation cycles --- packages/builder/src/helpers/urlStateSync.js | 2 +- .../src/pages/builder/app/[application]/_fallback.svelte | 4 ++-- .../src/pages/builder/app/[application]/_layout.svelte | 5 +---- .../pages/builder/app/[application]/automate/index.svelte | 4 ++-- .../src/pages/builder/app/[application]/data/_layout.svelte | 4 ++-- .../datasource/[selectedDatasource]/[query]/_layout.svelte | 4 ++-- .../datasource/[selectedDatasource]/[query]/index.svelte | 4 ++-- .../builder/app/[application]/data/datasource/index.svelte | 4 ++-- .../src/pages/builder/app/[application]/data/index.svelte | 4 ++-- .../[selectedTable]/relationship/[selectedRow]/index.svelte | 4 ++-- .../data/table/[selectedTable]/relationship/index.svelte | 4 ++-- .../builder/app/[application]/data/table/_layout.svelte | 4 ++-- .../pages/builder/app/[application]/data/table/index.svelte | 4 ++-- .../app/[application]/design/[screenId]/_layout.svelte | 5 ++++- .../[screenId]/components/[componentId]/_layout.svelte | 5 ++++- .../builder/src/pages/builder/app/[application]/index.svelte | 4 ++-- packages/builder/src/pages/builder/app/index.svelte | 4 ++-- 17 files changed, 36 insertions(+), 33 deletions(-) diff --git a/packages/builder/src/helpers/urlStateSync.js b/packages/builder/src/helpers/urlStateSync.js index f6357ae5d9..616bb9b7f1 100644 --- a/packages/builder/src/helpers/urlStateSync.js +++ b/packages/builder/src/helpers/urlStateSync.js @@ -36,7 +36,7 @@ export const syncURLToState = options => { let cachedRedirect = get(routify.redirect) let cachedPage = get(routify.page) let previousParamsHash = null - let debug = false + let debug = true const log = (...params) => debug && console.log(...params) // Navigate to a certain URL diff --git a/packages/builder/src/pages/builder/app/[application]/_fallback.svelte b/packages/builder/src/pages/builder/app/[application]/_fallback.svelte index 24c5c56780..c5b3b3803d 100644 --- a/packages/builder/src/pages/builder/app/[application]/_fallback.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_fallback.svelte @@ -1,5 +1,5 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/_layout.svelte index cf27add084..03bb545780 100644 --- a/packages/builder/src/pages/builder/app/[application]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_layout.svelte @@ -27,6 +27,7 @@ async function getPackage() { try { + store.actions.reset() const pkg = await API.fetchAppPackage(application) await store.actions.initialise(pkg) await automationStore.actions.fetch() @@ -65,10 +66,6 @@ hasSynced = true } }) - - onDestroy(() => { - store.actions.reset() - }) {#await promise} diff --git a/packages/builder/src/pages/builder/app/[application]/automate/index.svelte b/packages/builder/src/pages/builder/app/[application]/automate/index.svelte index e5dea10e0b..b861e82dd1 100644 --- a/packages/builder/src/pages/builder/app/[application]/automate/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/automate/index.svelte @@ -1,5 +1,5 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte index f5f5c9d977..87c648bd4f 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte @@ -1,5 +1,5 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/[query]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/[query]/_layout.svelte index 403e12a78c..3536a78be7 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/[query]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/[query]/_layout.svelte @@ -2,7 +2,7 @@ import { params } from "@roxi/routify" import { queries, datasources } from "stores/backend" import { IntegrationTypes } from "constants/backend" - import { goto } from "@roxi/routify" + import { redirect } from "@roxi/routify" let datasourceId if ($params.query) { @@ -16,7 +16,7 @@ ds => ds._id === $datasources.selected || ds._id === datasourceId ) if (datasource?.source === IntegrationTypes.REST) { - $goto(`../rest/${$params.query}`) + $redirect(`../rest/${$params.query}`) } diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/[query]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/[query]/index.svelte index 61e2ae5f19..a6bd10147d 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/[query]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/[query]/index.svelte @@ -1,5 +1,5 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/index.svelte index ffaaf5dad5..b59286b62a 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/index.svelte @@ -1,11 +1,11 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/data/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/index.svelte index 70c3d4481a..42ee02a308 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/index.svelte @@ -1,5 +1,5 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/data/table/[selectedTable]/relationship/[selectedRow]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/[selectedTable]/relationship/[selectedRow]/index.svelte index 8e195ddb12..1db607ccc1 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/table/[selectedTable]/relationship/[selectedRow]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/[selectedTable]/relationship/[selectedRow]/index.svelte @@ -1,6 +1,6 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/data/table/[selectedTable]/relationship/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/[selectedTable]/relationship/index.svelte index 7d081b6976..f0baf88ffe 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/table/[selectedTable]/relationship/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/[selectedTable]/relationship/index.svelte @@ -1,6 +1,6 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/data/table/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/_layout.svelte index 9ab874a4d0..5d0e12185a 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/table/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/_layout.svelte @@ -1,6 +1,6 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/data/table/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/index.svelte index 6d61614145..2bafb50a71 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/table/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/index.svelte @@ -1,10 +1,10 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte index 79e4fecf52..7de0c5d093 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte @@ -17,7 +17,10 @@ routify, }) - onDestroy(stopSyncing) + onDestroy(() => { + console.log("============= stop syncing screen ID!") + stopSyncing() + })
diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_layout.svelte index 5b51d755af..b773cbe6ee 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_layout.svelte @@ -15,7 +15,10 @@ routify, }) - onDestroy(stopSyncing) + onDestroy(() => { + console.log("============= stop syncing component ID!") + stopSyncing() + }) diff --git a/packages/builder/src/pages/builder/app/[application]/index.svelte b/packages/builder/src/pages/builder/app/[application]/index.svelte index 31486e771e..efcb3d1f44 100644 --- a/packages/builder/src/pages/builder/app/[application]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/index.svelte @@ -1,4 +1,4 @@ diff --git a/packages/builder/src/pages/builder/app/index.svelte b/packages/builder/src/pages/builder/app/index.svelte index 110b5e83d9..05a71911d2 100644 --- a/packages/builder/src/pages/builder/app/index.svelte +++ b/packages/builder/src/pages/builder/app/index.svelte @@ -1,4 +1,4 @@