diff --git a/packages/web/src/appobj/DatabaseAppObject.svelte b/packages/web/src/appobj/DatabaseAppObject.svelte index fb1756084..6f8e6a45e 100644 --- a/packages/web/src/appobj/DatabaseAppObject.svelte +++ b/packages/web/src/appobj/DatabaseAppObject.svelte @@ -315,7 +315,7 @@ ); } - $: isPinned = !!$pinnedDatabases.find(x => x.name == data.name && x.connection?._id == data.connection?._id); + $: isPinned = !!$pinnedDatabases.find(x => x?.name == data.name && x?.connection?._id == data.connection?._id); $: apps = useUsedApps(); diff --git a/packages/web/src/appobj/PinnedAppObject.svelte b/packages/web/src/appobj/PinnedAppObject.svelte index ebca63ceb..460a46549 100644 --- a/packages/web/src/appobj/PinnedAppObject.svelte +++ b/packages/web/src/appobj/PinnedAppObject.svelte @@ -13,11 +13,13 @@ if (!compare(dragged, data)) { const i1 = _.findIndex(pinned, x => compare(x, dragged)); const i2 = _.findIndex(pinned, x => compare(x, data)); - const newPinned = [...pinned]; - const tmp = newPinned[i1]; - newPinned[i1] = newPinned[i2]; - newPinned[i2] = tmp; - setPinned(newPinned); + if (i1 >= 0 && i2 >= 0 && i1 != i2) { + const newPinned = [...pinned]; + const tmp = newPinned[i1]; + newPinned[i1] = newPinned[i2]; + newPinned[i2] = tmp; + setPinned(newPinned); + } } } @@ -29,42 +31,44 @@ export let data; -{#if data.objectTypeField} - { - $draggedPinnedObject = data; - }} - on:dragenter={e => { - dragExchange( - $draggedPinnedObject, - data, - $pinnedTables, - value => ($pinnedTables = value), - (a, b) => a?.pureName == b?.pureName && a?.schemaName == b?.schemaName - ); - }} - on:dragend={() => { - $draggedPinnedObject = null; - }} - /> -{:else} - { - $draggedPinnedObject = data; - }} - on:dragenter={e => { - dragExchange( - $draggedPinnedObject, - data, - $pinnedDatabases, - value => ($pinnedDatabases = value), - (a, b) => a?.name == b?.name && a?.connection?._id == b?.connection?._id - ); - }} - on:dragend={() => { - $draggedPinnedObject = null; - }} - /> +{#if data} + {#if data.objectTypeField} + { + $draggedPinnedObject = data; + }} + on:dragenter={e => { + dragExchange( + $draggedPinnedObject, + data, + $pinnedTables, + value => ($pinnedTables = value), + (a, b) => a?.pureName == b?.pureName && a?.schemaName == b?.schemaName + ); + }} + on:dragend={() => { + $draggedPinnedObject = null; + }} + /> + {:else} + { + $draggedPinnedObject = data; + }} + on:dragenter={e => { + dragExchange( + $draggedPinnedObject, + data, + $pinnedDatabases, + value => ($pinnedDatabases = value), + (a, b) => a?.name == b?.name && a?.connection?._id == b?.connection?._id + ); + }} + on:dragend={() => { + $draggedPinnedObject = null; + }} + /> + {/if} {/if}