Commit 8f8c6857 authored by Giovanni Campagna's avatar Giovanni Campagna

Wait until activated to restore channels

1) We don't want to restore channels when dbus started, if the
   app is not activated
2) Most importantly, we need an existing window or _ensureRoom fails
   misteriously.
   Previously this would work because it would do:
   startup -> activate -> mainloop -> account manager prepared
   -> ensureRoom -> (-> handle channels -> ensureRoom)
   but in the mission control activation the flow is
   startup -> mainloop -> account manager prepared -> handle channels ->
   ensureRoom -> activate

   We need the second ensureRoom to be effective, and to do so we
   must avoid an ineffective ensureRoom before we handle the channels.

https://bugzilla.gnome.org/show_bug.cgi?id=745499
parent 0b27b134
......@@ -37,6 +37,10 @@ const AccountsMonitor = new Lang.Class({
return this._accounts.slice();
},
get accountManager() {
return this._accountManager;
},
_onPrepared: function(am, res) {
try {
am.prepare_finish(res);
......
......@@ -137,6 +137,8 @@ const Application = new Lang.Class({
this.emitJS('prepare-shutdown');
}));
this._window.window.show_all();
this._chatroomManager.lateInit();
}
this._window.window.present();
},
......
......@@ -52,6 +52,7 @@ const _ChatroomManager = new Lang.Class({
this._accountsMonitor = AccountsMonitor.getDefault();
this._accountsMonitor.connect('account-manager-prepared',
Lang.bind(this, this._onPrepared));
this._amIsPrepared = false;
},
_onPrepared: function(mon, am) {
......@@ -85,6 +86,17 @@ const _ChatroomManager = new Lang.Class({
}));
this._client.register();
this._amIsPrepared = true;
this.lateInit();
},
lateInit: function() {
let am = this._accountsMonitor.accountManager;
let ready = this._amIsPrepared &&
this._app.get_active_window() != null;
if (!ready)
return;
am.connect('account-enabled',
Lang.bind(this, this._onAccountEnabled));
am.connect('account-disabled',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment