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

Commit

Permalink
Calculate bookmarks bar overflow using css
Browse files Browse the repository at this point in the history
Fix #13695

Remove usage of textCalc as it was the last usage of tabs.executeScriptInBackground which is not compatible with upcoming muon v6.x since as it incorrectly used executeScriptInTab which should only work on a WebContents which is a Tab, not a Window. Muon does not have a generic WebContents.executeJavascript method.

Also added bonus of not requiring creating new Windows in order to calculate text width and having to manage when they are closed, etc which should address the following issues, if that was the cause:
Fix #13422
Fix #13277
  • Loading branch information
petemill committed Apr 7, 2018
1 parent 56f9e72 commit 9bd1cb7
Show file tree
Hide file tree
Showing 27 changed files with 166 additions and 1,351 deletions.
147 changes: 0 additions & 147 deletions app/browser/api/textCalc.js

This file was deleted.

43 changes: 0 additions & 43 deletions app/browser/reducers/bookmarkFoldersReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ const Immutable = require('immutable')
// State
const bookmarksState = require('../../common/state/bookmarksState')
const bookmarkFoldersState = require('../../common/state/bookmarkFoldersState')
const bookmarkToolbarState = require('../../common/state/bookmarkToolbarState')

// Constants
const appConstants = require('../../../js/constants/appConstants')
const siteTags = require('../../../js/constants/siteTags')
const {STATE_SITES} = require('../../../js/constants/stateConstants')

// Utils
const {makeImmutable} = require('../../common/state/immutableUtil')
const syncUtil = require('../../../js/state/syncUtil')
const textCalc = require('../../browser/api/textCalc')
const bookmarkFolderUtil = require('../../common/lib/bookmarkFoldersUtil')

const bookmarkFoldersReducer = (state, action, immutableAction) => {
Expand All @@ -40,12 +37,10 @@ const bookmarkFoldersReducer = (state, action, immutableAction) => {
state = syncUtil.updateObjectCache(state, folderDetails, STATE_SITES.BOOKMARK_FOLDERS)
folderList = folderList.push(folderDetails)
})
textCalc.calcTextList(folderList)
} else {
const folderDetails = bookmarkFolderUtil.buildFolder(folder, bookmarkFoldersState.getFolders(state))
state = bookmarkFoldersState.addFolder(state, folderDetails, closestKey)
state = syncUtil.updateObjectCache(state, folderDetails, STATE_SITES.BOOKMARK_FOLDERS)
textCalc.calcText(folderDetails, siteTags.BOOKMARK_FOLDER)
}
break
}
Expand All @@ -66,12 +61,6 @@ const bookmarkFoldersReducer = (state, action, immutableAction) => {

state = bookmarkFoldersState.editFolder(state, key, oldFolder, folder)
state = syncUtil.updateObjectCache(state, folder, STATE_SITES.BOOKMARK_FOLDERS)
const folderDetails = bookmarkFoldersState.getFolder(state, key)
textCalc.calcText(folderDetails, siteTags.BOOKMARK_FOLDER)

if (folder.has('parentFolderId') && oldFolder.get('parentFolderId') !== folder.get('parentFolderId')) {
state = bookmarkToolbarState.setToolbars(state)
}

break
}
Expand All @@ -83,8 +72,6 @@ const bookmarkFoldersReducer = (state, action, immutableAction) => {
break
}

const oldFolder = bookmarkFoldersState.getFolder(state, key)

state = bookmarkFoldersState.moveFolder(
state,
key,
Expand All @@ -95,13 +82,6 @@ const bookmarkFoldersReducer = (state, action, immutableAction) => {

const destinationDetail = bookmarksState.findBookmark(state, action.get('destinationKey'))
state = syncUtil.updateObjectCache(state, destinationDetail, STATE_SITES.BOOKMARK_FOLDERS)
if (
destinationDetail.get('parentFolderId') === 0 ||
action.get('destinationKey') === 0 ||
oldFolder.get('parentFolderId') === 0
) {
state = bookmarkToolbarState.setToolbars(state)
}
break
}
case appConstants.APP_REMOVE_BOOKMARK_FOLDER:
Expand All @@ -118,33 +98,10 @@ const bookmarkFoldersReducer = (state, action, immutableAction) => {
state = bookmarkFoldersState.removeFolder(state, key)
state = syncUtil.updateObjectCache(state, folder, STATE_SITES.BOOKMARK_FOLDERS)
})
state = bookmarkToolbarState.setToolbars(state)
} else {
const folder = bookmarkFoldersState.getFolder(state, folderKey)
state = bookmarkFoldersState.removeFolder(state, folderKey)
state = syncUtil.updateObjectCache(state, folder, STATE_SITES.BOOKMARK_FOLDERS)
if (folder.get('parentFolderId') === 0) {
state = bookmarkToolbarState.setToolbars(state)
}
}
break
}
case appConstants.APP_ON_BOOKMARK_FOLDER_WIDTH_CHANGED:
{
if (action.get('folderList', Immutable.List()).isEmpty()) {
break
}

let updateToolbar = false
action.get('folderList').forEach(item => {
state = bookmarkFoldersState.setWidth(state, item.get('key'), item.get('width'))
if (item.get('parentFolderId') === 0) {
updateToolbar = true
}
})

if (updateToolbar) {
state = bookmarkToolbarState.setToolbars(state)
}
break
}
Expand Down
44 changes: 0 additions & 44 deletions app/browser/reducers/bookmarkToolbarReducer.js

This file was deleted.

Loading

0 comments on commit 9bd1cb7

Please sign in to comment.