[gnome-documents] search: fix logic adding account identity to provider name
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] search: fix logic adding account identity to provider name
- Date: Tue, 4 Apr 2017 16:22:31 +0000 (UTC)
commit 0068808c1a086efb36db1346ad59bc250f982d00
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Apr 4 09:21:27 2017 -0700
search: fix logic adding account identity to provider name
We were always adding it for all sources, instead of doing it only when
there's more than one with the same name.
https://bugzilla.gnome.org/show_bug.cgi?id=769088
src/search.js | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/src/search.js b/src/search.js
index c60ff4e..0ee5a0f 100644
--- a/src/search.js
+++ b/src/search.js
@@ -473,7 +473,7 @@ const SourceManager = new Lang.Class({
_refreshGoaAccounts: function() {
let newItems = {};
- let newSources = [];
+ let newSources = new Map();
let accounts = Application.goaClient.get_accounts();
accounts.forEach(Lang.bind(this,
@@ -486,22 +486,28 @@ const SourceManager = new Lang.Class({
let source = new Source({ object: object });
- newSources.push(source);
+ let otherSources = newSources.get(source.name);
+ if (!otherSources)
+ otherSources = [];
+
+ otherSources.push(source);
+ newSources.set(source.name, otherSources);
newItems[source.id] = source;
}));
// Ensure an unique name for GOA accounts from the same provider
- newSources.forEach(function(source) {
- if (newSources.some(function(s) {
- return s.name == source.name;
- })) {
+ newSources.forEach(function(sources, name) {
+ if (sources.length == 1)
+ return;
+
+ sources.forEach(function(source) {
let account = source.object.get_account();
// Translators: the first %s is an online account provider name,
// e.g. "Google". The second %s is the identity used to log in,
// e.g. "foo gmail com".
source.name = _("%s (%s)").format(account.provider_name,
account.presentation_identity);
- }
+ });
});
this.processNewItems(newItems);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]