π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix: export `useSmartsheetStore` and add a fallback to prevent crashes in lazy-loaded components.
Pranav C634a0ea6b885
diff --git a/packages/nc-gui/components/smartsheet/toolbar/ExportSubActions.vue b/packages/nc-gui/components/smartsheet/toolbar/ExportSubActions.vueindex 786c193ba2..d5c209c21c 100644--- a/packages/nc-gui/components/smartsheet/toolbar/ExportSubActions.vue+++ b/packages/nc-gui/components/smartsheet/toolbar/ExportSubActions.vue@@ -45,7 +45,15 @@ const handleDownload = async (url: string) => {const isExporting = ref(false)-const { sorts, nestedFilters, isLocked } = useSmartsheetStoreOrThrow()+/**+ * This component is lazy loaded and might be initialized after the view is effectively unmounted.+ * In that case, the store is not available anymore, so we need to provide a fallback to avoid a crash.+ */+const { sorts, nestedFilters, isLocked } = useSmartsheetStore() || {+ sorts: ref([]),+ nestedFilters: ref([]),+ isLocked: ref(false),+}const { isUIAllowed } = useRoles()const exportFile = async (exportType: ExportTypes) => {diff --git a/packages/nc-gui/composables/useSmartsheetStore.ts b/packages/nc-gui/composables/useSmartsheetStore.tsindex 208aec1b8e..03f6439462 100644--- a/packages/nc-gui/composables/useSmartsheetStore.ts+++ b/packages/nc-gui/composables/useSmartsheetStore.ts@@ -272,7 +272,7 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState('smartsheet-store',)-export { useProvideSmartsheetStore }+export { useProvideSmartsheetStore, useSmartsheetStore }export function useSmartsheetStoreOrThrow() {const state = useSmartsheetStore()