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



commit 025ad7f18a0054bcdd117434b06cbfd0f356cf50
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 7f254f9..193cb2d 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]