From 8dbda1cb99a94d6308033752677a1e1f5d3b8a0e Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 13 Jun 2024 21:26:33 +0000 Subject: [PATCH] fix: move cache reference within clossure since each instance should have its own cache --- packages/nc-gui/composables/useDebounceFnCached.ts | 6 +++--- packages/nc-gui/composables/useViewFilters.ts | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/nc-gui/composables/useDebounceFnCached.ts b/packages/nc-gui/composables/useDebounceFnCached.ts index 31b101fa23..d01c1aab5e 100644 --- a/packages/nc-gui/composables/useDebounceFnCached.ts +++ b/packages/nc-gui/composables/useDebounceFnCached.ts @@ -2,9 +2,6 @@ import type { DebounceFilterOptions, MaybeRefOrGetter } from '@vueuse/core' type FunctionArgs = (...args: any[]) => any -// Cache to store debounced functions based on a unique key -const debounceCache = new Map() - // Default function to generate a cache key function defaultGetCacheKey(): string { return 'default' @@ -26,6 +23,9 @@ export function useCachedDebouncedFunction( getCacheKey: (...args: Parameters) => string | number = defaultGetCacheKey, options: DebounceFilterOptions = {}, ): (...args: Parameters) => ReturnType { + // Cache to store debounced functions based on a unique key + const debounceCache = new Map() + return function (...args: Parameters): ReturnType { // Generate a unique key for the given arguments const key = getCacheKey(args) diff --git a/packages/nc-gui/composables/useViewFilters.ts b/packages/nc-gui/composables/useViewFilters.ts index b22f42b26d..ecd59224a2 100644 --- a/packages/nc-gui/composables/useViewFilters.ts +++ b/packages/nc-gui/composables/useViewFilters.ts @@ -381,7 +381,6 @@ export function useViewFilters( } } } - try { if (nestedMode.value) { filters.value[i] = { ...filter } @@ -407,19 +406,22 @@ export function useViewFilters( }) // override any local changes with saved filter since user can change value while saving filters.value[i] = { - ...(savedFilter || {}), ...filters.value[i], + fk_parent_id: parentId, + id: savedFilter.id, status: undefined, } } else { + console.log(parentId.value) const savedFilter = await $api.dbTableFilter.create(view.value.id!, { ...filter, fk_parent_id: parentId.value, }) // override any local changes with saved filter since user can change value while saving filters.value[i] = { - ...(savedFilter || {}), ...filters.value[i], + fk_parent_id: parentId, + id: savedFilter.id, status: undefined, } }