From 4353b75ea136ac46fc7ff72ac5311b2fe80c38d5 Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Sat, 23 Nov 2024 10:35:50 +0000 Subject: [PATCH 1/5] memo the bindingobj --- .../src/components/spreadsheet/useSheetValue.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts b/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts index 692adeac566..ce78fe60e86 100644 --- a/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts +++ b/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts @@ -1,4 +1,4 @@ -import { useState, useRef, useLayoutEffect } from 'react'; +import { useState, useRef, useLayoutEffect, useMemo } from 'react'; import { type Query } from 'loot-core/shared/query'; import { useSpreadsheet } from 'loot-core/src/client/SpreadsheetProvider'; @@ -30,10 +30,13 @@ export function useSheetValue< ): SheetValueResult['value'] { const { sheetName, fullSheetName } = useSheetName(binding); - const bindingObj = - typeof binding === 'string' - ? { name: binding, value: null, query: undefined } - : binding; + const bindingObj = useMemo( + () => + typeof binding === 'string' + ? { name: binding, value: null, query: undefined } + : binding, + [], + ); const spreadsheet = useSpreadsheet(); const [result, setResult] = useState>({ @@ -48,6 +51,7 @@ export function useSheetValue< latestValue.current = result.value; useLayoutEffect(() => { + console.info(' yo:', bindingObj.query); if (bindingObj.query) { spreadsheet.createQuery(sheetName, bindingObj.name, bindingObj.query); } From f3f51dccf42504772e6fb106b1bd096b0582980c Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Sat, 23 Nov 2024 10:37:58 +0000 Subject: [PATCH 2/5] release notes --- upcoming-release-notes/3882.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 upcoming-release-notes/3882.md diff --git a/upcoming-release-notes/3882.md b/upcoming-release-notes/3882.md new file mode 100644 index 00000000000..9059395e154 --- /dev/null +++ b/upcoming-release-notes/3882.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [MikesGlitch] +--- + +Fix performance regression around accounts and budget pages From aa59fc9b88f1e3ec0de001ab1f080fbe049cde7a Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Sat, 23 Nov 2024 10:39:09 +0000 Subject: [PATCH 3/5] fix --- .../desktop-client/src/components/spreadsheet/useSheetValue.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts b/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts index ce78fe60e86..deca125d43e 100644 --- a/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts +++ b/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts @@ -51,7 +51,6 @@ export function useSheetValue< latestValue.current = result.value; useLayoutEffect(() => { - console.info(' yo:', bindingObj.query); if (bindingObj.query) { spreadsheet.createQuery(sheetName, bindingObj.name, bindingObj.query); } From 53fd326a6832b089445c6419f9a197f59fd48995 Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Sat, 23 Nov 2024 10:56:43 +0000 Subject: [PATCH 4/5] a bit heavy handed --- .../src/components/spreadsheet/useSheetValue.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts b/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts index deca125d43e..b8f2b46389d 100644 --- a/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts +++ b/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts @@ -30,13 +30,10 @@ export function useSheetValue< ): SheetValueResult['value'] { const { sheetName, fullSheetName } = useSheetName(binding); - const bindingObj = useMemo( - () => - typeof binding === 'string' - ? { name: binding, value: null, query: undefined } - : binding, - [], - ); + const bindingObj = + typeof binding === 'string' + ? { name: binding, value: null, query: undefined } + : binding; const spreadsheet = useSpreadsheet(); const [result, setResult] = useState>({ @@ -51,6 +48,7 @@ export function useSheetValue< latestValue.current = result.value; useLayoutEffect(() => { + console.info('hello', bindingObj.query, bindingObj.name); if (bindingObj.query) { spreadsheet.createQuery(sheetName, bindingObj.name, bindingObj.query); } @@ -69,7 +67,7 @@ export function useSheetValue< } }, ); - }, [sheetName, bindingObj.name, bindingObj.query]); + }, [sheetName, bindingObj.name, JSON.stringify(bindingObj.query)]); return result.value; } From bf7a266a498573488f78b69ad31ab239ca95777f Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Sat, 23 Nov 2024 11:02:03 +0000 Subject: [PATCH 5/5] lint --- .../desktop-client/src/components/spreadsheet/useSheetValue.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts b/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts index b8f2b46389d..ae0d09921ed 100644 --- a/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts +++ b/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts @@ -1,4 +1,4 @@ -import { useState, useRef, useLayoutEffect, useMemo } from 'react'; +import { useState, useRef, useLayoutEffect } from 'react'; import { type Query } from 'loot-core/shared/query'; import { useSpreadsheet } from 'loot-core/src/client/SpreadsheetProvider'; @@ -48,7 +48,6 @@ export function useSheetValue< latestValue.current = result.value; useLayoutEffect(() => { - console.info('hello', bindingObj.query, bindingObj.name); if (bindingObj.query) { spreadsheet.createQuery(sheetName, bindingObj.name, bindingObj.query); }