Skip to content

Commit

Permalink
fileManager1API: Deduplicate windows for locations
Browse files Browse the repository at this point in the history
A single window can show a location multiple times due to tabs.
Let's deduplicate these so that the window count on the icon is
accurate.
  • Loading branch information
philipl committed Mar 21, 2018
1 parent 9b885cc commit 770feb8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fileManager1API.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ var FileManager1Client = new Lang.Class({
let ret = [];
for (let [k,v] of this._locationMap) {
if (k.startsWith(location)) {
Array.prototype.push.apply(ret, v);
for (let l of v) {
ret.push(l);
}
}
}
return ret;
Expand All @@ -98,12 +100,14 @@ var FileManager1Client = new Lang.Class({
let locations = xidToLocations[xid];
for (let i = 0; i < locations.length; i++) {
let l = locations[i];
// Use a set to deduplicate when a window has a
// location open in multiple tabs.
if (!locationToWindow.has(l)) {
locationToWindow.set(l, []);
locationToWindow.set(l, new Set());
}
let window = xidToWindow.get(parseInt(xid));
if (window != null) {
locationToWindow.get(l).push(window);
locationToWindow.get(l).add(window);
}
}
}
Expand Down

0 comments on commit 770feb8

Please sign in to comment.