From 956108e8343550ce400c4c69fad0c4d97413dec4 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Mon, 22 Jan 2018 08:07:35 +0100 Subject: [PATCH 1/2] Fixes upgrade of bookmark/folder width Resolves #9517 Resolves #9939 Auditors: Test Plan: --- app/browser/reducers/bookmarkToolbarReducer.js | 11 +++++++++-- .../browser/reducers/bookmarkToolbarReducerTest.js | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/browser/reducers/bookmarkToolbarReducer.js b/app/browser/reducers/bookmarkToolbarReducer.js index 8621487dd81..cc75a48dcd8 100644 --- a/app/browser/reducers/bookmarkToolbarReducer.js +++ b/app/browser/reducers/bookmarkToolbarReducer.js @@ -2,6 +2,8 @@ * 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') + // Constants const appConstants = require('../../../js/constants/appConstants') @@ -20,13 +22,18 @@ const bookmarkToolbarReducer = (state, action, immutableAction) => { { // update session for 0.21.x version const bookmarks = bookmarksState.getBookmarks(state) + let list = Immutable.List() if (bookmarks.first() && !bookmarks.first().has('width')) { - textCalc.calcTextList(bookmarks.toList()) + list = bookmarks.toList() } const bookmarkFolders = bookmarkFoldersState.getFolders(state) if (bookmarkFolders.first() && !bookmarkFolders.first().has('width')) { - textCalc.calcTextList(bookmarkFolders.toList()) + list = list.concat(bookmarkFolders.toList()) + } + + if (!list.isEmpty()) { + textCalc.calcTextList(list) } } break diff --git a/test/unit/app/browser/reducers/bookmarkToolbarReducerTest.js b/test/unit/app/browser/reducers/bookmarkToolbarReducerTest.js index b1aa1fef7a0..32330bad97e 100644 --- a/test/unit/app/browser/reducers/bookmarkToolbarReducerTest.js +++ b/test/unit/app/browser/reducers/bookmarkToolbarReducerTest.js @@ -122,7 +122,7 @@ describe('bookmarkToolbarReducer unit test', function () { bookmarkToolbarReducer(stateWithData, { actionType: appConstants.APP_SET_STATE }) - assert.equal(spyCalc.callCount, 2) + assert.equal(spyCalc.callCount, 1) }) it('we are on version 0.21', function () { From c83037155261faabaa47e84c865bc4e6b88c4266 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Wed, 24 Jan 2018 09:12:27 +0100 Subject: [PATCH 2/2] Fixes bookmark text calc with special chars Auditors: Test Plan: --- app/browser/api/textCalc.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/browser/api/textCalc.js b/app/browser/api/textCalc.js index 6fe3e87eb08..5b78b87d0f6 100644 --- a/app/browser/api/textCalc.js +++ b/app/browser/api/textCalc.js @@ -21,7 +21,7 @@ const fontSize = globalStyles.spacing.bookmarksItemFontSize const fontFamily = globalStyles.typography.default.family const calcText = (item, type) => { - const title = type === siteTags.BOOKMARK + let title = type === siteTags.BOOKMARK ? item.get('title') || item.get('location') : item.get('title') @@ -29,6 +29,11 @@ const calcText = (item, type) => { return } + title = title + .replace(/'/g, '!') + .replace(/\\"/g, '!') + .replace(/\\\\/g, '//') + const param = ` (function() { let ctx = document.createElement('canvas').getContext('2d') @@ -133,7 +138,7 @@ const calcTextList = (list) => { if (list.size > 0) { calcTextList(list) } - }) + }, true) } module.exports = {