Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Fix issue with lost tabs ordering on relaunch #8589

Merged
merged 1 commit into from
May 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions app/browser/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const debounce = require('../../js/lib/debounce')
const {getSetting} = require('../../js/settings')
const locale = require('../locale')
const LocalShortcuts = require('../localShortcuts')
const {getSiteProps} = require('../common/lib/windowsUtil')
const {makeImmutable} = require('../common/state/immutableUtil')
const {getPinnedTabsByWindowId} = require('../common/state/tabState')
const {siteSort} = require('../../js/state/siteUtil')
Expand Down Expand Up @@ -61,13 +62,6 @@ const updateWindow = (windowId) => {
}
}

const siteProps = (site) => {
return Immutable.fromJS({
location: site.get('location'),
partitionNumber: site.get('partitionNumber') || 0
})
}

const updatePinnedTabs = (win) => {
if (win.webContents.browserWindowOptions.disposition === 'new-popup') {
return
Expand All @@ -77,7 +71,7 @@ const updatePinnedTabs = (win) => {
const state = appStore.getState()
const windowId = win.id
const pinnedSites = state.get('sites').toList().filter((site) =>
site.get('tags').includes(siteTags.PINNED)).map((site) => siteProps(site))
site.get('tags').includes(siteTags.PINNED)).map(site => getSiteProps(site))
const pinnedTabs = getPinnedTabsByWindowId(state, windowId)

pinnedSites.filter((site) =>
Expand Down
13 changes: 13 additions & 0 deletions app/common/lib/windowsUtil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const Immutable = require('immutable')

module.exports.getSiteProps = site => {
return Immutable.fromJS({
location: site.get('location'),
order: site.get('order'),
partitionNumber: site.get('partitionNumber') || 0
})
}
40 changes: 40 additions & 0 deletions test/unit/app/common/lib/windowsUtilTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* global describe, beforeEach, it */
const windowsUtil = require('../../../../../app/common/lib/windowsUtil')
const assert = require('assert')
const Immutable = require('immutable')

require('../../../braveUnit')

describe('windowsUtil', () => {
const location = 'https://css-tricks.com/'
const order = 9
const partitionNumber = 5
const expectedSiteProps = Immutable.fromJS({
location,
order,
partitionNumber
})
let site

describe('getSiteProps', () => {
beforeEach(() => {
site = Immutable.fromJS({
favicon: 'https://css-tricks.com/favicon.ico',
lastAccessedTime: 1493560182224,
location: location,
order: order,
partitionNumber: partitionNumber,
title: 'CSS-Tricks'
})
})
it('returns object with necessary fields', () => {
const result = windowsUtil.getSiteProps(site)
assert.deepEqual(expectedSiteProps, result)
})
it('set partitionNumber field to 0 in case of missing this field', () => {
site = site.delete('partitionNumber')
const result = windowsUtil.getSiteProps(site)
assert.equal(0, result.get('partitionNumber'))
})
})
})