refactor: Remove the registerPerson GraphQL query

- The first profile is now created after the user email validation
- NavBar is correctly updated when a user is connected but without any profile
- Always fetch identities from the server at login (no cache)
- NoIdentitiesException is thrown again
- Refactor EditIdentity to create the first profile
- Translations updated
- Tests updated

Fixes #1762
This commit is contained in:
Massedil
2025-05-23 20:34:00 +02:00
committed by setop
parent a9cfcd9e9d
commit 8bb6b0b97c
51 changed files with 138 additions and 609 deletions

View File

@@ -25,7 +25,13 @@ export function useCurrentActorClient() {
export function useLazyCurrentUserIdentities() {
return useLazyQuery<{
loggedUser: Pick<ICurrentUser, "actors">;
}>(IDENTITIES);
}>(
IDENTITIES,
{},
{
fetchPolicy: "network-only",
}
);
}
export function useCurrentUserIdentities() {

View File

@@ -1,4 +1,3 @@
import { IDENTITIES, REGISTER_PERSON } from "@/graphql/actor";
import {
CURRENT_USER_CLIENT,
LOGGED_USER_AND_SETTINGS,
@@ -6,10 +5,7 @@ import {
SET_USER_SETTINGS,
UPDATE_USER_LOCALE,
} from "@/graphql/user";
import { IPerson } from "@/types/actor";
import { ICurrentUser, IUser } from "@/types/current-user.model";
import { ActorType } from "@/types/enums";
import { ApolloCache, FetchResult } from "@apollo/client/core";
import { useMutation, useQuery } from "@vue/apollo-composable";
import { computed } from "vue";
@@ -65,44 +61,3 @@ export async function doUpdateSetting(
export function updateLocale() {
return useMutation<{ id: string; locale: string }>(UPDATE_USER_LOCALE);
}
export function registerAccount() {
return useMutation<
{ registerPerson: IPerson },
{
preferredUsername: string;
name: string;
summary: string;
email: string;
}
>(REGISTER_PERSON, () => ({
update: (
store: ApolloCache<{ registerPerson: IPerson }>,
{ data: localData }: FetchResult,
{ context }
) => {
if (context?.userAlreadyActivated) {
const currentUserData = store.readQuery<{
loggedUser: Pick<ICurrentUser, "actors" | "id">;
}>({
query: IDENTITIES,
});
if (currentUserData && localData) {
const newPersonData = {
...localData.registerPerson,
type: ActorType.PERSON,
};
store.writeQuery({
query: IDENTITIES,
data: {
...currentUserData.loggedUser,
actors: [[...currentUserData.loggedUser.actors, newPersonData]],
},
});
}
}
},
}));
}