mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 13:26:38 +03:00
rename me-chat to saved-messages, use an appropriate icon
This commit is contained in:
committed by
holger krekel
parent
a4a1cd42db
commit
f9d2fe710d
BIN
assets/icon-saved-messages.png
Normal file
BIN
assets/icon-saved-messages.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
20
src/chat.rs
20
src/chat.rs
@@ -100,7 +100,7 @@ impl Chat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if chat.param.exists(Param::Selftalk) {
|
if chat.param.exists(Param::Selftalk) {
|
||||||
chat.name = context.stock_str(StockMessage::SelfMsg).into();
|
chat.name = context.stock_str(StockMessage::SavedMessages).into();
|
||||||
} else if chat.param.exists(Param::Devicetalk) {
|
} else if chat.param.exists(Param::Devicetalk) {
|
||||||
chat.name = context.stock_str(StockMessage::DeviceMessages).into();
|
chat.name = context.stock_str(StockMessage::DeviceMessages).into();
|
||||||
}
|
}
|
||||||
@@ -603,6 +603,20 @@ fn copy_device_icon_to_blobs(context: &Context) -> Result<String, Error> {
|
|||||||
Ok(blob.as_name().to_string())
|
Ok(blob.as_name().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update_saved_messages_icon(context: &Context) -> Result<(), Error> {
|
||||||
|
// if there is no saved-messages chat, there is nothing to update. this is no error.
|
||||||
|
if let Ok((chat_id, _)) = lookup_by_contact_id(context, DC_CONTACT_ID_SELF) {
|
||||||
|
let icon = include_bytes!("../assets/icon-saved-messages.png");
|
||||||
|
let blob = BlobObject::create(context, "icon-saved-messages.png".to_string(), icon)?;
|
||||||
|
let icon = blob.as_name().to_string();
|
||||||
|
|
||||||
|
let mut chat = Chat::load_from_db(context, chat_id)?;
|
||||||
|
chat.param.set(Param::ProfileImage, icon);
|
||||||
|
chat.update_param(context)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn create_or_lookup_by_contact_id(
|
pub fn create_or_lookup_by_contact_id(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
contact_id: u32,
|
contact_id: u32,
|
||||||
@@ -652,6 +666,10 @@ pub fn create_or_lookup_by_contact_id(
|
|||||||
params![],
|
params![],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
if contact_id == DC_CONTACT_ID_SELF {
|
||||||
|
update_saved_messages_icon(context)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok((chat_id, create_blocked))
|
Ok((chat_id, create_blocked))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
src/sql.rs
10
src/sql.rs
@@ -7,6 +7,7 @@ use std::time::Duration;
|
|||||||
use rusqlite::{Connection, OpenFlags, Statement, NO_PARAMS};
|
use rusqlite::{Connection, OpenFlags, Statement, NO_PARAMS};
|
||||||
use thread_local_object::ThreadLocal;
|
use thread_local_object::ThreadLocal;
|
||||||
|
|
||||||
|
use crate::chat::update_saved_messages_icon;
|
||||||
use crate::constants::ShowEmails;
|
use crate::constants::ShowEmails;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
@@ -495,6 +496,7 @@ fn open(
|
|||||||
let mut dbversion = dbversion_before_update;
|
let mut dbversion = dbversion_before_update;
|
||||||
let mut recalc_fingerprints = 0;
|
let mut recalc_fingerprints = 0;
|
||||||
let mut update_file_paths = 0;
|
let mut update_file_paths = 0;
|
||||||
|
let mut update_icons = false;
|
||||||
|
|
||||||
if dbversion < 1 {
|
if dbversion < 1 {
|
||||||
info!(context, "[migration] v1");
|
info!(context, "[migration] v1");
|
||||||
@@ -822,6 +824,11 @@ fn open(
|
|||||||
}
|
}
|
||||||
sql.set_raw_config_int(context, "dbversion", 57)?;
|
sql.set_raw_config_int(context, "dbversion", 57)?;
|
||||||
}
|
}
|
||||||
|
if dbversion < 58 {
|
||||||
|
info!(context, "[migration] v58");
|
||||||
|
update_icons = true;
|
||||||
|
sql.set_raw_config_int(context, "dbversion", 58)?;
|
||||||
|
}
|
||||||
|
|
||||||
// (2) updates that require high-level objects
|
// (2) updates that require high-level objects
|
||||||
// (the structure is complete now and all objects are usable)
|
// (the structure is complete now and all objects are usable)
|
||||||
@@ -873,6 +880,9 @@ fn open(
|
|||||||
|
|
||||||
sql.set_raw_config(context, "backup_for", None)?;
|
sql.set_raw_config(context, "backup_for", None)?;
|
||||||
}
|
}
|
||||||
|
if update_icons {
|
||||||
|
update_saved_messages_icon(context)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info!(context, "Opened {:?}.", dbfile.as_ref(),);
|
info!(context, "Opened {:?}.", dbfile.as_ref(),);
|
||||||
|
|||||||
@@ -112,8 +112,10 @@ pub enum StockMessage {
|
|||||||
Location = 66,
|
Location = 66,
|
||||||
#[strum(props(fallback = "Sticker"))]
|
#[strum(props(fallback = "Sticker"))]
|
||||||
Sticker = 67,
|
Sticker = 67,
|
||||||
#[strum(props(fallback = "Device Messages"))]
|
#[strum(props(fallback = "Device messages"))]
|
||||||
DeviceMessages = 68,
|
DeviceMessages = 68,
|
||||||
|
#[strum(props(fallback = "Saved messages"))]
|
||||||
|
SavedMessages = 69,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StockMessage {
|
impl StockMessage {
|
||||||
|
|||||||
Reference in New Issue
Block a user