diff --git a/app/common/lib/bookmarkUtil.js b/app/common/lib/bookmarkUtil.js index 44cf589fc21..1fd21d9fdaa 100644 --- a/app/common/lib/bookmarkUtil.js +++ b/app/common/lib/bookmarkUtil.js @@ -68,15 +68,18 @@ const getDNDBookmarkData = (state, bookmarkKey) => { } let oldBookmarks +let oldBookmarkOrderCache let oldFolders let lastValue let lastWidth const getToolbarBookmarks = (state) => { const windowWidth = window.innerWidth const allBookmarks = bookmarksState.getBookmarks(state) + const bookmarkOrderCache = bookmarksState.getBookmarkOrder(state) const allFolders = bookmarkFoldersState.getFolders(state) if ( allBookmarks === oldBookmarks && + bookmarkOrderCache === oldBookmarkOrderCache && allFolders === oldFolders && lastWidth === windowWidth && lastValue @@ -85,6 +88,7 @@ const getToolbarBookmarks = (state) => { } oldBookmarks = allBookmarks + oldBookmarkOrderCache = bookmarkOrderCache oldFolders = allFolders lastWidth = windowWidth diff --git a/app/common/state/bookmarksState.js b/app/common/state/bookmarksState.js index 1dfdc1c9225..7bee24e27e7 100644 --- a/app/common/state/bookmarksState.js +++ b/app/common/state/bookmarksState.js @@ -44,6 +44,10 @@ const bookmarksState = { return state.getIn([STATE_SITES.BOOKMARKS, key], Immutable.Map()) }, + getBookmarkOrder: (state) => { + return state.getIn(STATE_SITES.BOOKMARK_ORDER_PATH) + }, + /** * Use this function if you only have a key and don't know if key is for folder or regular bookmark * @param state diff --git a/app/renderer/components/bookmarks/bookmarksToolbar.js b/app/renderer/components/bookmarks/bookmarksToolbar.js index f3ec3c22b45..79c81e65e44 100644 --- a/app/renderer/components/bookmarks/bookmarksToolbar.js +++ b/app/renderer/components/bookmarks/bookmarksToolbar.js @@ -61,8 +61,7 @@ class BookmarksToolbar extends React.Component { if (droppedOn.selectedRef) { const isRightSide = !dnd.isLeftSide(ReactDOM.findDOMNode(droppedOn.selectedRef), e.clientX) const droppedOnKey = droppedOn.selectedRef.props.bookmarkKey - const isDestinationParent = droppedOn.selectedRef.props.isFolder && droppedOn && droppedOn.isDroppedOn - + const isDestinationParent = droppedOn.selectedRef.state.isFolder && droppedOn && droppedOn.isDroppedOn if (bookmark.get('type') === siteTags.BOOKMARK_FOLDER) { appActions.moveBookmarkFolder(bookmark.get('key'), droppedOnKey, isRightSide, isDestinationParent) } else { diff --git a/js/constants/stateConstants.js b/js/constants/stateConstants.js index d264fe7ff3a..216177ab66e 100644 --- a/js/constants/stateConstants.js +++ b/js/constants/stateConstants.js @@ -6,7 +6,8 @@ const STATE_SITES = { BOOKMARKS: 'bookmarks', BOOKMARK_FOLDERS: 'bookmarkFolders', HISTORY_SITES: 'historySites', - PINNED_SITES: 'pinnedSites' + PINNED_SITES: 'pinnedSites', + BOOKMARK_ORDER_PATH: ['cache', 'bookmarkOrder'] } module.exports = { diff --git a/test/unit/app/common/state/bookmarksStateTest.js b/test/unit/app/common/state/bookmarksStateTest.js index 9b38c175d84..80066efe646 100644 --- a/test/unit/app/common/state/bookmarksStateTest.js +++ b/test/unit/app/common/state/bookmarksStateTest.js @@ -66,6 +66,11 @@ const stateWithData = Immutable.fromJS({ }) describe('bookmarkState unit test', function () { + describe('getBookmarkOrder', function () { + it('resturns order state', function () { + assert.deepEqual(bookmarksState.getBookmarkOrder(stateWithData), stateWithData.getIn(['cache', 'bookmarkOrder'])) + }) + }) describe('getBookmarksByParentId', function () { it('null case', function () { const result = bookmarksState.getBookmarksByParentId(stateWithData)