mirror of
https://github.com/BoostIo/Boostnote
synced 2026-01-02 11:39:25 +00:00
Folder indexing
This commit is contained in:
@@ -8,6 +8,7 @@ export const SWITCH_USER = 'SWITCH_USER'
|
||||
export const SWITCH_FOLDER = 'SWITCH_FOLDER'
|
||||
export const SWITCH_MODE = 'SWITCH_MODE'
|
||||
export const SWITCH_ARTICLE = 'SWITCH_ARTICLE'
|
||||
export const SET_SEARCH_FILTER = 'SET_SEARCH_FILTER'
|
||||
|
||||
// Status - mode
|
||||
export const IDLE_MODE = 'IDLE_MODE'
|
||||
@@ -56,10 +57,10 @@ export function switchUser (userId) {
|
||||
}
|
||||
}
|
||||
|
||||
export function switchFolder (folderId) {
|
||||
export function switchFolder (folderName) {
|
||||
return {
|
||||
type: SWITCH_FOLDER,
|
||||
data: folderId
|
||||
data: folderName
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,3 +77,10 @@ export function switchArticle (articleKey) {
|
||||
data: articleKey
|
||||
}
|
||||
}
|
||||
|
||||
export function setSearchFilter (search) {
|
||||
return {
|
||||
type: SET_SEARCH_FILTER,
|
||||
data: search
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { combineReducers } from 'redux'
|
||||
import { findIndex } from 'lodash'
|
||||
import { SWITCH_USER, SWITCH_FOLDER, SWITCH_MODE, SWITCH_ARTICLE, USER_UPDATE, ARTICLE_REFRESH, ARTICLE_UPDATE, ARTICLE_DESTROY, IDLE_MODE, CREATE_MODE } from './actions'
|
||||
import { SWITCH_USER, SWITCH_FOLDER, SWITCH_MODE, SWITCH_ARTICLE, SET_SEARCH_FILTER, USER_UPDATE, ARTICLE_REFRESH, ARTICLE_UPDATE, ARTICLE_DESTROY, IDLE_MODE, CREATE_MODE } from './actions'
|
||||
import auth from 'boost/auth'
|
||||
|
||||
const initialStatus = {
|
||||
mode: IDLE_MODE
|
||||
mode: IDLE_MODE,
|
||||
search: ''
|
||||
}
|
||||
|
||||
function getInitialArticles () {
|
||||
@@ -39,20 +40,24 @@ function status (state, action) {
|
||||
case SWITCH_USER:
|
||||
state.userId = action.data
|
||||
state.mode = IDLE_MODE
|
||||
state.folderId = null
|
||||
return state
|
||||
case SWITCH_FOLDER:
|
||||
state.folderId = action.data
|
||||
state.mode = IDLE_MODE
|
||||
state.search = `in:${action.data} `
|
||||
return state
|
||||
case SWITCH_MODE:
|
||||
state.mode = action.data
|
||||
if (state.mode === CREATE_MODE) state.articleKey = null
|
||||
|
||||
return state
|
||||
case SWITCH_ARTICLE:
|
||||
state.articleKey = action.data
|
||||
state.mode = IDLE_MODE
|
||||
return state
|
||||
case SET_SEARCH_FILTER:
|
||||
state.search = action.data
|
||||
state.mode = IDLE_MODE
|
||||
return state
|
||||
default:
|
||||
if (state == null) return initialStatus
|
||||
return state
|
||||
|
||||
17
lib/store.js
17
lib/store.js
@@ -1,23 +1,6 @@
|
||||
import reducer from './reducer'
|
||||
import { createStore } from 'redux'
|
||||
|
||||
// import React from 'react'
|
||||
// import { compose } from 'redux'
|
||||
// import { devTools, persistState } from 'redux-devtools'
|
||||
// import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react'
|
||||
|
||||
// let finalCreateStore = compose(devTools(), persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)))(createStore)
|
||||
// let store = finalCreateStore(reducer)
|
||||
|
||||
// devToolEl = (
|
||||
// <DebugPanel top right bottom>
|
||||
// <DevTools store={store} monitor={LogMonitor} visibleOnLoad={false}/>
|
||||
// </DebugPanel>
|
||||
// )
|
||||
|
||||
// export let devToolElement = devToolEl
|
||||
// export default store
|
||||
|
||||
let store = createStore(reducer)
|
||||
|
||||
export let devToolElement = null
|
||||
|
||||
Reference in New Issue
Block a user