The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: Remove flashes when listing the tables in the Table Editor (#20344)
Ivan Vasilov8e1bfc95828d
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsxindex 9eafab5e39f..2557ef355fb 100644--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx@@ -7,24 +7,22 @@ import { useInView } from 'react-intersection-observer'import { Button, IconArchive, IconExternalLink } from 'ui'import { Markdown } from 'components/interfaces/Markdown'+import { ItemRenderer } from 'components/ui/InfiniteList'import { Notification, NotificationData } from 'data/notifications/notifications-v2-query'-import { Project } from 'data/projects/project-detail-query'+import { ProjectInfo } from 'data/projects/projects-query'+import { ArchiveRestoreIcon } from 'lucide-react'import { Organization } from 'types'import { CriticalIcon, WarningIcon } from './NotificationsPopover.constants'-import { ArchiveRestoreIcon } from 'lucide-react'interface NotificationRowProps {- index: number- listRef: any- item: NotificationsetRowHeight: (idx: number, height: number) => void- getProject: (ref: string) => Project+ getProject: (ref: string) => ProjectInfogetOrganization: (id: number) => OrganizationonUpdateNotificationStatus: (id: string, status: 'archived' | 'seen') => voidqueueMarkRead: (id: string) => void}-const NotificationRow = ({+const NotificationRow: ItemRenderer<Notification, NotificationRowProps> = ({index,listRef,item: notification,@@ -33,7 +31,7 @@ const NotificationRow = ({getOrganization,onUpdateNotificationStatus,queueMarkRead,-}: NotificationRowProps) => {+}) => {const ref = useRef<HTMLDivElement>(null)const { ref: viewRef, inView } = useInView()const { status, priority } = notification@@ -53,7 +51,7 @@ const NotificationRow = ({useEffect(() => {if (ref.current) {- listRef.current.resetAfterIndex(0)+ listRef?.current?.resetAfterIndex(0)setRowHeight(index, ref.current.clientHeight)}}, [ref])diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsxindex a6acb360aca..f2f89535ba2 100644--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx@@ -1,5 +1,6 @@import clsx from 'clsx'import { useMemo, useRef, useState } from 'react'+import toast from 'react-hot-toast'import {Button,IconArchive,@@ -13,6 +14,7 @@ import {import AlertError from 'components/ui/AlertError'import InfiniteList from 'components/ui/InfiniteList'import ShimmeringLoader, { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'+import { useNotificationsArchiveAllMutation } from 'data/notifications/notifications-v2-archive-all-mutation'import { useNotificationsV2Query } from 'data/notifications/notifications-v2-query'import { useNotificationsSummaryQuery } from 'data/notifications/notifications-v2-summary-query'import { useNotificationsV2UpdateMutation } from 'data/notifications/notifications-v2-update-mutation'@@ -22,8 +24,6 @@ import { useNotificationsStateSnapshot } from 'state/notifications'import NotificationRow from './NotificationRow'import { NotificationsFilter } from './NotificationsFilter'import { CriticalIcon, WarningIcon } from './NotificationsPopover.constants'-import { useNotificationsArchiveAllMutation } from 'data/notifications/notifications-v2-archive-all-mutation'-import toast from 'react-hot-toast'const NotificationsPopoverV2 = () => {const [open, setOpen] = useState(false)@@ -197,8 +197,9 @@ const NotificationsPopoverV2 = () => {rowHeights.current = { ...rowHeights.current, [idx]: height }}},- getProject: (ref: string) => projects?.find((project) => project.ref === ref),- getOrganization: (id: number) => organizations?.find((org) => org.id === id),+ getProject: (ref: string) =>+ projects?.find((project) => project.ref === ref)!,+ getOrganization: (id: number) => organizations?.find((org) => org.id === id)!,onUpdateNotificationStatus: (id: string, status: 'archived' | 'seen') => {updateNotifications({ ids: [id], status })},diff --git a/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx b/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsxindex 90e53f7e37e..f63df7608b1 100644--- a/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx+++ b/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx@@ -18,7 +18,9 @@ import {IconTrash,} from 'ui'+import { IS_PLATFORM } from 'common'import { parseSupaTable } from 'components/grid'+import { ItemRenderer } from 'components/ui/InfiniteList'import { ENTITY_TYPE } from 'data/entity-types/entity-type-constants'import { Entity } from 'data/entity-types/entity-type-query'import { fetchAllTableRows } from 'data/table-rows/table-rows-query'@@ -27,18 +29,21 @@ import { useStore } from 'hooks'import { BASE_PATH } from 'lib/constants'import { useTableEditorStateSnapshot } from 'state/table-editor'import { useProjectContext } from '../ProjectLayout/ProjectContext'-import { IS_PLATFORM } from 'common'export interface EntityListItemProps {id: numberprojectRef: string- item: EntityisLocked: boolean}const svgLoader = <span className="block w-4 h-4 bg-[#133929] rounded-sm" />-const EntityListItem = ({ id, projectRef, item: entity, isLocked }: EntityListItemProps) => {+const EntityListItem: ItemRenderer<Entity, EntityListItemProps> = ({+ id,+ projectRef,+ item: entity,+ isLocked,+}) => {const { ui } = useStore()const { project } = useProjectContext()const snap = useTableEditorStateSnapshot()diff --git a/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx b/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsxindex 23bf135501e..7dc7d25979b 100644--- a/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx+++ b/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx@@ -292,8 +292,9 @@ const TableEditorMenu = () => {items={entityTypes}ItemComponent={EntityListItem}itemProps={{- projectRef: project?.ref,+ projectRef: project?.ref!,id: Number(id),+ isLocked,}}getItemSize={() => 28}hasNextPage={hasNextPage}diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsxindex 0a3b61101e2..f8cc0459e10 100644--- a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx+++ b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx@@ -10,9 +10,9 @@ import {DropdownMenuItem,DropdownMenuPortal,DropdownMenuSeparator,+ DropdownMenuSub,DropdownMenuSubContent,DropdownMenuSubTrigger,- DropdownMenuSub,DropdownMenuTrigger,IconAlertCircle,IconClipboard,@@ -28,6 +28,7 @@ import {IconTrash2,} from 'ui'+import { ItemRenderer } from 'components/ui/InfiniteList'import { useCheckPermissions } from 'hooks'import { BASE_PATH } from 'lib/constants'import { formatBytes } from 'lib/helpers'@@ -80,8 +81,6 @@ export const RowIcon = ({ view, status, fileType, mimeType }: any) => {}export interface FileExplorerRowProps {- index: number- item: anyview: stringcolumnIndex: numberselectedItems: any[]@@ -90,7 +89,7 @@ export interface FileExplorerRowProps {onCopyUrl: (name: string, url: string) => void}-const FileExplorerRow = ({+const FileExplorerRow: ItemRenderer<any, FileExplorerRowProps> = ({index: itemIndex,item = {},view = STORAGE_VIEWS.COLUMNS,@@ -99,7 +98,7 @@ const FileExplorerRow = ({openedFolders = [],selectedFilePreview = {},onCopyUrl,-}: FileExplorerRowProps) => {+}) => {const storageExplorerStore = useStorageStore()const {getFileUrl,diff --git a/apps/studio/components/ui/InfiniteList.tsx b/apps/studio/components/ui/InfiniteList.tsxindex bf5670a05b2..5d318a97bcd 100644--- a/apps/studio/components/ui/InfiniteList.tsx+++ b/apps/studio/components/ui/InfiniteList.tsx@@ -1,5 +1,5 @@import memoize from 'memoize-one'-import { CSSProperties, ReactNode, memo, useRef } from 'react'+import { CSSProperties, ComponentType, MutableRefObject, ReactNode, memo, useRef } from 'react'import AutoSizer from 'react-virtualized-auto-sizer'import { VariableSizeList, areEqual } from 'react-window'import InfiniteLoader from 'react-window-infinite-loader'@@ -15,28 +15,39 @@ import { propsAreEqual } from 'lib/helpers'const createItemData = memoize((items, itemProps) => ({ items, ...itemProps }))-export interface ItemProps {- data: any- listRef: any+export type ItemRenderer<T, P> = ComponentType<+ {+ item: T+ listRef: MutableRefObject<VariableSizeList<any> | null | undefined>+ index: number+ } & P+>++export interface ItemProps<T, P> {+ data: {+ items: T[]+ itemProps: P+ ItemComponent: ItemRenderer<T, P>+ listRef: MutableRefObject<VariableSizeList<any> | null | undefined>+ LoaderComponent?: ReactNode+ }index: numberstyle: CSSProperties- LoaderComponent?: ReactNode}-export interface InfiniteListProps<T> {+export interface InfiniteListProps<T, P> {items?: T[]- itemProps?: any+ itemProps?: PhasNextPage?: booleanisLoadingNextPage?: booleangetItemSize?: (index: number) => numberonLoadNextPage?: () => void- ItemComponent?: any+ ItemComponent?: ItemRenderer<T, P>LoaderComponent?: ReactNode}-// eslint-disable-next-line react/display-name-const Item = memo(({ listRef, LoaderComponent, data, index, style }: ItemProps) => {- const { items, itemProps, ItemComponent } = data+const Item = memo(<T, P>({ data, index, style }: ItemProps<T, P>) => {+ const { items, itemProps, ItemComponent, listRef, LoaderComponent } = dataconst item = index < items.length ? items[index] : undefinedreturn item ? (@@ -54,17 +65,19 @@ const Item = memo(({ listRef, LoaderComponent, data, index, style }: ItemProps))}, areEqual)-function InfiniteList<T>({+Item.displayName = 'Item'++function InfiniteList<T, P>({items = [],- itemProps = {},+ itemProps,hasNextPage = false,isLoadingNextPage = false,getItemSize = () => 40,onLoadNextPage = () => {},ItemComponent = () => null,LoaderComponent,-}: InfiniteListProps<T>) {- const listRef = useRef<any>()+}: InfiniteListProps<T, P>) {+ const listRef = useRef<VariableSizeList<any> | null>()// Only load 1 page of items at a time// Pass an empty callback to InfiniteLoader in case it asks to load more than once@@ -76,7 +89,7 @@ function InfiniteList<T>({}const itemCount = hasNextPage ? items.length + 1 : items.length- const itemData = createItemData(items, { itemProps, ItemComponent })+ const itemData = createItemData(items, { itemProps, ItemComponent, LoaderComponent, listRef })return (<div className="relative flex flex-col flex-grow">@@ -101,9 +114,7 @@ function InfiniteList<T>({itemSize={getItemSize}onItemsRendered={onItemsRendered}>- {(props) => (- <Item listRef={listRef} LoaderComponent={LoaderComponent} {...props} />- )}+ {Item}</VariableSizeList>)}</InfiniteLoader>@@ -124,4 +135,5 @@ function InfiniteList<T>({)}-export default memo(InfiniteList, propsAreEqual)+// memo erases generics so this magic is needed+export default memo(InfiniteList, propsAreEqual) as typeof InfiniteList