mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-20 23:22:12 +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),
|
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(
|
syncData(
|
||||||
user.user,
|
user.user,
|
||||||
user.session,
|
user.session,
|
||||||
|
|
|
||||||
|
|
@ -485,9 +485,9 @@ export function SettingsPage() {
|
||||||
);
|
);
|
||||||
|
|
||||||
const account = useAuthStore((s) => s.account);
|
const account = useAuthStore((s) => s.account);
|
||||||
const setAccount = useAuthStore((s) => s.setAccount);
|
|
||||||
const updateProfile = useAuthStore((s) => s.setAccountProfile);
|
const updateProfile = useAuthStore((s) => s.setAccountProfile);
|
||||||
const updateDeviceName = useAuthStore((s) => s.updateDeviceName);
|
const updateDeviceName = useAuthStore((s) => s.updateDeviceName);
|
||||||
|
const updateNickname = useAuthStore((s) => s.setAccountNickname);
|
||||||
const decryptedName = useMemo(() => {
|
const decryptedName = useMemo(() => {
|
||||||
if (!account) return "";
|
if (!account) return "";
|
||||||
return decryptData(account.deviceName, base64ToBuffer(account.seed));
|
return decryptData(account.deviceName, base64ToBuffer(account.seed));
|
||||||
|
|
@ -656,14 +656,13 @@ export function SettingsPage() {
|
||||||
await editUser(backendUrl, account, {
|
await editUser(backendUrl, account, {
|
||||||
nickname: state.nickname.state,
|
nickname: state.nickname.state,
|
||||||
});
|
});
|
||||||
// Update the account in the store
|
updateNickname(state.nickname.state);
|
||||||
const updatedAccount = { ...account, nickname: state.nickname.state };
|
|
||||||
setAccount(updatedAccount);
|
|
||||||
}
|
}
|
||||||
if (state.profile.changed) {
|
if (state.profile.changed && state.profile.state) {
|
||||||
await editUser(backendUrl, account, {
|
await editUser(backendUrl, account, {
|
||||||
profile: state.profile.state,
|
profile: state.profile.state,
|
||||||
});
|
});
|
||||||
|
updateProfile(state.profile.state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -734,7 +733,7 @@ export function SettingsPage() {
|
||||||
setProxySet,
|
setProxySet,
|
||||||
updateDeviceName,
|
updateDeviceName,
|
||||||
updateProfile,
|
updateProfile,
|
||||||
setAccount,
|
updateNickname,
|
||||||
logout,
|
logout,
|
||||||
setBackendUrl,
|
setBackendUrl,
|
||||||
setProxyTmdb,
|
setProxyTmdb,
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ interface AuthStore {
|
||||||
updateDeviceName(deviceName: string): void;
|
updateDeviceName(deviceName: string): void;
|
||||||
updateAccount(acc: Partial<Account>): void;
|
updateAccount(acc: Partial<Account>): void;
|
||||||
setAccountProfile(acc: Account["profile"]): void;
|
setAccountProfile(acc: Account["profile"]): void;
|
||||||
|
setAccountNickname(nickname: string): void;
|
||||||
setBackendUrl(url: null | string): void;
|
setBackendUrl(url: null | string): void;
|
||||||
setProxySet(urls: 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) {
|
updateAccount(acc) {
|
||||||
set((s) => {
|
set((s) => {
|
||||||
if (!s.account) return;
|
if (!s.account) return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue