@comapeo/core-react 11.0.5 → 11.0.6

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.
@@ -423,9 +423,18 @@ function useLeaveProject() {
423
423
  mutationFn: async ({ projectId }) => {
424
424
  return clientApi.leaveProject(projectId);
425
425
  },
426
- onSuccess: () => {
426
+ onSuccess: (_data, { projectId }) => {
427
+ const queryKey = (0, react_query_js_1.getProjectByIdQueryKey)({ projectId });
428
+ // Leaving closes the project's non-auth data stores, so refetching its
429
+ // queries would error. Mark them stale without refetching.
430
+ queryClient.invalidateQueries({
431
+ queryKey,
432
+ refetchType: 'none',
433
+ });
427
434
  queryClient.invalidateQueries({
428
435
  queryKey: (0, react_query_js_1.getProjectsQueryKey)(),
436
+ // The inverse of above - refetch all projects queries except the one for the left project
437
+ predicate: (query) => !(0, react_query_1.matchQuery)({ queryKey }, query),
429
438
  });
430
439
  },
431
440
  }));
@@ -1,4 +1,4 @@
1
- import { useMutation, useQueryClient, useSuspenseQuery, } from '@tanstack/react-query';
1
+ import { matchQuery, useMutation, useQueryClient, useSuspenseQuery, } from '@tanstack/react-query';
2
2
  import { useEffect, useSyncExternalStore } from 'react';
3
3
  import { baseMutationOptions, baseQueryOptions, filterMutationResult, getDocumentCreatedByQueryKey, getMediaServerOriginQueryKey, getMemberByIdQueryKey, getMembersQueryKey, getProjectByIdQueryKey, getProjectRoleQueryKey, getProjectSettingsQueryKey, getProjectsQueryKey, } from '../lib/react-query.js';
4
4
  import { SyncStore } from '../lib/sync.js';
@@ -392,9 +392,18 @@ export function useLeaveProject() {
392
392
  mutationFn: async ({ projectId }) => {
393
393
  return clientApi.leaveProject(projectId);
394
394
  },
395
- onSuccess: () => {
395
+ onSuccess: (_data, { projectId }) => {
396
+ const queryKey = getProjectByIdQueryKey({ projectId });
397
+ // Leaving closes the project's non-auth data stores, so refetching its
398
+ // queries would error. Mark them stale without refetching.
399
+ queryClient.invalidateQueries({
400
+ queryKey,
401
+ refetchType: 'none',
402
+ });
396
403
  queryClient.invalidateQueries({
397
404
  queryKey: getProjectsQueryKey(),
405
+ // The inverse of above - refetch all projects queries except the one for the left project
406
+ predicate: (query) => !matchQuery({ queryKey }, query),
398
407
  });
399
408
  },
400
409
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comapeo/core-react",
3
- "version": "11.0.5",
3
+ "version": "11.0.6",
4
4
  "description": "React wrapper for working with @comapeo/core",
5
5
  "repository": {
6
6
  "type": "git",