mirror of
https://github.com/chatmail/core.git
synced 2026-05-06 06:46:35 +03:00
use tri-state ImageAction instead of Option<Option>
This commit is contained in:
committed by
holger krekel
parent
c62532a665
commit
c3fd0889e2
@@ -15,6 +15,7 @@ use crate::events::Event;
|
||||
use crate::key::*;
|
||||
use crate::login_param::LoginParam;
|
||||
use crate::message::{MessageState, MsgId};
|
||||
use crate::mimeparser::ImageAction;
|
||||
use crate::param::*;
|
||||
use crate::peerstate::*;
|
||||
use crate::sql;
|
||||
@@ -965,17 +966,26 @@ fn set_block_contact(context: &Context, contact_id: u32, new_blocking: bool) {
|
||||
pub fn set_profile_image(
|
||||
context: &Context,
|
||||
contact_id: u32,
|
||||
profile_image: Option<String>,
|
||||
profile_image: ImageAction,
|
||||
) -> Result<()> {
|
||||
// the given profile image is expected to be already in the blob directory
|
||||
// as profile images can be set only by receiving messages, this should be always the case, however.
|
||||
let mut contact = Contact::load_from_db(context, contact_id)?;
|
||||
match profile_image {
|
||||
Some(profile_image) => contact.param.set(Param::ProfileImage, profile_image),
|
||||
None => contact.param.remove(Param::ProfileImage),
|
||||
let changed = match profile_image {
|
||||
ImageAction::Change(profile_image) => {
|
||||
contact.param.set(Param::ProfileImage, profile_image);
|
||||
true
|
||||
}
|
||||
ImageAction::Delete => {
|
||||
contact.param.remove(Param::ProfileImage);
|
||||
true
|
||||
}
|
||||
ImageAction::None => false,
|
||||
};
|
||||
contact.update_param(context)?;
|
||||
context.call_cb(Event::ContactsChanged(Some(contact_id)));
|
||||
if changed {
|
||||
contact.update_param(context)?;
|
||||
context.call_cb(Event::ContactsChanged(Some(contact_id)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user