[polari] Wait until activated to restore channels
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] Wait until activated to restore channels
- Date: Thu, 5 Mar 2015 09:24:08 +0000 (UTC)
commit 8f8c6857c9b7676582eb9ebe84328494702b7e32
Author: Giovanni Campagna <scampa giovanni gmail com>
Date: Mon Mar 2 23:42:12 2015 -0800
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
src/accountsMonitor.js | 4 ++++
src/application.js | 2 ++
src/chatroomManager.js | 12 ++++++++++++
3 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index d9bf63c..b692d1a 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -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);
diff --git a/src/application.js b/src/application.js
index b5425f5..209183b 100644
--- a/src/application.js
+++ b/src/application.js
@@ -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();
},
diff --git a/src/chatroomManager.js b/src/chatroomManager.js
index 3190e1d..6ec3b95 100644
--- a/src/chatroomManager.js
+++ b/src/chatroomManager.js
@@ -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',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]