From 94eea332b13abad9e331dd04f2917e40086a2bd4 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 21 Feb 2019 01:10:32 +0100 Subject: Wait for account to be persisted before creating omemo_db.identity entry fixes #128 --- plugins/omemo/src/manager.vala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/omemo/src/manager.vala b/plugins/omemo/src/manager.vala index ee82b9d5..d0df6c8e 100644 --- a/plugins/omemo/src/manager.vala +++ b/plugins/omemo/src/manager.vala @@ -165,7 +165,7 @@ public class Manager : StreamInteractionModule, Object { } private void on_account_added(Account account) { - stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).store_created.connect((store) => on_store_created(account, store)); + stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).store_created.connect((store) => on_store_created.begin(account, store)); stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).device_list_loaded.connect((jid, devices) => on_device_list_loaded(account, jid, devices)); stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).bundle_fetched.connect((jid, device_id, bundle) => on_bundle_fetched(account, jid, device_id, bundle)); } @@ -302,7 +302,12 @@ public class Manager : StreamInteractionModule, Object { } } - private void on_store_created(Account account, Store store) { + private async void on_store_created(Account account, Store store) { + // If the account is not yet persisted, wait for that and then continue - without identity.account_id the entry isn't worth much. + if (account.id == -1) { + account.notify["id"].connect(() => on_store_created.callback()); + yield; + } Qlite.Row? row = db.identity.row_with(db.identity.account_id, account.id).inner; int identity_id = -1; bool publish_identity = false; -- cgit v1.2.3-54-g00ecf