After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 732905 - Restore saved channels when an account is reconnected
Restore saved channels when an account is reconnected
Status: RESOLVED FIXED
Product: polari
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Polari maintainers
Polari maintainers
Depends on:
Blocks:
 
 
Reported: 2014-07-08 16:05 UTC by Giovanni Campagna
Modified: 2014-07-17 14:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Restore saved channels when an account is reconnected (3.08 KB, patch)
2014-07-08 16:05 UTC, Giovanni Campagna
reviewed Details | Review
accountsMonitor: Make primary owner of accountManager (3.82 KB, patch)
2014-07-08 20:13 UTC, Florian Müllner
none Details | Review
accountsMonitor: Make primary owner of accountManager (3.85 KB, patch)
2014-07-17 14:28 UTC, Florian Müllner
committed Details | Review
Restore saved channels when an account is reconnected (3.27 KB, patch)
2014-07-17 14:31 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2014-07-08 16:05:21 UTC
If an account is reconnected after a transient network failure
(that is not picked up by GNetworkMonitor), rejoin all its channels,
otherwise we end up connected but outside all rooms.
Comment 1 Giovanni Campagna 2014-07-08 16:05:25 UTC
Created attachment 280168 [details] [review]
Restore saved channels when an account is reconnected
Comment 2 Florian Müllner 2014-07-08 16:28:22 UTC
Review of attachment 280168 [details] [review]:

::: src/chatroomManager.js
@@ +124,3 @@
     },
 
+    restoreSavedChannels: function(account) {

I'd prefer to keep the way channels are serialized an implementation detail, so I'd prefer a TpAccount instead of the object path here

::: src/mainWindow.js
@@ +193,3 @@
             function() {
                 app.unmark_busy();
+                ChatroomManager.getDefault().restoreSavedChannels(account.object_path);

Not a fan to be honest - restoring saved channels when a particular notification is closed looks random, e.g. what if we decide to add a close button to in-app notifications so users don't have to wait for them to be closed automatically?
Comment 3 Florian Müllner 2014-07-08 20:13:07 UTC
Created attachment 280183 [details] [review]
accountsMonitor: Make primary owner of accountManager

Currently, both ChatroomManager and AccountsMonitor take a reference
on AccountsManager, with the former setting up the required features,
so it needs to be initialized first. Instead, handle AccountManager
initialization in AccountsMonitor and port ChatroomManager to use
it, so we can start to make use of AccountsMonitor's account tracking
in the future.


So I buried up an old local patch of mine that might be useful here - the original patch had this chunk in chatroomManager.js:

+        this._accountsMonitor.connect('account-status-changed', Lang.bind(this,
+            function(mon, account) {
+                if (account.connection_status == Tp.ConnectionStatus.CONNECTED)
+                    this._restoreSavedChannels();
+            }));

I've taken it out as your approach of restoring channels for a particular account looks reasonable to me, so what do you think of rebasing your fix on top of this patch?
Comment 4 Giovanni Campagna 2014-07-17 14:19:18 UTC
Review of attachment 280183 [details] [review]:

::: src/accountsMonitor.js
@@ +42,3 @@
+            am.prepare_finish(res);
+        } catch(e) {
+            this._app.release(); // no point in carrying on

return?
Comment 5 Florian Müllner 2014-07-17 14:28:21 UTC
Created attachment 281003 [details] [review]
accountsMonitor: Make primary owner of accountManager

Yeah, makes sense to me ...
Comment 6 Giovanni Campagna 2014-07-17 14:31:26 UTC
Created attachment 281004 [details] [review]
Restore saved channels when an account is reconnected

If an account is reconnected after a transient network failure
(that is not picked up by GNetworkMonitor), rejoin all its channels,
otherwise we end up connected but outside all rooms.

And this is the rebased version.
Comment 7 Florian Müllner 2014-07-17 14:43:30 UTC
Review of attachment 281004 [details] [review]:

::: src/chatroomManager.js
@@ +106,3 @@
 
+    _onAccountEnabled: function(am, account) {
+        this._restoreSavedChannels(account.object_path);

You need to pass the account, not its object path

::: src/mainWindow.js
@@ +193,3 @@
             function() {
                 app.unmark_busy();
+                delete account._connectingNotification;

This drive-by fix is a bit odd now that you don't touch any actual code here - can you push this separately please?
Comment 8 Florian Müllner 2014-07-17 14:44:57 UTC
Comment on attachment 281003 [details] [review]
accountsMonitor: Make primary owner of accountManager

Attachment 281003 [details] pushed as 5bfc81c - accountsMonitor: Make primary owner of accountManager
Comment 9 Giovanni Campagna 2014-07-17 14:48:37 UTC
Pushed with the noted fixes.

Attachment 281004 [details] pushed as d490384 - Restore saved channels when an account is reconnected