[polari] joindialog: Default to account of the currently selected room
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] joindialog: Default to account of the currently selected room
- Date: Wed, 7 Oct 2015 20:44:49 +0000 (UTC)
commit 677829cb8952e103826be5f9202b273b5ca18e6d
Author: Kunaal Jain <kunaalus gmail com>
Date: Thu Oct 8 00:44:58 2015 +0530
joindialog: Default to account of the currently selected room
When joining a new room or messaging a new user, it is more logical
and intuitive to default to the account of the currently active room
rather than selecting the account that was last used in the join-room
or message-user dialog as we currently do.
https://bugzilla.gnome.org/show_bug.cgi?id=755771
data/org.gnome.Polari.gschema.xml | 3 ---
src/joinDialog.js | 12 +++++-------
src/messageDialog.js | 13 ++++++-------
3 files changed, 11 insertions(+), 17 deletions(-)
---
diff --git a/data/org.gnome.Polari.gschema.xml b/data/org.gnome.Polari.gschema.xml
index edf75af..0704c1e 100644
--- a/data/org.gnome.Polari.gschema.xml
+++ b/data/org.gnome.Polari.gschema.xml
@@ -6,9 +6,6 @@
<summary>Saved channel list</summary>
<description>List of channels to restore on startup</description>
</key>
- <key type="s" name="last-used-account">
- <default>''</default>
- </key>
<key type="ai" name="window-size">
<default>[800,500]</default>
<summary>Window size</summary>
diff --git a/src/joinDialog.js b/src/joinDialog.js
index 5b26ec0..e07c1b2 100644
--- a/src/joinDialog.js
+++ b/src/joinDialog.js
@@ -5,6 +5,7 @@ const Tp = imports.gi.TelepathyGLib;
const Tpl = imports.gi.TelepathyLogger;
const AccountsMonitor = imports.accountsMonitor;
+const ChatroomManager = imports.chatroomManager;
const Connections = imports.connections;
const Lang = imports.lang;
const Utils = imports.utils;
@@ -23,6 +24,7 @@ const JoinDialog = new Lang.Class({
this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' });
this._accountsMonitor = AccountsMonitor.getDefault();
+ this._roomManager = ChatroomManager.getDefault();
this._accounts = {};
this._accountsMonitor.dupAccounts().forEach(Lang.bind(this,
@@ -149,9 +151,6 @@ const JoinDialog = new Lang.Class({
let selected = this._connectionCombo.get_active_text();
let account = this._accounts[selected];
- this._settings.set_string('last-used-account',
- account.get_object_path());
-
let room = this._nameEntry.get_text();
if (room[0] != '#')
room = '#' + room;
@@ -176,11 +175,10 @@ const JoinDialog = new Lang.Class({
this._connectionCombo.append_text(names[i]);
this._connectionCombo.sensitive = names.length > 1;
- let factory = Tp.AccountManager.dup().get_factory();
- let lastUsed = factory.ensure_account(this._settings.get_string('last-used-account'), []);
+ let activeRoom = this._roomManager.getActiveRoom();
let activeIndex = 0;
- if (lastUsed)
- activeIndex = Math.max(names.indexOf(lastUsed.display_name), 0);
+ if(activeRoom)
+ activeIndex = Math.max(names.indexOf(activeRoom.account.display_name), 0);
this._connectionCombo.set_active(activeIndex);
},
diff --git a/src/messageDialog.js b/src/messageDialog.js
index 9f49065..9b974b4 100644
--- a/src/messageDialog.js
+++ b/src/messageDialog.js
@@ -5,6 +5,7 @@ const Tp = imports.gi.TelepathyGLib;
const Tpl = imports.gi.TelepathyLogger;
const AccountsMonitor = imports.accountsMonitor;
+const ChatroomManager = imports.chatroomManager;
const Lang = imports.lang;
const Utils = imports.utils;
@@ -19,6 +20,8 @@ const MessageDialog = new Lang.Class({
this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' });
this._accounts = {};
+ this._roomManager = ChatroomManager.getDefault();
+
AccountsMonitor.getDefault().dupAccounts().forEach(Lang.bind(this,
function(a) {
if (!a.enabled)
@@ -34,11 +37,10 @@ const MessageDialog = new Lang.Class({
this._connectionCombo.append_text(names[i]);
this._connectionCombo.sensitive = names.length > 1;
- let factory = Tp.AccountManager.dup().get_factory();
- let lastUsed = factory.ensure_account(this._settings.get_string('last-used-account'), []);
+ let activeRoom = this._roomManager.getActiveRoom();
let activeIndex = 0;
- if (lastUsed)
- activeIndex = Math.max(names.indexOf(lastUsed.display_name), 0);
+ if(activeRoom)
+ activeIndex = Math.max(names.indexOf(activeRoom.account.display_name), 0);
this._connectionCombo.set_active(activeIndex);
this._updateCanConfirm();
@@ -167,9 +169,6 @@ const MessageDialog = new Lang.Class({
let selected = this._connectionCombo.get_active_text();
let account = this._accounts[selected];
- this._settings.set_string('last-used-account',
- account.get_object_path());
-
let user = this._nameEntry.get_text();
let app = Gio.Application.get_default();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]