diff --git a/public/locales/en/user.json b/public/locales/en/user.json index d5837bf34..2f33f8708 100644 --- a/public/locales/en/user.json +++ b/public/locales/en/user.json @@ -139,8 +139,8 @@ "already_exists": "This profile name is already taken. Please choose another one.", "invalid_characters": "Your profile name can only contain letters, numbers, and spaces.", "required": "Please enter a name for your profile.", - "too_long": "Please limit your profile name to {{count}} characters or fewer.", - "too_short": "Please enter at least {{count}} characters." + "too_long": "Please limit your profile name to {{charactersCount}} characters or fewer.", + "too_short": "Please enter at least {{charactersCount}} characters." } }, "watch_now": "Watch now" diff --git a/src/hooks/useProfiles.ts b/src/hooks/useProfiles.ts index 8dabb3d0a..d491a2dde 100644 --- a/src/hooks/useProfiles.ts +++ b/src/hooks/useProfiles.ts @@ -7,7 +7,6 @@ import { createProfile, deleteProfile, enterProfile, listProfiles, updateProfile import { useProfileStore } from '#src/stores/ProfileStore'; import type { CommonAccountResponse, ListProfilesResponse, ProfileDetailsPayload, ProfilePayload } from '#types/account'; import { useAccountStore } from '#src/stores/AccountStore'; -import defaultAvatar from '#src/assets/profiles/default_avatar.png'; import type { GenericFormErrors } from '#types/form'; import type { ProfileFormSubmitError } from '#src/containers/Profiles/types'; @@ -102,23 +101,9 @@ export const useProfiles = ( const user = useAccountStore((s) => s.user); const query = useQuery(['listProfiles'], listProfiles, { ...options, enabled: !!user }); const { canManageProfiles } = useAccountStore(); - if (!canManageProfiles && query.data?.responseData.canManageProfiles) { - useAccountStore.setState({ canManageProfiles: true }); - } return { ...query, - data: { - ...query.data, - responseData: { - ...query.data?.responseData, - collection: - query.data?.responseData.collection.map((profile) => ({ - ...profile, - avatar_url: profile?.avatar_url || defaultAvatar, - })) ?? [], - }, - }, profilesEnabled: query.data?.responseData.canManageProfiles && canManageProfiles, }; }; diff --git a/src/services/inplayer.profile.service.ts b/src/services/inplayer.profile.service.ts index 0ece11b80..822040e41 100644 --- a/src/services/inplayer.profile.service.ts +++ b/src/services/inplayer.profile.service.ts @@ -1,6 +1,7 @@ import InPlayer from '@inplayer-org/inplayer.js'; import type { ListProfiles, CreateProfile, UpdateProfile, EnterProfile, GetProfileDetails, DeleteProfile } from '#types/account'; +import defaultAvatar from '#src/assets/profiles/default_avatar.png'; export const listProfiles: ListProfiles = async () => { try { @@ -8,7 +9,11 @@ export const listProfiles: ListProfiles = async () => { return { responseData: { canManageProfiles: true, - collection: response.data, + collection: + response.data.map((profile) => ({ + ...profile, + avatar_url: profile?.avatar_url || defaultAvatar, + })) ?? [], }, errors: [], }; diff --git a/src/stores/ProfileController.ts b/src/stores/ProfileController.ts index f709c1529..b20f008e8 100644 --- a/src/stores/ProfileController.ts +++ b/src/stores/ProfileController.ts @@ -2,6 +2,7 @@ import { useFavoritesStore } from './FavoritesStore'; import { useProfileStore } from './ProfileStore'; import { useWatchHistoryStore } from './WatchHistoryStore'; import { initializeAccount } from './AccountController'; +import { useAccountStore } from './AccountStore'; import * as persist from '#src/utils/persist'; import type { ProfilePayload, EnterProfilePayload, ProfileDetailsPayload } from '#types/account'; @@ -15,7 +16,12 @@ export const unpersistProfile = () => { export const listProfiles = async () => { return await useService(async ({ profileService, sandbox }) => { - return await profileService?.listProfiles(undefined, sandbox ?? true); + const res = await profileService?.listProfiles(undefined, sandbox ?? true); + const canManageProfiles = useAccountStore.getState().canManageProfiles; + if (!canManageProfiles && res?.responseData.canManageProfiles) { + useAccountStore.setState({ canManageProfiles: true }); + } + return res; }); };