Skip to content

Commit

Permalink
fix: use setUser instead of updating probableUser directly
Browse files Browse the repository at this point in the history
  • Loading branch information
amk-dev committed Mar 25, 2024
1 parent e35075e commit a613e85
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,16 @@ export const def: AuthPlatformDef = {

async setDisplayName(name: string) {
if (!name) return E.left("USER_NAME_CANNOT_BE_EMPTY")
if (!currentUser$.value) return E.left("NO_USER_LOGGED_IN")

const res = await updateUserDisplayName(name)

if (E.isRight(res)) {
probableUser$.next({
...probableUser$.value,
displayName: res.right.updateDisplayName.displayName,
} as HoppUser)
setUser({
...currentUser$.value,
displayName: res.right.updateDisplayName.displayName ?? null,
})

return E.right(undefined)
}
return E.left(res.left)
Expand Down

0 comments on commit a613e85

Please sign in to comment.