mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
use ConfigManager
This commit is contained in:
@@ -5,6 +5,7 @@ import { openModal } from 'browser/lib/modal'
|
||||
import Preferences from '../modals/Preferences'
|
||||
import RepositorySection from './RepositorySection'
|
||||
import NewRepositoryModal from '../modals/NewRepositoryModal'
|
||||
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||
|
||||
const electron = require('electron')
|
||||
const { remote } = electron
|
||||
@@ -46,17 +47,19 @@ class SideNav extends React.Component {
|
||||
}
|
||||
|
||||
handleToggleButtonClick (e) {
|
||||
let { dispatch } = this.props
|
||||
let { dispatch, config } = this.props
|
||||
|
||||
ConfigManager.set({isSideNavFolded: !config.isSideNavFolded})
|
||||
dispatch({
|
||||
type: 'TOGGLE_SIDENAV'
|
||||
type: 'SET_IS_SIDENAV_FOLDED',
|
||||
isFolded: !config.isSideNavFolded
|
||||
})
|
||||
}
|
||||
|
||||
render () {
|
||||
let { repositories, dispatch, location, status } = this.props
|
||||
let { repositories, dispatch, location, config } = this.props
|
||||
|
||||
let isFolded = !status.sideNavExpand
|
||||
let isFolded = config.isSideNavFolded
|
||||
let isHomeActive = location.pathname.match(/^\/home$/)
|
||||
let isStarredActive = location.pathname.match(/^\/starred$/)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { combineReducers, createStore } from 'redux'
|
||||
import _ from 'lodash'
|
||||
import { syncHistoryWithStore, routerReducer } from 'react-router-redux'
|
||||
import { routerReducer } from 'react-router-redux'
|
||||
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||
|
||||
/**
|
||||
* Repositories
|
||||
@@ -110,14 +111,15 @@ function repositories (state = initialRepositories, action) {
|
||||
return state
|
||||
}
|
||||
|
||||
const defaultStatus = {
|
||||
sideNavExpand: false
|
||||
}
|
||||
const defaultConfig = ConfigManager.get()
|
||||
|
||||
function status (state = defaultStatus, action) {
|
||||
function config (state = defaultConfig, action) {
|
||||
switch (action.type) {
|
||||
case 'TOGGLE_SIDENAV':
|
||||
state.sideNavExpand = !state.sideNavExpand
|
||||
case 'SET_IS_SIDENAV_FOLDED':
|
||||
state.isSideNavFolded = action.isFolded
|
||||
return Object.assign({}, state)
|
||||
case 'SET_ZOOM':
|
||||
state.zoom = action.zoom
|
||||
return Object.assign({}, state)
|
||||
}
|
||||
return state
|
||||
@@ -125,7 +127,7 @@ function status (state = defaultStatus, action) {
|
||||
|
||||
let reducer = combineReducers({
|
||||
repositories,
|
||||
status,
|
||||
config,
|
||||
routing: routerReducer
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user