feat(config): Add deviceName to the user config (#474)
* add device name to configuration * feat(config): Rename user configuration * style: fix tslint error * test: Fix unit tests * test: Add UserConfiguration device name test * set device name if faild the user-config read from device * feat(device): Remove the first 0 from USB[W] dump
This commit is contained in:
committed by
László Monda
parent
9885439b10
commit
cdc4a169de
@@ -12,7 +12,8 @@ export const ActionTypes = {
|
||||
SAVE_USER_CONFIG_SUCCESS: type(PREFIX + 'Save User Config Success'),
|
||||
SAVE_USER_CONFIG_IN_JSON_FILE: type(PREFIX + 'Save User Config in JSON file'),
|
||||
SAVE_USER_CONFIG_IN_BIN_FILE: type(PREFIX + 'Save User Config in binary file'),
|
||||
LOAD_RESET_USER_CONFIGURATION: type(PREFIX + 'Load reset user configuration')
|
||||
LOAD_RESET_USER_CONFIGURATION: type(PREFIX + 'Load reset user configuration'),
|
||||
RENAME_USER_CONFIGURATION: type(PREFIX + 'Rename user configuration')
|
||||
};
|
||||
|
||||
export class LoadUserConfigAction implements Action {
|
||||
@@ -26,19 +27,22 @@ export class LoadConfigFromDeviceAction implements Action {
|
||||
export class LoadConfigFromDeviceReplyAction implements Action {
|
||||
type = ActionTypes.LOAD_CONFIG_FROM_DEVICE_REPLY;
|
||||
|
||||
constructor(public payload: ConfigurationReply) { }
|
||||
constructor(public payload: ConfigurationReply) {
|
||||
}
|
||||
}
|
||||
|
||||
export class LoadUserConfigSuccessAction implements Action {
|
||||
type = ActionTypes.LOAD_USER_CONFIG_SUCCESS;
|
||||
|
||||
constructor(public payload: UserConfiguration) { }
|
||||
constructor(public payload: UserConfiguration) {
|
||||
}
|
||||
}
|
||||
|
||||
export class SaveUserConfigSuccessAction implements Action {
|
||||
type = ActionTypes.SAVE_USER_CONFIG_SUCCESS;
|
||||
|
||||
constructor(public payload: UserConfiguration) { }
|
||||
constructor(public payload: UserConfiguration) {
|
||||
}
|
||||
}
|
||||
|
||||
export class SaveUserConfigInJsonFileAction implements Action {
|
||||
@@ -52,7 +56,15 @@ export class SaveUserConfigInBinaryFileAction implements Action {
|
||||
export class LoadResetUserConfigurationAction implements Action {
|
||||
type = ActionTypes.LOAD_RESET_USER_CONFIGURATION;
|
||||
|
||||
constructor(public payload: UserConfiguration) { }
|
||||
constructor(public payload: UserConfiguration) {
|
||||
}
|
||||
}
|
||||
|
||||
export class RenameUserConfigurationAction implements Action {
|
||||
type = ActionTypes.RENAME_USER_CONFIGURATION;
|
||||
|
||||
constructor(public payload: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export type Actions
|
||||
@@ -64,4 +76,5 @@ export type Actions
|
||||
| SaveUserConfigInJsonFileAction
|
||||
| SaveUserConfigInBinaryFileAction
|
||||
| LoadResetUserConfigurationAction
|
||||
| RenameUserConfigurationAction
|
||||
;
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
import {
|
||||
ActionTypes,
|
||||
LoadUserConfigSuccessAction,
|
||||
RenameUserConfigurationAction,
|
||||
SaveUserConfigSuccessAction
|
||||
} from '../actions/user-config';
|
||||
|
||||
@@ -72,8 +73,9 @@ export class UserConfigEffects {
|
||||
KeymapActions.ADD, KeymapActions.DUPLICATE, KeymapActions.EDIT_NAME, KeymapActions.EDIT_ABBR,
|
||||
KeymapActions.SET_DEFAULT, KeymapActions.REMOVE, KeymapActions.SAVE_KEY,
|
||||
MacroActions.ADD, MacroActions.DUPLICATE, MacroActions.EDIT_NAME, MacroActions.REMOVE, MacroActions.ADD_ACTION,
|
||||
MacroActions.SAVE_ACTION, MacroActions.DELETE_ACTION, MacroActions.REORDER_ACTION) as
|
||||
Observable<KeymapAction | MacroAction>)
|
||||
MacroActions.SAVE_ACTION, MacroActions.DELETE_ACTION, MacroActions.REORDER_ACTION,
|
||||
ActionTypes.RENAME_USER_CONFIGURATION) as
|
||||
Observable<KeymapAction | MacroAction | RenameUserConfigurationAction>)
|
||||
.withLatestFrom(this.store.select(getUserConfiguration), this.store.select(getPrevUserConfiguration))
|
||||
.mergeMap(([action, config, prevUserConfiguration]) => {
|
||||
this.dataStorageRepository.saveConfig(config);
|
||||
|
||||
@@ -39,6 +39,7 @@ export const metaReducers: MetaReducer<AppState>[] = environment.production
|
||||
: [storeFreeze];
|
||||
|
||||
export const getUserConfiguration = (state: AppState) => state.userConfiguration;
|
||||
export const getDeviceName = (state: AppState) => state.userConfiguration.deviceName;
|
||||
|
||||
export const appState = (state: AppState) => state.app;
|
||||
export const showAddonMenu = createSelector(appState, fromApp.showAddonMenu);
|
||||
|
||||
@@ -126,7 +126,7 @@ export function reducer(state = initialState, action: Action & { payload?: any }
|
||||
if (index - 1 === newKeyAction.layer) {
|
||||
const clonedAction = KeyActionHelper.createKeyAction(action.payload.keyAction);
|
||||
setKeyActionToLayer(newLayer, moduleIndex, keyIndex, clonedAction);
|
||||
}else {
|
||||
} else {
|
||||
setKeyActionToLayer(newLayer, moduleIndex, keyIndex, null);
|
||||
}
|
||||
}
|
||||
@@ -240,6 +240,12 @@ export function reducer(state = initialState, action: Action & { payload?: any }
|
||||
return macro;
|
||||
});
|
||||
break;
|
||||
|
||||
case ActionTypes.RENAME_USER_CONFIGURATION: {
|
||||
changedUserConfiguration.deviceName = action.payload;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user