[polari/wip/fmuellner/misc-fixes: 16/16] app: Ensure we are prepared before handling join-room/message-user



commit e4bcde11b02c0f02063dfeaa36e253bd71380ef8
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Jul 30 23:01:31 2016 +0200

    app: Ensure we are prepared before handling join-room/message-user
    
    We are not prepared to handle the join-room/message-user actions before
    the account manager is prepared, so run the handling through the account
    monitor's prepare() method.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769592

 src/application.js |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 6d490d6..ffce823 100644
--- a/src/application.js
+++ b/src/application.js
@@ -470,19 +470,24 @@ const Application = new Lang.Class({
 
     _onJoinRoom: function(action, parameter) {
         let [accountPath, channelName, time] = parameter.deep_unpack();
-        let account = this._accountsMonitor.lookupAccount(accountPath);
-        if (!account)
-            return;
 
-        this._requestChannel(accountPath, Tp.HandleType.ROOM,
-                             channelName, time);
-        this._addSavedChannel(account, channelName);
+        this._accountsMonitor.prepare(() => {
+            let account = this._accountsMonitor.lookupAccount(accountPath);
+            if (!account)
+                return;
+
+            this._requestChannel(accountPath, Tp.HandleType.ROOM,
+                                 channelName, time);
+            this._addSavedChannel(account, channelName);
+        });
     },
 
     _onMessageUser: function(action, parameter) {
         let [accountPath, contactName, message, time] = parameter.deep_unpack();
-        this._requestChannel(accountPath, Tp.HandleType.CONTACT,
-                             contactName, time, Lang.bind(this, this._sendMessage, message));
+        this._accountsMonitor.prepare(() => {
+            this._requestChannel(accountPath, Tp.HandleType.CONTACT,
+                                 contactName, time, Lang.bind(this, this._sendMessage, message));
+        });
     },
 
     _sendMessage: function(channel, message) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]