diff --git a/app/browser/windows.js b/app/browser/windows.js index 62f0e3b52ba..c807c986c50 100644 --- a/app/browser/windows.js +++ b/app/browser/windows.js @@ -109,7 +109,8 @@ const updatePinnedTabs = (win, appState) => { // sites are instructions of what should be pinned // tabs are sites our window already has pinned // for each site which should be pinned, find if it's already pinned - for (const site of statePinnedSites.values()) { + const statePinnedSitesOrdered = statePinnedSites.sort((a, b) => a.get('order') - b.get('order')) + for (const site of statePinnedSitesOrdered.values()) { const existingPinnedTabIdx = pinnedWindowTabs.findIndex(tab => siteMatchesTab(site, tab)) if (existingPinnedTabIdx !== -1) { // if it's already pinned we don't need to consider the tab in further searches diff --git a/app/common/state/pinnedSitesState.js b/app/common/state/pinnedSitesState.js index 0fd0285fdfc..2630d00c56f 100644 --- a/app/common/state/pinnedSitesState.js +++ b/app/common/state/pinnedSitesState.js @@ -59,6 +59,10 @@ const pinnedSiteState = { return state } + if (state.hasIn([STATE_SITES.PINNED_SITES, key])) { + return state + } + state = state.setIn([STATE_SITES.PINNED_SITES, key], site) return state }, diff --git a/app/sessionStore.js b/app/sessionStore.js index 57fb0f68f94..3917a56ff81 100644 --- a/app/sessionStore.js +++ b/app/sessionStore.js @@ -676,7 +676,9 @@ module.exports.runPreMigrations = (data) => { const site = data.sites[key] if (site.tags && site.tags.includes('pinned')) { delete site.tags - data.pinnedSites[key] = site + // matches `getKey` from pinnedSitesUtil + const pinnedSiteKey = `${site.location}|${site.partitionNumber}` + data.pinnedSites[pinnedSiteKey] = site } } diff --git a/test/unit/app/sessionStoreTest.js b/test/unit/app/sessionStoreTest.js index 2831cce6c9a..347be270666 100644 --- a/test/unit/app/sessionStoreTest.js +++ b/test/unit/app/sessionStoreTest.js @@ -1540,7 +1540,7 @@ describe('sessionStore unit tests', function () { before(function () { oldValue = data.getIn(['sites', 'https://pinned-tab.com|0|0']) - newValue = runPreMigrations.pinnedSites['https://pinned-tab.com|0|0'] + newValue = runPreMigrations.pinnedSites['https://pinned-tab.com|0'] }) it('copies lastAccessedTime', function () {