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;
const { load: loadIdentities } = useLazyCurrentUserIdentities();
onBeforeMount(async () => {
console.debug("Before mount App");
if (initializeCurrentUser()) {
try {
const result = await loadIdentities();
const result = useLazyCurrentUserIdentities();
if (!result) return;
await initializeCurrentActor(result.loggedUser.actors);
await initializeCurrentActor(result.result.value?.loggedUser.actors);
} catch (err) {
if (err instanceof NoIdentitiesException) {
await router.push({

View file

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

View file

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