Fix secret chats being duplicated on login

This commit is contained in:
mjentsch 2015-11-16 16:15:20 +01:00
parent 85df0e0bcd
commit b721e8d217

View file

@ -555,10 +555,16 @@ static GList* tgprpl_blist_node_menu (PurpleBlistNode *node) {
static void update_on_logged_in (struct tgl_state *TLS) {
info ("update_on_logged_in(): The account is signed in");
debug ("state: seq = %d, pts = %d, date = %d", TLS->seq, TLS->pts, TLS->date);
write_auth_file (TLS);
debug ("state: seq = %d, pts = %d, date = %d", TLS->seq, TLS->pts, TLS->date);
purple_connection_set_state (tg_get_conn (TLS), PURPLE_CONNECTED);
purple_blist_add_account (tg_get_acc (TLS));
// It is important to load secret chats exactly at this point during login, cause if it was done earlier,
// the update function wouldn't find existing chats and create duplicate entries. If it was done later, eventual
// updates for those secret chats wouldn't be able to be decrypted due to missing secret keys.
read_secret_chat_file (TLS);
}
static void update_on_ready (struct tgl_state *TLS) {
@ -639,10 +645,8 @@ static void tgprpl_login (PurpleAccount * acct) {
read_auth_file (TLS);
read_state_file (TLS);
read_secret_chat_file (TLS);
purple_connection_set_state (conn->gc, PURPLE_CONNECTING);
tgl_login (TLS);
}