1
0
Fork 0
mirror of synced 2024-09-19 10:48:30 +12:00

Update many usages of goto to redirect to improve routing history and fix many blocking navigation cycles

This commit is contained in:
Andrew Kingston 2022-05-05 09:28:33 +01:00
parent 7b96ba811c
commit b21c4b95b8
17 changed files with 36 additions and 33 deletions

View file

@ -36,7 +36,7 @@ export const syncURLToState = options => {
let cachedRedirect = get(routify.redirect) let cachedRedirect = get(routify.redirect)
let cachedPage = get(routify.page) let cachedPage = get(routify.page)
let previousParamsHash = null let previousParamsHash = null
let debug = false let debug = true
const log = (...params) => debug && console.log(...params) const log = (...params) => debug && console.log(...params)
// Navigate to a certain URL // Navigate to a certain URL

View file

@ -1,5 +1,5 @@
<script> <script>
import { goto } from "@roxi/routify" import { redirect } from "@roxi/routify"
$goto("../design") $redirect("../design")
</script> </script>

View file

@ -27,6 +27,7 @@
async function getPackage() { async function getPackage() {
try { try {
store.actions.reset()
const pkg = await API.fetchAppPackage(application) const pkg = await API.fetchAppPackage(application)
await store.actions.initialise(pkg) await store.actions.initialise(pkg)
await automationStore.actions.fetch() await automationStore.actions.fetch()
@ -65,10 +66,6 @@
hasSynced = true hasSynced = true
} }
}) })
onDestroy(() => {
store.actions.reset()
})
</script> </script>
{#await promise} {#await promise}

View file

@ -1,5 +1,5 @@
<script> <script>
import { goto, leftover } from "@roxi/routify" import { redirect, leftover } from "@roxi/routify"
import { onMount } from "svelte" import { onMount } from "svelte"
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
@ -11,7 +11,7 @@
(!$automationStore.selectedAutomation || (!$automationStore.selectedAutomation ||
!$automationStore.selectedAutomation?.automation?._id) !$automationStore.selectedAutomation?.automation?._id)
) { ) {
$goto(`./${$automationStore.automations[0]._id}`) $redirect(`./${$automationStore.automations[0]._id}`)
} }
}) })
</script> </script>

View file

@ -1,5 +1,5 @@
<script> <script>
import { goto, params } from "@roxi/routify" import { redirect, params } from "@roxi/routify"
import { Icon, Tabs, Tab } from "@budibase/bbui" import { Icon, Tabs, Tab } from "@budibase/bbui"
import { BUDIBASE_INTERNAL_DB } from "constants" import { BUDIBASE_INTERNAL_DB } from "constants"
import DatasourceNavigator from "components/backend/DatasourceNavigator/DatasourceNavigator.svelte" import DatasourceNavigator from "components/backend/DatasourceNavigator/DatasourceNavigator.svelte"
@ -14,7 +14,7 @@
$params.selectedDatasource !== BUDIBASE_INTERNAL_DB $params.selectedDatasource !== BUDIBASE_INTERNAL_DB
function selectFirstDatasource() { function selectFirstDatasource() {
$goto("./table") $redirect("./table")
} }
</script> </script>

View file

@ -2,7 +2,7 @@
import { params } from "@roxi/routify" import { params } from "@roxi/routify"
import { queries, datasources } from "stores/backend" import { queries, datasources } from "stores/backend"
import { IntegrationTypes } from "constants/backend" import { IntegrationTypes } from "constants/backend"
import { goto } from "@roxi/routify" import { redirect } from "@roxi/routify"
let datasourceId let datasourceId
if ($params.query) { if ($params.query) {
@ -16,7 +16,7 @@
ds => ds._id === $datasources.selected || ds._id === datasourceId ds => ds._id === $datasources.selected || ds._id === datasourceId
) )
if (datasource?.source === IntegrationTypes.REST) { if (datasource?.source === IntegrationTypes.REST) {
$goto(`../rest/${$params.query}`) $redirect(`../rest/${$params.query}`)
} }
</script> </script>

View file

@ -1,5 +1,5 @@
<script> <script>
import { params, goto } from "@roxi/routify" import { params, redirect } from "@roxi/routify"
import { database, datasources, queries } from "stores/backend" import { database, datasources, queries } from "stores/backend"
import QueryInterface from "components/integration/QueryViewer.svelte" import QueryInterface from "components/integration/QueryViewer.svelte"
import { IntegrationTypes } from "constants/backend" import { IntegrationTypes } from "constants/backend"
@ -18,7 +18,7 @@
) )
$: { $: {
if (datasource?.source === IntegrationTypes.REST) { if (datasource?.source === IntegrationTypes.REST) {
$goto(`../rest/${$params.query}`) $redirect(`../rest/${$params.query}`)
} }
} }
</script> </script>

View file

@ -1,11 +1,11 @@
<script> <script>
import { datasources } from "stores/backend" import { datasources } from "stores/backend"
import { goto } from "@roxi/routify" import { redirect } from "@roxi/routify"
import { onMount } from "svelte" import { onMount } from "svelte"
onMount(async () => { onMount(async () => {
// navigate to first table in list, if not already selected // navigate to first table in list, if not already selected
$datasources.list.length > 0 && $goto(`./${$datasources.list[0]._id}`) $datasources.list.length > 0 && $redirect(`./${$datasources.list[0]._id}`)
}) })
</script> </script>

View file

@ -1,5 +1,5 @@
<script> <script>
import { goto } from "@roxi/routify" import { redirect } from "@roxi/routify"
import { onMount } from "svelte" import { onMount } from "svelte"
import { admin } from "stores/portal" import { admin } from "stores/portal"
import CreateDatasourceModal from "components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte" import CreateDatasourceModal from "components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte"
@ -14,7 +14,7 @@
if (!setupComplete && !$admin.isDev) { if (!setupComplete && !$admin.isDev) {
modal.show() modal.show()
} else { } else {
$goto("./table") $redirect("./table")
} }
}) })
</script> </script>

View file

@ -1,6 +1,6 @@
<script> <script>
import { goto } from "@roxi/routify" import { redirect } from "@roxi/routify"
$goto("../../") $redirect("../../")
</script> </script>
<!-- routify:options index=false --> <!-- routify:options index=false -->

View file

@ -1,6 +1,6 @@
<script> <script>
import { goto } from "@roxi/routify" import { redirect } from "@roxi/routify"
$goto("../") $redirect("../")
</script> </script>
<!-- routify:options index=false --> <!-- routify:options index=false -->

View file

@ -1,6 +1,6 @@
<script> <script>
import { tables } from "stores/backend" import { tables } from "stores/backend"
import { goto, leftover } from "@roxi/routify" import { redirect, leftover } from "@roxi/routify"
import { onMount } from "svelte" import { onMount } from "svelte"
onMount(async () => { onMount(async () => {
@ -11,7 +11,7 @@
$tables.list.length > 0 && $tables.list.length > 0 &&
(!$tables.selected || !$tables.selected._id) (!$tables.selected || !$tables.selected._id)
) { ) {
$goto(`./${$tables.list[0]._id}`) $redirect(`./${$tables.list[0]._id}`)
} }
}) })
</script> </script>

View file

@ -1,10 +1,10 @@
<script> <script>
import { goto } from "@roxi/routify" import { redirect } from "@roxi/routify"
import { onMount } from "svelte" import { onMount } from "svelte"
import { tables } from "stores/backend" import { tables } from "stores/backend"
onMount(async () => { onMount(async () => {
$tables.list.length > 0 && $goto(`./${$tables.list[0]._id}`) $tables.list.length > 0 && $redirect(`./${$tables.list[0]._id}`)
}) })
</script> </script>

View file

@ -17,7 +17,10 @@
routify, routify,
}) })
onDestroy(stopSyncing) onDestroy(() => {
console.log("============= stop syncing screen ID!")
stopSyncing()
})
</script> </script>
<div class="design"> <div class="design">

View file

@ -15,7 +15,10 @@
routify, routify,
}) })
onDestroy(stopSyncing) onDestroy(() => {
console.log("============= stop syncing component ID!")
stopSyncing()
})
</script> </script>
<slot /> <slot />

View file

@ -1,4 +1,4 @@
<script> <script>
import { goto } from "@roxi/routify" import { redirect } from "@roxi/routify"
$goto("./design") $redirect("./design")
</script> </script>

View file

@ -1,4 +1,4 @@
<script> <script>
import { goto } from "@roxi/routify" import { redirect } from "@roxi/routify"
$goto("../portal") $redirect("../portal")
</script> </script>