Browse Source

fix: move cache reference within clossure since each instance should have its own cache

pull/8732/head
Pranav C 5 months ago
parent
commit
8dbda1cb99
  1. 6
      packages/nc-gui/composables/useDebounceFnCached.ts
  2. 8
      packages/nc-gui/composables/useViewFilters.ts

6
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<string | number, any>()
// Default function to generate a cache key
function defaultGetCacheKey(): string {
return 'default'
@ -26,6 +23,9 @@ export function useCachedDebouncedFunction<T extends FunctionArgs>(
getCacheKey: (...args: Parameters<T>) => string | number = defaultGetCacheKey,
options: DebounceFilterOptions = {},
): (...args: Parameters<T>) => ReturnType<T> {
// Cache to store debounced functions based on a unique key
const debounceCache = new Map<string | number, any>()
return function (...args: Parameters<T>): ReturnType<T> {
// Generate a unique key for the given arguments
const key = getCacheKey(args)

8
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,
}
}

Loading…
Cancel
Save