fix: Do not give a wrong currentActor if there is no identities
Related to #1806
This commit is contained in:
@@ -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 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user