From 5a65d3d5494978d2e9ada8f07e57edf5218a4674 Mon Sep 17 00:00:00 2001 From: Massedil Date: Sun, 29 Jun 2025 15:15:17 +0200 Subject: [PATCH] fix: Do not give a wrong currentActor if there is no identities Related to #1806 --- src/composition/apollo/actor.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/composition/apollo/actor.ts b/src/composition/apollo/actor.ts index e26ab7b58..e9101885d 100644 --- a/src/composition/apollo/actor.ts +++ b/src/composition/apollo/actor.ts @@ -11,14 +11,25 @@ import { computed, Ref, unref } from "vue"; import { useCurrentUserClient } from "./user"; export function useCurrentActorClient() { + const { identities } = useCurrentUserIdentities(); + + // There is a current actor only if there is at least one identity + const enabled = computed( + () => identities.value != undefined && identities.value?.length > 0 + ); + const { result: currentActorResult, error, loading, - } = useQuery<{ currentActor: IPerson }>(CURRENT_ACTOR_CLIENT); - const currentActor = computed( - () => currentActorResult.value?.currentActor + } = useQuery<{ currentActor: IPerson }>(CURRENT_ACTOR_CLIENT, {}, () => ({ + enabled: enabled, + })); + + const currentActor = computed(() => + enabled.value ? currentActorResult.value?.currentActor : undefined ); + return { currentActor, error, loading }; }