@greatapps/common 1.1.500 → 1.1.502
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,31 +10,52 @@ function useDeleteProject() {
|
|
|
10
10
|
return useMutation({
|
|
11
11
|
mutationFn: ({ projectId, moveToProjectId }) => withAction(deleteProjectAction)(projectId, moveToProjectId),
|
|
12
12
|
onSuccess: (_, { projectId }) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
console.log("[useDeleteProject] onSuccess called, projectId:", projectId);
|
|
14
|
+
console.log("[useDeleteProject] projectsKey:", projectsKey);
|
|
15
|
+
const cache = queryClient.getQueryCache();
|
|
16
|
+
const queries = cache.findAll({ queryKey: projectsKey });
|
|
17
|
+
console.log("[useDeleteProject] queries found:", queries.length, queries.map((q) => ({ key: q.queryKey, isInfinite: q.queryKey.includes("infinite") })));
|
|
18
|
+
for (const query of queries) {
|
|
19
|
+
const isInfinite = query.queryKey.includes("infinite");
|
|
20
|
+
if (isInfinite) {
|
|
21
|
+
queryClient.setQueryData(
|
|
22
|
+
query.queryKey,
|
|
23
|
+
(old) => {
|
|
24
|
+
if (!old?.pages.length) return old;
|
|
25
|
+
const before = old.pages.flatMap((p) => p.data).length;
|
|
26
|
+
const result = {
|
|
27
|
+
...old,
|
|
28
|
+
pages: old.pages.map((page) => ({
|
|
29
|
+
...page,
|
|
30
|
+
data: page.data.filter((p) => p.id !== projectId),
|
|
31
|
+
total: page.total - 1
|
|
32
|
+
}))
|
|
33
|
+
};
|
|
34
|
+
const after = result.pages.flatMap((p) => p.data).length;
|
|
35
|
+
console.log("[useDeleteProject] infinite query updated:", { before, after, key: query.queryKey });
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
} else {
|
|
40
|
+
queryClient.setQueryData(
|
|
41
|
+
query.queryKey,
|
|
42
|
+
(old) => {
|
|
43
|
+
if (!old) {
|
|
44
|
+
console.log("[useDeleteProject] list query old is null/undefined");
|
|
45
|
+
return old;
|
|
46
|
+
}
|
|
47
|
+
const before = old.data.length;
|
|
48
|
+
const result = {
|
|
49
|
+
...old,
|
|
50
|
+
data: old.data.filter((p) => p.id !== projectId),
|
|
51
|
+
total: old.total - 1
|
|
52
|
+
};
|
|
53
|
+
console.log("[useDeleteProject] list query updated:", { before, after: result.data.length, key: query.queryKey });
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
);
|
|
25
57
|
}
|
|
26
|
-
|
|
27
|
-
queryClient.setQueriesData(
|
|
28
|
-
{ queryKey: projectsKey, exact: false },
|
|
29
|
-
(old) => {
|
|
30
|
-
if (!old) return old;
|
|
31
|
-
return {
|
|
32
|
-
...old,
|
|
33
|
-
data: old.data.filter((p) => p.id !== projectId),
|
|
34
|
-
total: old.total - 1
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
);
|
|
58
|
+
}
|
|
38
59
|
queryClient.invalidateQueries({ queryKey: projectsKey });
|
|
39
60
|
}
|
|
40
61
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/projects/hooks/delete-project.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient, InfiniteData } from '@tanstack/react-query';\nimport { deleteProjectAction } from '../actions/delete-project.action';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { PROJECTS_BASE_KEY } from './list-projects.hook';\nimport type { ProjectsPage } from '../types';\n\nexport function useDeleteProject() {\n const queryClient = useQueryClient();\n const projectsKey = useAuthQueryKey([...PROJECTS_BASE_KEY]);\n\n return useMutation({\n mutationFn: ({ projectId, moveToProjectId }: { projectId: number; moveToProjectId: number }) =>\n withAction(deleteProjectAction)(projectId, moveToProjectId),\n\n onSuccess: (_, { projectId }) => {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/hooks/delete-project.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient, InfiniteData } from '@tanstack/react-query';\nimport { deleteProjectAction } from '../actions/delete-project.action';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { PROJECTS_BASE_KEY } from './list-projects.hook';\nimport type { ProjectsPage } from '../types';\n\nexport function useDeleteProject() {\n const queryClient = useQueryClient();\n const projectsKey = useAuthQueryKey([...PROJECTS_BASE_KEY]);\n\n return useMutation({\n mutationFn: ({ projectId, moveToProjectId }: { projectId: number; moveToProjectId: number }) =>\n withAction(deleteProjectAction)(projectId, moveToProjectId),\n\n onSuccess: (_, { projectId }) => {\n console.log('[useDeleteProject] onSuccess called, projectId:', projectId);\n console.log('[useDeleteProject] projectsKey:', projectsKey);\n\n const cache = queryClient.getQueryCache();\n const queries = cache.findAll({ queryKey: projectsKey });\n console.log('[useDeleteProject] queries found:', queries.length, queries.map((q) => ({ key: q.queryKey, isInfinite: q.queryKey.includes('infinite') })));\n\n for (const query of queries) {\n const isInfinite = query.queryKey.includes('infinite');\n\n if (isInfinite) {\n queryClient.setQueryData<InfiniteData<ProjectsPage>>(\n query.queryKey,\n (old) => {\n if (!old?.pages.length) return old;\n const before = old.pages.flatMap((p) => p.data).length;\n const result = {\n ...old,\n pages: old.pages.map((page) => ({\n ...page,\n data: page.data.filter((p) => p.id !== projectId),\n total: page.total - 1,\n })),\n };\n const after = result.pages.flatMap((p) => p.data).length;\n console.log('[useDeleteProject] infinite query updated:', { before, after, key: query.queryKey });\n return result;\n },\n );\n } else {\n queryClient.setQueryData<ProjectsPage>(\n query.queryKey,\n (old) => {\n if (!old) { console.log('[useDeleteProject] list query old is null/undefined'); return old; }\n const before = old.data.length;\n const result = {\n ...old,\n data: old.data.filter((p) => p.id !== projectId),\n total: old.total - 1,\n };\n console.log('[useDeleteProject] list query updated:', { before, after: result.data.length, key: query.queryKey });\n return result;\n },\n );\n }\n }\n\n queryClient.invalidateQueries({ queryKey: projectsKey });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,aAAa,sBAAoC;AAC1D,SAAS,2BAA2B;AACpC,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAG3B,SAAS,mBAAmB;AACjC,QAAM,cAAc,eAAe;AACnC,QAAM,cAAc,gBAAgB,CAAC,GAAG,iBAAiB,CAAC;AAE1D,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,EAAE,WAAW,gBAAgB,MACxC,WAAW,mBAAmB,EAAE,WAAW,eAAe;AAAA,IAE5D,WAAW,CAAC,GAAG,EAAE,UAAU,MAAM;AAC/B,cAAQ,IAAI,mDAAmD,SAAS;AACxE,cAAQ,IAAI,mCAAmC,WAAW;AAE1D,YAAM,QAAQ,YAAY,cAAc;AACxC,YAAM,UAAU,MAAM,QAAQ,EAAE,UAAU,YAAY,CAAC;AACvD,cAAQ,IAAI,qCAAqC,QAAQ,QAAQ,QAAQ,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,YAAY,EAAE,SAAS,SAAS,UAAU,EAAE,EAAE,CAAC;AAEvJ,iBAAW,SAAS,SAAS;AAC3B,cAAM,aAAa,MAAM,SAAS,SAAS,UAAU;AAErD,YAAI,YAAY;AACd,sBAAY;AAAA,YACV,MAAM;AAAA,YACN,CAAC,QAAQ;AACP,kBAAI,CAAC,KAAK,MAAM,OAAQ,QAAO;AAC/B,oBAAM,SAAS,IAAI,MAAM,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE;AAChD,oBAAM,SAAS;AAAA,gBACb,GAAG;AAAA,gBACH,OAAO,IAAI,MAAM,IAAI,CAAC,UAAU;AAAA,kBAC9B,GAAG;AAAA,kBACH,MAAM,KAAK,KAAK,OAAO,CAAC,MAAM,EAAE,OAAO,SAAS;AAAA,kBAChD,OAAO,KAAK,QAAQ;AAAA,gBACtB,EAAE;AAAA,cACJ;AACA,oBAAM,QAAQ,OAAO,MAAM,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE;AAClD,sBAAQ,IAAI,8CAA8C,EAAE,QAAQ,OAAO,KAAK,MAAM,SAAS,CAAC;AAChG,qBAAO;AAAA,YACT;AAAA,UACF;AAAA,QACF,OAAO;AACL,sBAAY;AAAA,YACV,MAAM;AAAA,YACN,CAAC,QAAQ;AACP,kBAAI,CAAC,KAAK;AAAE,wBAAQ,IAAI,qDAAqD;AAAG,uBAAO;AAAA,cAAK;AAC5F,oBAAM,SAAS,IAAI,KAAK;AACxB,oBAAM,SAAS;AAAA,gBACb,GAAG;AAAA,gBACH,MAAM,IAAI,KAAK,OAAO,CAAC,MAAM,EAAE,OAAO,SAAS;AAAA,gBAC/C,OAAO,IAAI,QAAQ;AAAA,cACrB;AACA,sBAAQ,IAAI,0CAA0C,EAAE,QAAQ,OAAO,OAAO,KAAK,QAAQ,KAAK,MAAM,SAAS,CAAC;AAChH,qBAAO;AAAA,YACT;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,kBAAY,kBAAkB,EAAE,UAAU,YAAY,CAAC;AAAA,IACzD;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/package.json
CHANGED
|
@@ -16,32 +16,52 @@ export function useDeleteProject() {
|
|
|
16
16
|
withAction(deleteProjectAction)(projectId, moveToProjectId),
|
|
17
17
|
|
|
18
18
|
onSuccess: (_, { projectId }) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
19
|
+
console.log('[useDeleteProject] onSuccess called, projectId:', projectId);
|
|
20
|
+
console.log('[useDeleteProject] projectsKey:', projectsKey);
|
|
21
|
+
|
|
22
|
+
const cache = queryClient.getQueryCache();
|
|
23
|
+
const queries = cache.findAll({ queryKey: projectsKey });
|
|
24
|
+
console.log('[useDeleteProject] queries found:', queries.length, queries.map((q) => ({ key: q.queryKey, isInfinite: q.queryKey.includes('infinite') })));
|
|
25
|
+
|
|
26
|
+
for (const query of queries) {
|
|
27
|
+
const isInfinite = query.queryKey.includes('infinite');
|
|
28
|
+
|
|
29
|
+
if (isInfinite) {
|
|
30
|
+
queryClient.setQueryData<InfiniteData<ProjectsPage>>(
|
|
31
|
+
query.queryKey,
|
|
32
|
+
(old) => {
|
|
33
|
+
if (!old?.pages.length) return old;
|
|
34
|
+
const before = old.pages.flatMap((p) => p.data).length;
|
|
35
|
+
const result = {
|
|
36
|
+
...old,
|
|
37
|
+
pages: old.pages.map((page) => ({
|
|
38
|
+
...page,
|
|
39
|
+
data: page.data.filter((p) => p.id !== projectId),
|
|
40
|
+
total: page.total - 1,
|
|
41
|
+
})),
|
|
42
|
+
};
|
|
43
|
+
const after = result.pages.flatMap((p) => p.data).length;
|
|
44
|
+
console.log('[useDeleteProject] infinite query updated:', { before, after, key: query.queryKey });
|
|
45
|
+
return result;
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
} else {
|
|
49
|
+
queryClient.setQueryData<ProjectsPage>(
|
|
50
|
+
query.queryKey,
|
|
51
|
+
(old) => {
|
|
52
|
+
if (!old) { console.log('[useDeleteProject] list query old is null/undefined'); return old; }
|
|
53
|
+
const before = old.data.length;
|
|
54
|
+
const result = {
|
|
55
|
+
...old,
|
|
56
|
+
data: old.data.filter((p) => p.id !== projectId),
|
|
57
|
+
total: old.total - 1,
|
|
58
|
+
};
|
|
59
|
+
console.log('[useDeleteProject] list query updated:', { before, after: result.data.length, key: query.queryKey });
|
|
60
|
+
return result;
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
45
65
|
|
|
46
66
|
queryClient.invalidateQueries({ queryKey: projectsKey });
|
|
47
67
|
},
|