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";
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<IPerson | undefined>(
() => currentActorResult.value?.currentActor
} = useQuery<{ currentActor: IPerson }>(CURRENT_ACTOR_CLIENT, {}, () => ({
enabled: enabled,
}));
const currentActor = computed<IPerson | undefined>(() =>
enabled.value ? currentActorResult.value?.currentActor : undefined
);
return { currentActor, error, loading };
}