use useQuery instead of useLazyQuery in useLazyCurrentUserIdentities

In the hopes of fixing
#44
through hints found at
https://github.com/apollographql/apollo-client/issues/9354
This commit is contained in:
778a69cd 2024-02-27 22:49:40 +01:00
parent 864e2fa660
commit a5b8530387
3 changed files with 5 additions and 9 deletions

View file

@ -139,15 +139,13 @@ interval.value = window.setInterval(async () => {
} }
}, 60000) as unknown as number; }, 60000) as unknown as number;
const { load: loadIdentities } = useLazyCurrentUserIdentities();
onBeforeMount(async () => { onBeforeMount(async () => {
console.debug("Before mount App"); console.debug("Before mount App");
if (initializeCurrentUser()) { if (initializeCurrentUser()) {
try { try {
const result = await loadIdentities(); const result = useLazyCurrentUserIdentities();
if (!result) return; if (!result) return;
await initializeCurrentActor(result.loggedUser.actors); await initializeCurrentActor(result.result.value?.loggedUser.actors);
} catch (err) { } catch (err) {
if (err instanceof NoIdentitiesException) { if (err instanceof NoIdentitiesException) {
await router.push({ await router.push({

View file

@ -23,7 +23,7 @@ export function useCurrentActorClient() {
} }
export function useLazyCurrentUserIdentities() { export function useLazyCurrentUserIdentities() {
return useLazyQuery<{ return useQuery<{
loggedUser: Pick<ICurrentUser, "actors">; loggedUser: Pick<ICurrentUser, "actors">;
}>(IDENTITIES); }>(IDENTITIES);
} }

View file

@ -238,17 +238,15 @@ const loginAction = (e: Event) => {
}); });
}; };
const { load: loadIdentities } = useLazyCurrentUserIdentities();
const { onDone: onCurrentUserMutationDone, mutate: updateCurrentUserMutation } = const { onDone: onCurrentUserMutationDone, mutate: updateCurrentUserMutation } =
useMutation(UPDATE_CURRENT_USER_CLIENT); useMutation(UPDATE_CURRENT_USER_CLIENT);
onCurrentUserMutationDone(async () => { onCurrentUserMutationDone(async () => {
console.debug("Current user mutation done, now setuping actors…"); console.debug("Current user mutation done, now setuping actors…");
try { try {
const result = await loadIdentities(); const result = useLazyCurrentUserIdentities();
if (!result) return; if (!result) return;
await initializeCurrentActor(result.loggedUser.actors); await initializeCurrentActor(result.result.value?.loggedUser.actors);
} catch (err: any) { } catch (err: any) {
if (err instanceof NoIdentitiesException && currentUser.value) { if (err instanceof NoIdentitiesException && currentUser.value) {
await router.push({ await router.push({