Fix update avatar
This commit is contained in:
parent
980d263c87
commit
9ba3f112e6
@ -39,6 +39,12 @@ pub fn update(msg: Msg, model: &mut crate::model::Model, orders: &mut impl Order
|
||||
.unwrap_or_default()
|
||||
.into();
|
||||
}
|
||||
Msg::ResourceChanged(ResourceKind::User, OperationKind::SingleModified, Some(id)) => {
|
||||
profile_page.avatar.url = model
|
||||
.users_by_id
|
||||
.get(&id)
|
||||
.and_then(|u| u.avatar_url.clone());
|
||||
}
|
||||
Msg::FileInputChanged(FieldId::Profile(UsersFieldId::Avatar), ..) => {
|
||||
let file = match profile_page.avatar.file.as_ref() {
|
||||
Some(f) => f,
|
||||
|
@ -169,6 +169,22 @@ pub fn update(msg: WsMsg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
));
|
||||
}
|
||||
// user settings
|
||||
WsMsg::User(WsMsgUser::AvatarUrlChanged(id, url)) => {
|
||||
if let Some(user) = model.user.as_mut().filter(|u| u.id == id) {
|
||||
user.avatar_url = Some(url.clone());
|
||||
}
|
||||
if let Some(user) = model.users_by_id.get_mut(&id) {
|
||||
user.avatar_url = Some(url.clone());
|
||||
}
|
||||
if let Some(user) = model.users.iter_mut().find(|u| u.id == id) {
|
||||
user.avatar_url = Some(url);
|
||||
}
|
||||
orders.send_msg(Msg::ResourceChanged(
|
||||
ResourceKind::User,
|
||||
OperationKind::SingleModified,
|
||||
Some(id),
|
||||
));
|
||||
}
|
||||
WsMsg::User(WsMsgUser::UserSettingUpdated(setting)) => {
|
||||
model.user_settings = Some(setting);
|
||||
orders.send_msg(Msg::ResourceChanged(
|
||||
@ -334,23 +350,6 @@ pub fn update(msg: WsMsg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
Some(comment_id),
|
||||
));
|
||||
}
|
||||
WsMsg::User(WsMsgUser::AvatarUrlChanged(user_id, avatar_url)) => {
|
||||
for user in model.users.iter_mut() {
|
||||
if user.id == user_id {
|
||||
user.avatar_url = Some(avatar_url.clone());
|
||||
}
|
||||
}
|
||||
if let Some(me) = model.user.as_mut() {
|
||||
if me.id == user_id {
|
||||
me.avatar_url = Some(avatar_url);
|
||||
}
|
||||
}
|
||||
orders.send_msg(Msg::ResourceChanged(
|
||||
ResourceKind::User,
|
||||
OperationKind::SingleModified,
|
||||
Some(user_id),
|
||||
));
|
||||
}
|
||||
// messages
|
||||
WsMsg::Message(WsMsgMessage::MessageUpdated(mut received)) => {
|
||||
if let Some(idx) = model.messages.iter().position(|m| m.id == received.id) {
|
||||
|
Loading…
Reference in New Issue
Block a user