mirror of
https://github.com/AppFlowy-IO/AppFlowy-Web.git
synced 2025-11-29 19:08:33 +08:00
chore: remove skeleton
This commit is contained in:
@@ -3,9 +3,6 @@ import { ErrorBoundary } from 'react-error-boundary';
|
|||||||
|
|
||||||
import { useDatabaseViewsSelector } from '@/application/database-yjs';
|
import { useDatabaseViewsSelector } from '@/application/database-yjs';
|
||||||
import { DatabaseViewLayout, YjsDatabaseKey } from '@/application/types';
|
import { DatabaseViewLayout, YjsDatabaseKey } from '@/application/types';
|
||||||
import CalendarSkeleton from '@/components/_shared/skeleton/CalendarSkeleton';
|
|
||||||
import GridSkeleton from '@/components/_shared/skeleton/GridSkeleton';
|
|
||||||
import KanbanSkeleton from '@/components/_shared/skeleton/KanbanSkeleton';
|
|
||||||
import { Board } from '@/components/database/board';
|
import { Board } from '@/components/database/board';
|
||||||
import { DatabaseConditionsContext } from '@/components/database/components/conditions/context';
|
import { DatabaseConditionsContext } from '@/components/database/components/conditions/context';
|
||||||
import { DatabaseTabs } from '@/components/database/components/tabs';
|
import { DatabaseTabs } from '@/components/database/components/tabs';
|
||||||
@@ -112,22 +109,9 @@ function DatabaseViews({
|
|||||||
[fixedHeight, onChangeView]
|
[fixedHeight, onChangeView]
|
||||||
);
|
);
|
||||||
|
|
||||||
const skeleton = useMemo(() => {
|
|
||||||
switch (layout) {
|
|
||||||
case DatabaseViewLayout.Grid:
|
|
||||||
return <GridSkeleton includeTitle={false} includeTabs={false} />;
|
|
||||||
case DatabaseViewLayout.Board:
|
|
||||||
return <KanbanSkeleton includeTitle={false} includeTabs={false} />;
|
|
||||||
case DatabaseViewLayout.Calendar:
|
|
||||||
return <CalendarSkeleton includeTitle={false} includeTabs={false} />;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}, [layout]);
|
|
||||||
|
|
||||||
// Simple conditional rendering - Board's autoScrollForElements doesn't support keep-alive
|
|
||||||
const view = useMemo(() => {
|
const view = useMemo(() => {
|
||||||
if (isLoading) return skeleton;
|
if (isLoading) return null;
|
||||||
switch (layout) {
|
switch (layout) {
|
||||||
case DatabaseViewLayout.Grid:
|
case DatabaseViewLayout.Grid:
|
||||||
return <Grid />;
|
return <Grid />;
|
||||||
@@ -136,7 +120,7 @@ function DatabaseViews({
|
|||||||
case DatabaseViewLayout.Calendar:
|
case DatabaseViewLayout.Calendar:
|
||||||
return <Calendar />;
|
return <Calendar />;
|
||||||
}
|
}
|
||||||
}, [layout, isLoading, skeleton]);
|
}, [layout, isLoading]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLoading && viewContainerRef.current) {
|
if (!isLoading && viewContainerRef.current) {
|
||||||
@@ -279,7 +263,7 @@ function DatabaseViews({
|
|||||||
: {}
|
: {}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Suspense fallback={skeleton}>
|
<Suspense fallback={null}>
|
||||||
<ErrorBoundary fallbackRender={ElementFallbackRender}>{view}</ErrorBoundary>
|
<ErrorBoundary fallbackRender={ElementFallbackRender}>{view}</ErrorBoundary>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export enum RenderRowType {
|
|||||||
Row = 'row',
|
Row = 'row',
|
||||||
NewRow = 'new-row',
|
NewRow = 'new-row',
|
||||||
CalculateRow = 'calculate-row',
|
CalculateRow = 'calculate-row',
|
||||||
|
PlaceholderRow = 'placeholder-row',
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RenderRow = {
|
export type RenderRow = {
|
||||||
@@ -19,6 +20,18 @@ export function useRenderRows () {
|
|||||||
const readOnly = useReadOnly();
|
const readOnly = useReadOnly();
|
||||||
|
|
||||||
const renderRows = useMemo(() => {
|
const renderRows = useMemo(() => {
|
||||||
|
// If rows are still loading, show placeholder rows
|
||||||
|
if (rows === undefined) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: RenderRowType.Header,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: RenderRowType.CalculateRow,
|
||||||
|
},
|
||||||
|
].filter(Boolean) as RenderRow[];
|
||||||
|
}
|
||||||
|
|
||||||
const rowItems =
|
const rowItems =
|
||||||
rows?.map((row) => ({
|
rows?.map((row) => ({
|
||||||
type: RenderRowType.Row,
|
type: RenderRowType.Row,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
import { useDatabaseContext, useDatabaseViewId } from '@/application/database-yjs';
|
import { useDatabaseContext, useDatabaseViewId, useRowOrdersSelector } from '@/application/database-yjs';
|
||||||
import { useRenderFields } from '@/components/database/components/grid/grid-column';
|
import { useRenderFields } from '@/components/database/components/grid/grid-column';
|
||||||
import GridVirtualizer from '@/components/database/components/grid/grid-table/GridVirtualizer';
|
import GridVirtualizer from '@/components/database/components/grid/grid-table/GridVirtualizer';
|
||||||
import { GridProvider } from '@/components/database/grid/GridProvider';
|
import { GridProvider } from '@/components/database/grid/GridProvider';
|
||||||
@@ -8,14 +8,15 @@ import { GridProvider } from '@/components/database/grid/GridProvider';
|
|||||||
export function Grid() {
|
export function Grid() {
|
||||||
const { fields } = useRenderFields();
|
const { fields } = useRenderFields();
|
||||||
const viewId = useDatabaseViewId();
|
const viewId = useDatabaseViewId();
|
||||||
|
const rows = useRowOrdersSelector();
|
||||||
|
|
||||||
const { onRendered } = useDatabaseContext();
|
const { onRendered } = useDatabaseContext();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fields) {
|
if (fields && rows !== undefined) {
|
||||||
onRendered?.();
|
onRendered?.();
|
||||||
}
|
}
|
||||||
}, [fields, onRendered]);
|
}, [fields, rows, onRendered]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GridProvider>
|
<GridProvider>
|
||||||
|
|||||||
Reference in New Issue
Block a user