Skip to content

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

fix: full refresh on logs page (#37246)

Alaister Young78ec1a4c9165
diff --git a/apps/studio/pages/project/[ref]/logs/index.tsx b/apps/studio/pages/project/[ref]/logs/index.tsx
index 4875b1f9545..92ac4e81db7 100644
--- a/apps/studio/pages/project/[ref]/logs/index.tsx
+++ b/apps/studio/pages/project/[ref]/logs/index.tsx
@@ -1,7 +1,7 @@
import { useRouter } from 'next/router'
-import { useEffect } from 'react'
+import { useContext, useEffect } from 'react'
-import { LOCAL_STORAGE_KEYS, useParams } from 'common'
+import { FeatureFlagContext, LOCAL_STORAGE_KEYS, useParams } from 'common'
import { useUnifiedLogsPreview } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { UnifiedLogs } from 'components/interfaces/UnifiedLogs/UnifiedLogs'
import DefaultLayout from 'components/layouts/DefaultLayout'
@@ -13,6 +13,7 @@ import type { NextPageWithLayout } from 'types'
export const LogPage: NextPageWithLayout = () => {
const router = useRouter()
const { ref } = useParams()
+ const { hasLoaded } = useContext(FeatureFlagContext)
const { isEnabled: isUnifiedLogsEnabled } = useUnifiedLogsPreview()
const [lastVisitedLogsPage] = useLocalStorageQuery(
@@ -21,29 +22,29 @@ export const LogPage: NextPageWithLayout = () => {
)
useEffect(() => {
- if (!isUnifiedLogsEnabled) {
+ if (hasLoaded && !isUnifiedLogsEnabled) {
router.replace(`/project/${ref}/logs/${lastVisitedLogsPage}`)
}
- }, [router, lastVisitedLogsPage, ref, isUnifiedLogsEnabled])
+ }, [router, hasLoaded, lastVisitedLogsPage, ref, isUnifiedLogsEnabled])
// Handle redirects when unified logs preview flag changes
useEffect(() => {
// Only handle redirects if we're currently on a logs page
- if (!router.asPath.includes('/logs')) return
+ if (!router.asPath.includes('/logs') || !hasLoaded) return
if (isUnifiedLogsEnabled) {
// If unified logs preview is enabled and we're not already on the main logs page
if (router.asPath !== `/project/${ref}/logs` && router.asPath.includes('/logs/')) {
router.push(`/project/${ref}/logs`)
}
- } else if (!isUnifiedLogsEnabled) {
+ } else {
// If unified logs preview is disabled and admin flag is also off
// and we're on the main logs page, redirect to explorer
if (router.asPath === `/project/${ref}/logs`) {
router.push(`/project/${ref}/logs/explorer`)
}
}
- }, [isUnifiedLogsEnabled, router, ref])
+ }, [isUnifiedLogsEnabled, router, ref, hasLoaded])
if (isUnifiedLogsEnabled) {
return (