fix: refs #8647 solve warning

This commit is contained in:
Javier Segarra 2025-03-10 13:02:14 +01:00
parent 04a3c48cd6
commit dcd4c327a0
1 changed files with 18 additions and 6 deletions

View File

@ -8,24 +8,36 @@ import { isDialogOpened } from 'src/filters';
const arrayDataStore = useArrayDataStore();
export function useArrayData(key, userOptions) {
key ??= useRoute().meta.moduleName;
let route = null;
let router = null;
const initializeRouting = () => {
if (!route) route = useRoute();
if (!router) router = useRouter();
return { route, router };
};
// Si no hay key, intentamos obtenerla del route
if (!key) {
const { route: initialRoute, router: initialRouter } = initializeRouting();
key = initialRoute?.meta?.moduleName;
route = initialRoute;
router = initialRouter;
}
if (!key) throw new Error('ArrayData: A key is required to use this composable');
if (!arrayDataStore.get(key)) arrayDataStore.set(key);
const store = arrayDataStore.get(key);
const route = useRoute();
const router = useRouter();
let canceller = null;
onMounted(() => {
setOptions();
reset(['skip']);
const query = route.query;
const { route: initialRoute, router: initialRouter } = initializeRouting();
route = initialRoute;
router = initialRouter;
const searchUrl = store.searchUrl;
if (query[searchUrl]) {
if (route.query[searchUrl]) {
const params = JSON.parse(query[searchUrl]);
const filter =
params?.filter && typeof params?.filter == 'object'