fix: Do not give a wrong currentActor if there is no identities

Related to #1806
This commit is contained in:
Massedil
2025-06-29 15:15:17 +02:00
parent 26186e96fc
commit 5a65d3d549

View File

@@ -11,14 +11,25 @@ import { computed, Ref, unref } from "vue";
import { useCurrentUserClient } from "./user"; import { useCurrentUserClient } from "./user";
export function useCurrentActorClient() { 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 { const {
result: currentActorResult, result: currentActorResult,
error, error,
loading, loading,
} = useQuery<{ currentActor: IPerson }>(CURRENT_ACTOR_CLIENT); } = useQuery<{ currentActor: IPerson }>(CURRENT_ACTOR_CLIENT, {}, () => ({
const currentActor = computed<IPerson | undefined>( enabled: enabled,
() => currentActorResult.value?.currentActor }));
const currentActor = computed<IPerson | undefined>(() =>
enabled.value ? currentActorResult.value?.currentActor : undefined
); );
return { currentActor, error, loading }; return { currentActor, error, loading };
} }