Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fixed regression bug, useSWRInfinite duplicate api call on refresh

TzeYiing9f429f1a617c
diff --git a/studio/components/interfaces/Settings/Logs/LogTable.tsx b/studio/components/interfaces/Settings/Logs/LogTable.tsx
index 9709dc6965d..5db96080e8d 100644
--- a/studio/components/interfaces/Settings/Logs/LogTable.tsx
+++ b/studio/components/interfaces/Settings/Logs/LogTable.tsx
@@ -50,12 +50,13 @@ const LogTable = ({ isCustomQuery, data }: Props) => {
}, {})
}, [JSON.stringify(data)])
+ const strLogMap = JSON.stringify(logMap)
useEffect(() => {
- if (!data) return
+ if (data === null || data === undefined) return
if (focusedLog && !(focusedLog.id in logMap)) {
setFocusedLog(null)
}
- }, [Object.keys(logMap)])
+ }, [strLogMap])
if (!data) return null
@@ -64,7 +65,7 @@ const LogTable = ({ isCustomQuery, data }: Props) => {
const logDataRows = useMemo(() => {
return Object.values(logMap).sort((a, b) => a.timestamp - b.timestamp)
- }, [JSON.stringify(Object.keys(logMap))])
+ }, [strLogMap])
return (
<section className="flex flex-1 flex-row" style={{ maxHeight }}>
<DataGrid
diff --git a/studio/pages/project/[ref]/settings/logs/[type].tsx b/studio/pages/project/[ref]/settings/logs/[type].tsx
index 75c7af9cfd2..5300d2f976d 100644
--- a/studio/pages/project/[ref]/settings/logs/[type].tsx
+++ b/studio/pages/project/[ref]/settings/logs/[type].tsx
@@ -110,7 +110,6 @@ export const LogPage: NextPage = () => {
const handleRefresh = () => {
setLatestRefresh(new Date().toISOString())
setSize(1)
- mutate()
}
const handleModeToggle = () => {
diff --git a/studio/tests/pages/projects/logs.test.js b/studio/tests/pages/projects/logs.test.js
index 5d963b3df15..bb9107a467e 100644
--- a/studio/tests/pages/projects/logs.test.js
+++ b/studio/tests/pages/projects/logs.test.js
@@ -97,7 +97,7 @@ test('Refreshpage', async () => {
await waitFor(() => screen.getByText(/my_key/))
// simulate refresh
- await waitFor(() => userEvent.click(screen.getByText(/Refresh/)))
+ userEvent.click(screen.getByText(/Refresh/))
// when log line unmounts and it was focused, should close focus panel
await waitFor(() => screen.queryByText(/my_key/) === null, { timeout: 1000 })
await waitFor(() => screen.queryByText(/happened/) === null, { timeout: 1000 })