-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from BUTR/dev
Release 1.0.10
- Loading branch information
Showing
26 changed files
with
366 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// This is a risk, since we won't notice if the API changes | ||
// TODO: Ask IDCs to provider a proper type system | ||
import { types } from 'vortex-api'; | ||
|
||
export const setFBForceUpdate = (profileId: string) => ({ | ||
type: 'SET_FB_FORCE_UPDATE', | ||
payload: { | ||
profileId, | ||
}, | ||
}); | ||
|
||
export const setFBLoadOrderEntry = (profileId: string, loEntry: types.ILoadOrderEntry) => ({ | ||
type: 'SET_FB_LOAD_ORDER_ENTRY', | ||
payload: { | ||
profileId, | ||
loEntry, | ||
}, | ||
}); | ||
|
||
export const setFBLoadOrder = (profileId: string, loadOrder: types.LoadOrder) => ({ | ||
type: 'SET_FB_LOAD_ORDER', | ||
payload: { | ||
profileId, | ||
loadOrder, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * as actionsLoadOrder from './actions'; | ||
export * from './converter'; | ||
export * from './manager'; | ||
export * from './persistence'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function nameof<TObject>(obj: TObject, key: keyof TObject): string; | ||
export function nameof<TObject>(key: keyof TObject): string; | ||
export function nameof(key1: unknown, key2?: unknown): unknown { | ||
return key2 ?? key1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { actions, types, util } from 'vortex-api'; | ||
import { actionsSettings, actionsSave, ReducerHandler, ReducerHandlerState, createReducer, nameof } from '.'; | ||
import { IBannerlordSettings } from '../types'; | ||
|
||
// TODO: Ask IDCs to provider a proper type system? | ||
type SetLoadOrderPayload = { | ||
id: string; | ||
order: unknown[]; | ||
}; | ||
|
||
const setSaveInState = (state: ReducerHandlerState, payload: actionsSave.SetCurrentSavePayload) => { | ||
return util.setSafe(state, [nameof<IBannerlordSettings>('saveName'), payload.profileId], payload.saveId); | ||
}; | ||
|
||
const setSortOnDeployInState = (state: ReducerHandlerState, payload: actionsSettings.SetSortOnDeployPayload) => { | ||
return util.setSafe(state, [nameof<IBannerlordSettings>('sortOnDeploy'), payload.profileId], payload.sort); | ||
}; | ||
|
||
const setLoadOrderInState = (state: ReducerHandlerState, payload: SetLoadOrderPayload) => { | ||
return util.setSafe(state, [payload.id], payload.order); | ||
}; | ||
|
||
const getReducers = () => { | ||
const reducers: { [key: string]: ReducerHandler<unknown> } = {}; | ||
createReducer(actionsSettings.setSortOnDeploy, setSortOnDeployInState, reducers); | ||
createReducer(actions.setLoadOrder, setLoadOrderInState, reducers); | ||
createReducer(actionsSave.setCurrentSave, setSaveInState, reducers); | ||
return reducers; | ||
}; | ||
|
||
const getDefaults = () => ({ | ||
[nameof<IBannerlordSettings>('sortOnDeploy')]: {}, | ||
[nameof<IBannerlordSettings>('saveName')]: {}, | ||
}); | ||
|
||
export const reducer: types.IReducerSpec = { | ||
reducers: getReducers(), | ||
defaults: getDefaults(), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BaseActionCreator, ComplexActionCreator } from 'redux-act'; | ||
|
||
export type ReducerHandlerState = { | ||
[key: string]: unknown; | ||
}; | ||
|
||
export type ReducerHandler<P> = (state: ReducerHandlerState, payload: P) => ReducerHandlerState; | ||
|
||
export const createReducer = <P, M>( | ||
actionCreator: BaseActionCreator<ComplexActionCreator<P, M>>, | ||
action: ReducerHandler<P>, | ||
reducers: { [key: string]: ReducerHandler<P> } | ||
) => { | ||
reducers[actionCreator.getType()] = action; | ||
}; |
Oops, something went wrong.