Fix Sidebar & Mouse event target area

Fix clipboard
Fix invalid state in sidebar due to missing event termination
This commit is contained in:
Thomas Nordquist
2019-01-10 10:34:09 +01:00
parent 269061bdc8
commit eb375073f9
11 changed files with 111 additions and 60 deletions

View File

@@ -1,19 +1,29 @@
import { Reducer, Action } from 'redux'
import * as q from '../../../backend/src/Model'
export enum ActionTypes {
setAutoExpandLimit = 'SET_AUTO_EXPAND_LIMIT',
toggleSettingsVisibility = 'TOGGLE_SETTINGS_VISIBILITY',
setNodeOrder = 'SET_NODE_ORDER',
selectTopic = 'SELECT_TOPIC',
}
interface SettingsAction extends Action {
interface CustomAction extends Action {
type: ActionTypes,
autoExpandLimit?: number
nodeOrder?: NodeOrder
selectedTopic?: q.TreeNode
}
export interface AppState {
settings: SettingsModel
settings: SettingsState,
selectedTopic?: q.TreeNode
}
export interface SettingsState {
autoExpandLimit: number
visible: boolean
nodeOrder: NodeOrder
}
export enum NodeOrder {
@@ -23,13 +33,7 @@ export enum NodeOrder {
topics = '#topics',
}
export interface SettingsModel {
autoExpandLimit: number
visible: boolean
nodeOrder: NodeOrder
}
const reducer: Reducer<AppState | undefined, SettingsAction> = (state, action) => {
const reducer: Reducer<AppState | undefined, CustomAction> = (state, action) => {
if (!state) {
throw Error('No initial state')
}
@@ -57,6 +61,15 @@ const reducer: Reducer<AppState | undefined, SettingsAction> = (state, action) =
nodeOrder: state.settings.nodeOrder,
},
}
case ActionTypes.selectTopic:
if (!action.selectedTopic) {
return state
}
return {
...state,
settings: state.settings,
selectedTopic: action.selectedTopic,
}
case ActionTypes.setNodeOrder:
if (!action.nodeOrder) {
return state