Skip to content

Commit

Permalink
session_manager: Handle telegram chat links opening
Browse files Browse the repository at this point in the history
  • Loading branch information
krlade committed Nov 3, 2022
1 parent 520544d commit 9cc8459
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/session_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,28 @@ impl SessionManager {
}
}

pub(crate) fn handle_deeplink(&self, url: String) {
let client_id = self.active_logged_in_client_id();
if let Some(client_id) = client_id {
let username = url
.replace("tg://", "")
.replace("resolve?domain=", "")
.split('&')
.next()
.unwrap()
.to_owned();

//TODO: Open chat at given message_id
spawn(clone!(@weak self as obj => async move {
let result = functions::search_public_chat(username, client_id).await;
if let Ok(chat) = result {
let enums::Chat::Chat(chat) = chat;
obj.select_chat(client_id, chat.id);
}
}));
}
}

pub(crate) fn begin_chats_search(&self) {
if let Some(client_id) = self.active_logged_in_client_id() {
let clients = self.imp().clients.borrow();
Expand Down

0 comments on commit 9cc8459

Please sign in to comment.