omemo keyring
This commit is contained in:
+12
-5
@@ -23,6 +23,15 @@ fn item_id(jid: &str) -> String {
|
||||
format!("#{}", utils::cleanup_id(&format!("{}_chat_item", utils::slugify(jid))))
|
||||
}
|
||||
|
||||
/// Put the item of a discussion on top of the list. The html is prepared before
|
||||
/// touching the list: with an await between the remove and the prepend, two
|
||||
/// concurrent calls (a message during a reload) left two items for one contact.
|
||||
async fn put_on_top(ctx: &Ctx, jid: &str) {
|
||||
let html = prepare_chat(ctx, jid).await;
|
||||
rpc!(ctx, "MovimTpl.remove", item_id(jid));
|
||||
rpc!(ctx, "MovimTpl.prepend", "#chats", html);
|
||||
}
|
||||
|
||||
pub async fn call(ctx: &Ctx, func: &str, p: &P<'_>) -> bool {
|
||||
match func {
|
||||
"ajaxHttpGet" => {
|
||||
@@ -138,7 +147,7 @@ pub async fn chat_open(ctx: &Ctx, jid: &str) {
|
||||
let me = ctx.jid();
|
||||
if !db::open_chat_exists(ctx.db(), &me, jid).await.unwrap_or(false) {
|
||||
let _ = db::open_chat_touch(ctx.db(), &me, jid, None).await;
|
||||
rpc!(ctx, "MovimTpl.prepend", "#chats", prepare_chat(ctx, jid).await);
|
||||
put_on_top(ctx, jid).await;
|
||||
} else {
|
||||
rpc!(ctx, "MovimTpl.replace", item_id(jid), prepare_chat(ctx, jid).await);
|
||||
}
|
||||
@@ -170,8 +179,7 @@ pub async fn open(ctx: &Ctx, jid: &str, and_show: bool, history: bool) {
|
||||
});
|
||||
}
|
||||
let _ = db::open_chat_touch(ctx.db(), &me, jid, None).await;
|
||||
rpc!(ctx, "MovimTpl.remove", item_id(jid));
|
||||
rpc!(ctx, "MovimTpl.prepend", "#chats", prepare_chat(ctx, jid).await);
|
||||
put_on_top(ctx, jid).await;
|
||||
rpc!(ctx, "Chats.refresh");
|
||||
if notif::is_current(ctx, jid) || and_show {
|
||||
rpc!(ctx, "Chats.setActive", jid);
|
||||
@@ -209,8 +217,7 @@ pub async fn on_message(ctx: &Ctx, m: &db::Message, origin: &Origin) {
|
||||
return;
|
||||
}
|
||||
let _ = db::open_chat_touch(ctx.db(), &me, &jid, Some(&m.published)).await;
|
||||
rpc!(ctx, "MovimTpl.remove", item_id(&jid));
|
||||
rpc!(ctx, "MovimTpl.prepend", "#chats", prepare_chat(ctx, &jid).await);
|
||||
put_on_top(ctx, &jid).await;
|
||||
rpc!(ctx, "Chats.refresh");
|
||||
if notif::is_current(ctx, &jid) {
|
||||
rpc!(ctx, "Chats.setActive", jid.clone());
|
||||
|
||||
Reference in New Issue
Block a user