Sort tabs synchronously
This commit is contained in:
parent
2d07657019
commit
ab7ccb6fb6
1 changed files with 3 additions and 8 deletions
|
@ -241,12 +241,12 @@ const backgroundLogic = {
|
||||||
const windows = await browser.windows.getAll({populate: true});
|
const windows = await browser.windows.getAll({populate: true});
|
||||||
for (let windowObj of windows) { // eslint-disable-line prefer-const
|
for (let windowObj of windows) { // eslint-disable-line prefer-const
|
||||||
// First the pinned tabs, then the normal ones.
|
// First the pinned tabs, then the normal ones.
|
||||||
await this._sortTabsInternal(windowObj, true);
|
this._sortTabsInternal(windowObj, true);
|
||||||
await this._sortTabsInternal(windowObj, false);
|
this._sortTabsInternal(windowObj, false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async _sortTabsInternal(windowObj, pinnedTabs) {
|
_sortTabsInternal(windowObj, pinnedTabs) {
|
||||||
const tabs = windowObj.tabs;
|
const tabs = windowObj.tabs;
|
||||||
const sortedTabs = [];
|
const sortedTabs = [];
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
|
@ -289,11 +289,6 @@ const backgroundLogic = {
|
||||||
if (newIndex < 0)
|
if (newIndex < 0)
|
||||||
newIndex = beforeIds.length;
|
newIndex = beforeIds.length;
|
||||||
let oldIndices = movingIds.map(id => sortedIds.indexOf(id));
|
let oldIndices = movingIds.map(id => sortedIds.indexOf(id));
|
||||||
// Reject already removed tabs.
|
|
||||||
movingIds = movingIds.filter((id, index) => oldIndices[index] > -1);
|
|
||||||
if (movingIds.length === 0)
|
|
||||||
continue;
|
|
||||||
oldIndices = oldIndices.filter(index => index > -1);
|
|
||||||
if (oldIndices[0] < newIndex)
|
if (oldIndices[0] < newIndex)
|
||||||
newIndex--;
|
newIndex--;
|
||||||
browser.tabs.move(movingIds, {
|
browser.tabs.move(movingIds, {
|
||||||
|
|
Loading…
Add table
Reference in a new issue