Skip to content

Commit

Permalink
fix(web): don't stack repeated displayMetadata keys
Browse files Browse the repository at this point in the history
resolves #1463
  • Loading branch information
LukeWasTakenn committed Sep 9, 2023
1 parent bf69a76 commit e177d4b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions web/src/store/inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,15 @@ export const inventorySlice = createSlice({
) => {
state.contextMenu = action.payload;
},
setAdditionalMetadata: (state, action: PayloadAction<Array<{metadata: string, value: string}>>) => {
state.additionalMetadata = [ ...state.additionalMetadata, ...action.payload ];
setAdditionalMetadata: (state, action: PayloadAction<Array<{ metadata: string; value: string }>>) => {
const metadata = [];

for (let i = 0; i < action.payload.length; i++) {
const entry = action.payload[i];
if (!state.additionalMetadata.find((el) => el.value === entry.value)) metadata.push(entry);
}

state.additionalMetadata = [...state.additionalMetadata, ...metadata];
},
setItemAmount: (state, action: PayloadAction<number>) => {
state.itemAmount = action.payload;
Expand Down

0 comments on commit e177d4b

Please sign in to comment.