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

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Jul 7, 2017
1 parent 765c713 commit 590acc4
Show file tree
Hide file tree
Showing 24 changed files with 611 additions and 444 deletions.
2 changes: 2 additions & 0 deletions app/browser/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ const doAction = (state, action) => {
}
break
case appConstants.APP_ADD_SITE:
case appConstants.APP_ADD_BOOKMARK:
case appConstants.APP_EDIT_BOOKMARK:
{
if (action.tag === siteTags.BOOKMARK || action.tag === siteTags.BOOKMARK_FOLDER) {
createMenu(state)
Expand Down
57 changes: 37 additions & 20 deletions app/browser/reducers/sitesReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,52 @@ const sitesReducer = (state, action, immutableAction) => {
break
}
case appConstants.APP_ADD_SITE:
const isSyncEnabled = syncEnabled()
if (Immutable.List.isList(action.siteDetail)) {
action.siteDetail.forEach((s) => {
state = siteUtil.addSite(state, s, action.tag, undefined, action.skipSync)
{
const isSyncEnabled = syncEnabled()
if (Immutable.List.isList(action.siteDetail)) {
action.siteDetail.forEach((s) => {
state = siteUtil.addSite(state, s, action.tag, action.skipSync)
if (isSyncEnabled) {
state = syncUtil.updateSiteCache(state, s)
}
})
} else {
let sites = state.get('sites')
if (!action.siteDetail.get('folderId') && siteUtil.isFolder(action.siteDetail)) {
action.siteDetail = action.siteDetail.set('folderId', siteUtil.getNextFolderId(sites))
}
state = siteUtil.addSite(state, action.siteDetail, action.tag, action.skipSync)
if (isSyncEnabled) {
state = syncUtil.updateSiteCache(state, s)
state = syncUtil.updateSiteCache(state, action.siteDetail)
}
})
} else {
let sites = state.get('sites')
if (!action.siteDetail.get('folderId') && siteUtil.isFolder(action.siteDetail)) {
}
state = updateActiveTabBookmarked(state)
break
}
case appConstants.APP_ADD_BOOKMARK:
case appConstants.APP_EDIT_BOOKMARK:
{
const isSyncEnabled = syncEnabled()
const sites = state.get('sites')
const closestKey = action.closestKey
if (!action.siteDetail.get('folderId') && action.tag === siteTags.BOOKMARK_FOLDER) {
action.siteDetail = action.siteDetail.set('folderId', siteUtil.getNextFolderId(sites))
}
state = siteUtil.addSite(state, action.siteDetail, action.tag, action.originalSiteDetail, action.skipSync)
if (action.destinationDetail) {
const sourceKey = siteUtil.getSiteKey(action.siteDetail)
const destinationKey = siteUtil.getSiteKey(action.destinationDetail)

if (sourceKey != null) {
state = siteUtil.moveSite(state,
sourceKey, destinationKey, false, false, true)
}
state = siteUtil.addSite(state, action.siteDetail, action.tag, action.editKey)

if (closestKey != null) {
const sourceKey = siteUtil.getSiteKey(action.siteDetail)
state = siteUtil.moveSite(state, sourceKey, closestKey, false, false, true)
}

if (isSyncEnabled) {
state = syncUtil.updateSiteCache(state, action.destinationDetail || action.siteDetail)
state = syncUtil.updateSiteCache(state, action.siteDetail)
}

state = updateActiveTabBookmarked(state)
break
}
state = updateActiveTabBookmarked(state)
break
case appConstants.APP_REMOVE_SITE:
const removeSiteSyncCallback = action.skipSync ? undefined : syncActions.removeSite
state = siteUtil.removeSite(state, action.siteDetail, action.tag, true, removeSiteSyncCallback)
Expand Down
2 changes: 2 additions & 0 deletions app/browser/reducers/urlBarSuggestionsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const tabState = require('../../common/state/tabState')
const urlBarSuggestionsReducer = (state, action) => {
switch (action.actionType) {
case appConstants.APP_ADD_SITE:
case appConstants.APP_ADD_BOOKMARK:
case appConstants.APP_EDIT_BOOKMARK:
if (Immutable.List.isList(action.siteDetail)) {
action.siteDetail.forEach((s) => {
add(s)
Expand Down
24 changes: 13 additions & 11 deletions app/common/lib/bookmarkUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ const {calculateTextWidth} = require('../../../js/lib/textCalculator')
const {iconSize} = require('../../../js/constants/config')
const {getSetting} = require('../../../js/settings')

const bookmarkHangerHeading = (detail, isFolder, shouldShowLocation) => {
function bookmarkHangerHeading (editMode, isFolder, isAdded) {
if (isFolder) {
return shouldShowLocation
return editMode
? 'bookmarkFolderEditing'
: 'bookmarkFolderAdding'
}
return shouldShowLocation
? (!detail || !detail.has('location'))
? 'bookmarkCreateNew'
: 'bookmarkEdit'
: 'bookmarkAdded'

if (isAdded) {
return 'bookmarkAdded'
}

return editMode
? 'bookmarkEdit'
: 'bookmarkCreateNew'
}

const displayBookmarkName = (detail) => {
Expand All @@ -37,11 +40,10 @@ const displayBookmarkName = (detail) => {
return detail.get('title') || ''
}

const isBookmarkNameValid = (detail, isFolder) => {
const title = detail.get('title') || detail.get('customTitle')
const location = detail.get('location')
const isBookmarkNameValid = (title, location, isFolder, customTitle) => {
const newTitle = title || customTitle
return isFolder
? (title != null && title.trim().length > 0)
? (newTitle != null && newTitle.trim().length > 0)
: (location != null && location.trim().length > 0)
}

Expand Down
Loading

0 comments on commit 590acc4

Please sign in to comment.