mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 17:25:16 -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
|
@ -8,9 +8,8 @@ import { store } from '..'
|
|||
import { ApiUrlActionType, ApiUrlObject, SetApiUrlAction } from './types'
|
||||
|
||||
export const setApiUrl = (state: ApiUrlObject): void => {
|
||||
const action: SetApiUrlAction = {
|
||||
store.dispatch({
|
||||
type: ApiUrlActionType.SET_API_URL,
|
||||
state
|
||||
}
|
||||
store.dispatch(action)
|
||||
} as SetApiUrlAction)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { Reducer } from 'redux'
|
||||
import { ApiUrlActions, ApiUrlActionType, ApiUrlObject, SetApiUrlAction } from './types'
|
||||
import { ApiUrlActions, ApiUrlActionType, ApiUrlObject } from './types'
|
||||
|
||||
export const initialState: ApiUrlObject = {
|
||||
apiUrl: ''
|
||||
|
@ -17,7 +17,7 @@ export const ApiUrlReducer: Reducer<ApiUrlObject, ApiUrlActions> = (
|
|||
) => {
|
||||
switch (action.type) {
|
||||
case ApiUrlActionType.SET_API_URL:
|
||||
return (action as SetApiUrlAction).state
|
||||
return action.state
|
||||
default:
|
||||
return state
|
||||
}
|
||||
|
|
|
@ -10,11 +10,10 @@ export enum ApiUrlActionType {
|
|||
SET_API_URL = 'api-url/set'
|
||||
}
|
||||
|
||||
export interface ApiUrlActions extends Action<ApiUrlActionType> {
|
||||
type: ApiUrlActionType
|
||||
}
|
||||
export type ApiUrlActions = SetApiUrlAction
|
||||
|
||||
export interface SetApiUrlAction extends ApiUrlActions {
|
||||
export interface SetApiUrlAction extends Action<ApiUrlActionType> {
|
||||
type: ApiUrlActionType.SET_API_URL
|
||||
state: ApiUrlObject
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue