Skip to content

Commit b8b3f15

Browse files
fix pr comments, update actionkeybind types
1 parent bcc8681 commit b8b3f15

6 files changed

Lines changed: 16 additions & 11 deletions

File tree

src/redux/actions/actionsMiddleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const getAllActions = createAsyncThunk('actions/getAll', async () => {
1111
});
1212
const data = await topic.next();
1313
if (data.type !== 'combined') {
14-
throw new Error(`Expected keybinds in data, got '${data}'`);
14+
throw new Error(`Expected keybinds in data, got '${JSON.stringify(data)}'`);
1515
}
1616
topic.cancel();
1717
return data;
@@ -24,7 +24,7 @@ export const getAction = createAsyncThunk('actions/get', async (uri: Uri) => {
2424
});
2525
const data = await topic.next();
2626
if (data.type !== 'action') {
27-
throw new Error(`Expected action, got '${data}'`);
27+
throw new Error(`Expected action, got '${JSON.stringify(data)}'`);
2828
}
2929
topic.cancel();
3030
return data.action;

src/redux/actions/actionsSlice.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit';
22
import { Action, Keybind } from 'openspace-api-js/generated';
33

44
import { getAction, getAllActions } from './actionsMiddleware';
5+
import { KeybindModifiers, KeybindRedux } from '@/types/types';
56

67
export interface ActionsState {
78
isInitialized: boolean;
89
navigationPath: string;
910
actions: Action[];
10-
keybinds: Keybind[];
11+
keybinds: KeybindRedux[];
1112
showKeybinds: boolean;
1213
}
1314

@@ -58,10 +59,11 @@ export const actionsSlice = createSlice({
5859
getAllActions.fulfilled,
5960
(state, action: PayloadAction<{ actions: Action[]; keybinds: Keybind[] }>) => {
6061
const { actions, keybinds } = action.payload;
61-
const modifiedKeybinds: Keybind[] = keybinds.map((keybind) => {
62+
63+
const modifiedKeybinds: KeybindRedux[] = keybinds.map((keybind) => {
6264
const modifiers = Object.values(keybind.modifiers)
6365
.map((value, i) => (value ? Object.keys(keybind.modifiers)[i] : null))
64-
.filter((value) => value !== null) as Keybind['modifiers'];
66+
.filter((value) => value !== null) as KeybindModifiers;
6567

6668
return {
6769
action: keybind.action,

src/redux/logging/loggingMiddleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function unsubscribe() {
6767
function logNotificationMessage(logMessage: LogMessage, showNotification: boolean) {
6868
const { category, level, message } = logMessage;
6969

70-
if (!level || !category) {
70+
if (level === undefined || !category) {
7171
return;
7272
}
7373

src/redux/missions/missionsSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const missionsSlice = createSlice({
5656
state.missions = {};
5757
state.isInitialized = true;
5858

59-
Object.entries(action.payload).map(([identifier, mission]) => {
59+
Object.entries(action.payload).forEach(([identifier, mission]) => {
6060
state.missions[identifier] = convertMissionToUTC(mission);
6161
});
6262

src/redux/propertytree/propertyTreeMiddleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const getRoot = createAsyncThunk('propertyTree/getRoot', async (_, thunkAPI) =>
148148
const response = await api.getProperty(rootOwnerKey);
149149

150150
if (response.type !== 'propertyOwner') {
151-
throw new Error(`Expected propertyOwner, got '${response.type}': ${response.value}'`);
151+
throw new Error(`Expected propertyOwner, got '${JSON.stringify(response)}'`);
152152
}
153153

154154
const { propertyOwners, properties } = flattenPropertyTree(response.value);

src/types/types.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ export type LanguageInfo = {
1414
icon: React.JSX.Element;
1515
};
1616

17-
export type KeybindModifiers = Keybind['modifiers'];
17+
export type KeybindModifiers = (keyof Keybind['modifiers'])[];
1818

19+
export type KeybindRedux = Pick<Keybind, 'action' | 'key'> & {
20+
modifiers: KeybindModifiers;
21+
};
1922
// @TODO (anden88 2026-04-07): This is currently not being used in favour of
2023
// `KeybindInfoType` does this concatenation of the Keybind and Action make sense?
21-
export type ActionOrKeybind = Action | Keybind;
24+
export type ActionOrKeybind = Action | KeybindRedux;
2225

23-
export type KeybindInfoType = Keybind & Action;
26+
export type KeybindInfoType = KeybindRedux & Action;
2427

2528
export interface Properties {
2629
[key: Uri]: AnyProperty | undefined;

0 commit comments

Comments
 (0)