mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-24 20:14:35 -04:00
Reorganize redux types to avoid unnecessary type casting
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
a221ce4255
commit
6a43d0c5fb
27 changed files with 113 additions and 153 deletions
|
@ -9,9 +9,8 @@ import { Config } from '../../api/config/types'
|
|||
import { ConfigActionType, SetConfigAction } from './types'
|
||||
|
||||
export const setConfig = (state: Config): void => {
|
||||
const action: SetConfigAction = {
|
||||
store.dispatch({
|
||||
type: ConfigActionType.SET_CONFIG,
|
||||
state: state
|
||||
}
|
||||
store.dispatch(action)
|
||||
} as SetConfigAction)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { Reducer } from 'redux'
|
||||
import { Config } from '../../api/config/types'
|
||||
import { ConfigActions, ConfigActionType, SetConfigAction } from './types'
|
||||
import { ConfigActions, ConfigActionType } from './types'
|
||||
|
||||
export const initialState: Config = {
|
||||
allowAnonymous: true,
|
||||
|
@ -55,7 +55,7 @@ export const initialState: Config = {
|
|||
export const ConfigReducer: Reducer<Config, ConfigActions> = (state: Config = initialState, action: ConfigActions) => {
|
||||
switch (action.type) {
|
||||
case ConfigActionType.SET_CONFIG:
|
||||
return (action as SetConfigAction).state
|
||||
return action.state
|
||||
default:
|
||||
return state
|
||||
}
|
||||
|
|
|
@ -11,10 +11,9 @@ export enum ConfigActionType {
|
|||
SET_CONFIG = 'config/set'
|
||||
}
|
||||
|
||||
export interface ConfigActions extends Action<ConfigActionType> {
|
||||
type: ConfigActionType
|
||||
}
|
||||
export type ConfigActions = SetConfigAction
|
||||
|
||||
export interface SetConfigAction extends ConfigActions {
|
||||
export interface SetConfigAction extends Action<ConfigActionType> {
|
||||
type: ConfigActionType.SET_CONFIG
|
||||
state: Config
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue