From ce6aaa709fd112ecac7659e207152bd9a03d84f3 Mon Sep 17 00:00:00 2001 From: Kendall Garner <17521368+kgarner7@users.noreply.github.com> Date: Tue, 1 Jul 2025 19:03:54 -0700 Subject: [PATCH] bugfix: handle table update when column is missing --- src/renderer/hooks/use-song-change.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/renderer/hooks/use-song-change.ts b/src/renderer/hooks/use-song-change.ts index 3bf27504..7bf54c88 100644 --- a/src/renderer/hooks/use-song-change.ts +++ b/src/renderer/hooks/use-song-change.ts @@ -33,16 +33,17 @@ export const useTableChange = ( const api = tableRef.current?.api; if (!api) return; - const rowNodes: RowNode[] = []; const idSet = new Set(ids); api.forEachNode((node: RowNode) => { if (!node.data || !idSet.has(node.data.id)) return; + // Make sure to use setData instead of setDataValue. setDataValue + // will error if the column does not exist, whereas setData won't care switch (event.event) { case 'favorite': { if (node.data.userFavorite !== event.favorite) { - node.setDataValue('userFavorite', event.favorite); + node.setData({ ...node.data, userFavorite: event.favorite }); } break; } @@ -58,18 +59,12 @@ export const useTableChange = ( break; case 'rating': { if (node.data.userRating !== event.rating) { - node.setDataValue('userRating', event.rating); - rowNodes.push(node); + node.setData({ ...node.data, userRating: event.rating }); } break; } } }); - - // This is required to redraw star rows - if (rowNodes.length > 0) { - api.redrawRows({ rowNodes }); - } }, [tableRef], );