mirror of
https://github.com/p-stream/p-stream.git
synced 2026-03-11 17:55:33 +00:00
fix account nickname not updating or displaying
This commit is contained in:
parent
067b6e43bc
commit
04a08af5e9
3 changed files with 23 additions and 6 deletions
|
|
@ -188,6 +188,16 @@ export function useAuth() {
|
|||
getGroupOrder(backendUrl, account),
|
||||
]);
|
||||
|
||||
// Update account store with fresh user data (including nickname)
|
||||
const { setAccount } = useAuthStore.getState();
|
||||
if (account) {
|
||||
setAccount({
|
||||
...account,
|
||||
nickname: user.user.nickname,
|
||||
profile: user.user.profile,
|
||||
});
|
||||
}
|
||||
|
||||
syncData(
|
||||
user.user,
|
||||
user.session,
|
||||
|
|
|
|||
|
|
@ -485,9 +485,9 @@ export function SettingsPage() {
|
|||
);
|
||||
|
||||
const account = useAuthStore((s) => s.account);
|
||||
const setAccount = useAuthStore((s) => s.setAccount);
|
||||
const updateProfile = useAuthStore((s) => s.setAccountProfile);
|
||||
const updateDeviceName = useAuthStore((s) => s.updateDeviceName);
|
||||
const updateNickname = useAuthStore((s) => s.setAccountNickname);
|
||||
const decryptedName = useMemo(() => {
|
||||
if (!account) return "";
|
||||
return decryptData(account.deviceName, base64ToBuffer(account.seed));
|
||||
|
|
@ -656,14 +656,13 @@ export function SettingsPage() {
|
|||
await editUser(backendUrl, account, {
|
||||
nickname: state.nickname.state,
|
||||
});
|
||||
// Update the account in the store
|
||||
const updatedAccount = { ...account, nickname: state.nickname.state };
|
||||
setAccount(updatedAccount);
|
||||
updateNickname(state.nickname.state);
|
||||
}
|
||||
if (state.profile.changed) {
|
||||
if (state.profile.changed && state.profile.state) {
|
||||
await editUser(backendUrl, account, {
|
||||
profile: state.profile.state,
|
||||
});
|
||||
updateProfile(state.profile.state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -734,7 +733,7 @@ export function SettingsPage() {
|
|||
setProxySet,
|
||||
updateDeviceName,
|
||||
updateProfile,
|
||||
setAccount,
|
||||
updateNickname,
|
||||
logout,
|
||||
setBackendUrl,
|
||||
setProxyTmdb,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ interface AuthStore {
|
|||
updateDeviceName(deviceName: string): void;
|
||||
updateAccount(acc: Partial<Account>): void;
|
||||
setAccountProfile(acc: Account["profile"]): void;
|
||||
setAccountNickname(nickname: string): void;
|
||||
setBackendUrl(url: null | string): void;
|
||||
setProxySet(urls: null | string[]): void;
|
||||
}
|
||||
|
|
@ -65,6 +66,13 @@ export const useAuthStore = create(
|
|||
}
|
||||
});
|
||||
},
|
||||
setAccountNickname(nickname) {
|
||||
set((s) => {
|
||||
if (s.account) {
|
||||
s.account.nickname = nickname;
|
||||
}
|
||||
});
|
||||
},
|
||||
updateAccount(acc) {
|
||||
set((s) => {
|
||||
if (!s.account) return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue