Skip to content

Commit

Permalink
Add updatePin function
Browse files Browse the repository at this point in the history
  • Loading branch information
GLDuval committed May 6, 2023
1 parent b1aa29e commit 2a112f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Empty file.
9 changes: 8 additions & 1 deletion src/renderer/store/modules/gpioPins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ export const gpioPinsSlice = createSlice({
addPin: (state, { payload }: PayloadAction<GpioPinsState>) => {
state.push(payload);
},
updatePin: (state, { payload }: PayloadAction<GpioPinsState>) => {
const element = state.find((element) => element.id === payload.id);
if (element) {
element.name = payload.name;
element.topicName = payload.topicName;
}
},
removePin: (state, { payload }: PayloadAction<GpioPinsState>) => {
state = state.filter((pin) => pin.id !== payload.id);
},
},
});

export const selectAllPins = (state: GlobalState) => state.gpioPins;
export const selectAllGpioPins = (state: GlobalState) => state.gpioPins;

0 comments on commit 2a112f4

Please sign in to comment.