diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx index 5c76070c05b..b26848d2eab 100644 --- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx +++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx @@ -39,10 +39,14 @@ export const FeaturePreviewContextProvider = ({ children }: PropsWithChildren<{} setFlags( featurePreviews.reduce((a, b) => { const defaultOptIn = b.isDefaultOptIn - const localStorageValue = localStorage.getItem(b.key) - return { - ...a, - [b.key]: !localStorageValue ? defaultOptIn : localStorageValue === 'true', + try { + const localStorageValue = window.localStorage.getItem(b.key) + return { + ...a, + [b.key]: !localStorageValue ? defaultOptIn : localStorageValue === 'true', + } + } catch { + return { ...a, [b.key]: defaultOptIn } } }, {}) ) @@ -57,8 +61,12 @@ export const FeaturePreviewContextProvider = ({ children }: PropsWithChildren<{} const value = { flags, onUpdateFlag: (key: string, value: boolean) => { - if (typeof window !== 'undefined') { - window.localStorage.setItem(key, value.toString()) + try { + if (typeof window !== 'undefined' && window.localStorage) { + window.localStorage.setItem(key, value ? 'true' : 'false') + } + } catch { + // Silently fail in restricted storage modes (e.g. Safari private browsing) } const updatedFlags = { ...flags, [key]: value } setFlags(updatedFlags) diff --git a/apps/studio/components/layouts/AppLayout/AdvisorButton.tsx b/apps/studio/components/layouts/AppLayout/AdvisorButton.tsx index a5f6f05b170..24783838552 100644 --- a/apps/studio/components/layouts/AppLayout/AdvisorButton.tsx +++ b/apps/studio/components/layouts/AppLayout/AdvisorButton.tsx @@ -20,8 +20,8 @@ export const AdvisorButton = ({ projectRef }: { projectRef?: string }) => { const notifications = useMemo(() => { return notificationsData?.pages.flatMap((page) => page) ?? [] }, [notificationsData?.pages]) - const hasUnreadNotifications = notifications.some((x) => x.status === 'new') - const hasCriticalNotifications = notifications.some((x) => x.priority === 'Critical') + const hasUnreadNotifications = notifications.some((x) => x?.status === 'new') + const hasCriticalNotifications = notifications.some((x) => x?.priority === 'Critical') const hasCriticalIssues = hasCriticalNotifications || diff --git a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorNav.tsx b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorNav.tsx index 06d86694a9f..39d0910630f 100644 --- a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorNav.tsx +++ b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorNav.tsx @@ -171,6 +171,16 @@ export const SQLEditorNav = ({ sort = 'inserted_at' }: SQLEditorNavProps) => { [folders, privateSnippets] ) + const privateSnippetsTreeNodeIds = useMemo( + () => new Set(privateSnippetsTreeState.map((node) => node.id.toString())), + [privateSnippetsTreeState] + ) + + const validExpandedFolderIds = useMemo( + () => expandedFolderIds.filter((id) => privateSnippetsTreeNodeIds.has(id)), + [expandedFolderIds, privateSnippetsTreeNodeIds] + ) + const privateSnippetsLastItemIds = useMemo( () => getLastItemIds(privateSnippetsTreeState), [privateSnippetsTreeState] @@ -644,7 +654,7 @@ export const SQLEditorNav = ({ sort = 'inserted_at' }: SQLEditorNavProps) => { setExpandedFolderIds(expandedFolderIds.filter((x) => x !== folderId)) } }} - expandedIds={expandedFolderIds} + expandedIds={validExpandedFolderIds} nodeRenderer={({ element, ...props }) => { const isOpened = Object.values(tabs.tabsMap).some( (tab) => tab.metadata?.sqlId === element.metadata?.id diff --git a/apps/studio/hooks/branches/useEdgeFunctionsDiff.ts b/apps/studio/hooks/branches/useEdgeFunctionsDiff.ts index a785c080ec9..d663866fba4 100644 --- a/apps/studio/hooks/branches/useEdgeFunctionsDiff.ts +++ b/apps/studio/hooks/branches/useEdgeFunctionsDiff.ts @@ -11,7 +11,6 @@ import { type EdgeFunctionsData, } from '@/data/edge-functions/edge-functions-query' import { edgeFunctionsKeys } from '@/data/edge-functions/keys' -import { handleError } from '@/data/fetchers' interface UseEdgeFunctionsDiffProps { currentBranchRef?: string @@ -163,18 +162,6 @@ export const useEdgeFunctionsDiff = ({ isCurrentFunctionsLoading || isMainFunctionsLoading - // Aggregate errors across all queries and handle the first encountered error. - const firstError = [ - ...currentBodiesQueries, - ...mainBodiesQueries, - ...addedBodiesQueries, - ...removedBodiesQueries, - ].find((q) => q.error)?.error - - if (firstError) { - handleError(firstError) - } - // Build lookup maps -------------------------------------------------------- const currentBodiesMap: Record = {} currentBodiesQueries.forEach((q, idx) => {