1
0
Fork 0
mirror of synced 2024-09-09 06:01:08 +12:00

Remove unnecessary searching through large rows array

This commit is contained in:
Andrew Kingston 2023-03-08 10:15:46 +00:00
parent dfce198fe5
commit 9020060f17

View file

@ -135,7 +135,8 @@ export const createRowsStore = context => {
// Get index of row to check if it exists
const $rows = get(rows)
const index = $rows.findIndex(row => row._id === id)
const $rowLookupMap = get(rowLookupMap)
const index = $rowLookupMap[id]
// Process as either an update, addition or deletion
if (newRow) {
@ -167,7 +168,8 @@ export const createRowsStore = context => {
// Updates a value of a row
const updateRow = async (rowId, column, value) => {
const $rows = get(rows)
const index = $rows.findIndex(x => x._id === rowId)
const $rowLookupMap = get(rowLookupMap)
const index = $rowLookupMap[rowId]
const row = $rows[index]
if (index === -1 || row?.[column] === value) {
return