[polari/wip/raresv/GSoC: 8/17] userDetails: add offline support
- From: Rares Visalom <raresvisalom src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/raresv/GSoC: 8/17] userDetails: add offline support
- Date: Mon, 22 Aug 2016 19:33:13 +0000 (UTC)
commit 080d9b16f5db1bb592d4a1d99ff73a236635c339
Author: raresv <rares visalom gmail com>
Date: Sun Aug 21 14:49:12 2016 +0300
userDetails: add offline support
We want to be able to use the UserDetails class both when the
user is offline and online. The offline functionality of the
UserDetails class will be visible just in the UserPopover,
as there are no offline users displayed in the UserList. We
know which case we are in by the presence of the _user variable.
We also need to update the messageButton visibility. The _user
param is not passed at construction time, but is initialized
through a setter.
src/userList.js | 40 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/src/userList.js b/src/userList.js
index baa11f6..c4136af 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -128,6 +128,27 @@ const UserDetails = new Lang.Class({
this._detailsGrid.hide();
},
+ set user(user) {
+ if (this._user == user)
+ return;
+
+ if (this._user)
+ this._user.connection.disconnect(this._selfContactChangedId);
+ this._selfContactChangedId = 0;
+
+ this._user = user;
+
+ if (this._user)
+ this._selfContactChangedId = this._user.connection.connect('notify::self-contact',
+ Lang.bind(this, this._updateButtonVisibility));
+
+ if (this.expanded)
+ this._expand();
+
+ this._updateButtonVisibility();
+ this._lastLabel.visible = this._user != null;
+ },
+
set nickname(nickname) {
this._nickname = nickname;
@@ -166,6 +187,9 @@ const UserDetails = new Lang.Class({
if (this._user)
this._user.request_contact_info_async(this._cancellable,
Lang.bind(this, this._onContactInfoReady));
+ //TODO: else use this._nickname to query tracker
+ else
+ this._revealDetails();
},
_unexpand: function() {
@@ -230,6 +254,10 @@ const UserDetails = new Lang.Class({
this._lastLabel.hide();
}
+ this._revealDetails();
+ },
+
+ _revealDetails: function() {
this._spinner.stop();
this._spinnerBox.hide();
this._detailsGrid.show();
@@ -249,7 +277,13 @@ const UserDetails = new Lang.Class({
},
_updateButtonVisibility: function() {
- if (!this._user || this._user == this._user.connection.self_contact) {
+ if (!this._user) {
+ this._messageButton.sensitive = false;
+
+ return;
+ }
+
+ if (this._user == this._user.connection.self_contact) {
this._messageButton.visible = false;
this._messageButton.sensitive = true;
} else {
@@ -322,7 +356,9 @@ const UserListRow = new Lang.Class({
if (this._revealer.get_child())
return;
- let details = new UserListDetails({ user: this._user })
+ let details = new UserDetails();
+ details.user = this._user;
+
this._revealer.bind_property('reveal-child', details, 'expanded', 0);
this._revealer.add(details);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]