Skip to content

Commit

Permalink
User::rename(): don't discard the current state
Browse files Browse the repository at this point in the history
Closes #481.
  • Loading branch information
KitsuneRal committed Jul 16, 2021
1 parent 680d51c commit d85c63f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ void User::rename(const QString& newName, const Room* r)
rename(newName);
return;
}
Q_ASSERT_X(r->memberJoinState(this) == JoinState::Join, __FUNCTION__,
// #481: take the current state and update it with the new name
auto evtC = r->getCurrentState<RoomMemberEvent>(id())->content();
Q_ASSERT_X(evtC.membership == MembershipType::Join, __FUNCTION__,
"Attempt to rename a user that's not a room member");
const auto actualNewName = sanitized(newName);
MemberEventContent evtC;
evtC.displayName = actualNewName;
evtC.displayName = sanitized(newName);
r->setState<RoomMemberEvent>(id(), move(evtC));
// The state will be updated locally after it arrives with sync
}
Expand Down

0 comments on commit d85c63f

Please sign in to comment.