Reapply "fix(user): refresh profile on sidebar open"
This reverts commit f4d0f76466.
This commit is contained in:
@@ -103,11 +103,10 @@ describe("userMachine", () => {
|
||||
actor.stop();
|
||||
});
|
||||
|
||||
it("updates user profile fields synchronously", () => {
|
||||
it("updates user profile synchronously", () => {
|
||||
const actor = createActor(createTestUserMachine()).start();
|
||||
|
||||
actor.send({ type: "UserUpdate", user: makeUser({ username: "Before" }) });
|
||||
actor.send({ type: "UserUpdateUsername", username: "After" });
|
||||
actor.send({ type: "UserUpdate", user: makeUser({ username: "After" }) });
|
||||
|
||||
expect(actor.getSnapshot().context.currentUser?.username).toBe("After");
|
||||
|
||||
|
||||
@@ -7,8 +7,5 @@ export type UserEvent =
|
||||
| { type: "UserInit" }
|
||||
| { type: "UserFetch" }
|
||||
| { type: "UserUpdate"; user: UserView }
|
||||
| { type: "UserUpdateUsername"; username: string }
|
||||
| { type: "UserClearLocal" }
|
||||
| { type: "UserLogout" }
|
||||
| { type: "UserDeleteChatHistory" }
|
||||
| { type: "UserDeleteAccount" };
|
||||
| { type: "UserLogout" };
|
||||
|
||||
@@ -40,13 +40,6 @@ export const userMachine = setup({
|
||||
};
|
||||
}),
|
||||
|
||||
updateUsername: assign(({ context, event }) => {
|
||||
if (event.type !== "UserUpdateUsername" || !context.currentUser) return {};
|
||||
return {
|
||||
currentUser: { ...context.currentUser, username: event.username },
|
||||
};
|
||||
}),
|
||||
|
||||
clearUser: assign(() => ({
|
||||
currentUser: null,
|
||||
avatarUrl: null,
|
||||
@@ -66,15 +59,10 @@ export const userMachine = setup({
|
||||
UserUpdate: {
|
||||
actions: "updateUser",
|
||||
},
|
||||
UserUpdateUsername: {
|
||||
actions: "updateUsername",
|
||||
},
|
||||
UserClearLocal: {
|
||||
actions: "clearUser",
|
||||
},
|
||||
UserLogout: "loggingOut",
|
||||
UserDeleteChatHistory: {},
|
||||
UserDeleteAccount: {},
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user