mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: can not display rows when rows overthan 1000 (#5777)
This commit is contained in:
parent
a8b4f22703
commit
864768b3ba
@ -12,7 +12,6 @@ import {
|
|||||||
useDatabase,
|
useDatabase,
|
||||||
useDatabaseFields,
|
useDatabaseFields,
|
||||||
useDatabaseView,
|
useDatabaseView,
|
||||||
useIsDatabaseRowPage,
|
|
||||||
useRowDocMap,
|
useRowDocMap,
|
||||||
useViewId,
|
useViewId,
|
||||||
} from '@/application/database-yjs/context';
|
} from '@/application/database-yjs/context';
|
||||||
@ -434,7 +433,6 @@ export function useRowsByGroup(groupId: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useRowOrdersSelector() {
|
export function useRowOrdersSelector() {
|
||||||
const isDatabaseRowPage = useIsDatabaseRowPage();
|
|
||||||
const { rows, clock } = useRowDocMapSelector();
|
const { rows, clock } = useRowDocMapSelector();
|
||||||
const [rowOrders, setRowOrders] = useState<Row[]>();
|
const [rowOrders, setRowOrders] = useState<Row[]>();
|
||||||
const view = useDatabaseView();
|
const view = useDatabaseView();
|
||||||
@ -446,7 +444,6 @@ export function useRowOrdersSelector() {
|
|||||||
|
|
||||||
if (!originalRowOrders || !rows) return;
|
if (!originalRowOrders || !rows) return;
|
||||||
|
|
||||||
if (originalRowOrders.length > rows.size && !isDatabaseRowPage) return;
|
|
||||||
if (sorts?.length === 0 && filters?.length === 0) {
|
if (sorts?.length === 0 && filters?.length === 0) {
|
||||||
setRowOrders(originalRowOrders);
|
setRowOrders(originalRowOrders);
|
||||||
return;
|
return;
|
||||||
@ -467,7 +464,7 @@ export function useRowOrdersSelector() {
|
|||||||
} else {
|
} else {
|
||||||
setRowOrders(originalRowOrders);
|
setRowOrders(originalRowOrders);
|
||||||
}
|
}
|
||||||
}, [fields, filters, rows, sorts, view, isDatabaseRowPage]);
|
}, [fields, filters, rows, sorts, view]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onConditionsChange();
|
onConditionsChange();
|
||||||
|
@ -12,7 +12,7 @@ import {
|
|||||||
import { applyYDoc } from '@/application/ydoc/apply';
|
import { applyYDoc } from '@/application/ydoc/apply';
|
||||||
import { closeCollabDB, db, openCollabDB } from '@/application/db';
|
import { closeCollabDB, db, openCollabDB } from '@/application/db';
|
||||||
import { Fetcher, StrategyType } from '@/application/services/js-services/cache/types';
|
import { Fetcher, StrategyType } from '@/application/services/js-services/cache/types';
|
||||||
import { IndexeddbPersistence } from 'y-indexeddb';
|
// import { IndexeddbPersistence } from 'y-indexeddb';
|
||||||
import * as Y from 'yjs';
|
import * as Y from 'yjs';
|
||||||
|
|
||||||
export function collabTypeToDBType(type: CollabType) {
|
export function collabTypeToDBType(type: CollabType) {
|
||||||
@ -139,19 +139,19 @@ export async function getPublishView<
|
|||||||
const doc = await openCollabDB(name);
|
const doc = await openCollabDB(name);
|
||||||
const rowMapDoc = (await openCollabDB(`${name}_rows`)) as Y.Doc;
|
const rowMapDoc = (await openCollabDB(`${name}_rows`)) as Y.Doc;
|
||||||
|
|
||||||
const subdocs = Array.from(rowMapDoc.getSubdocs());
|
// const subdocs = Array.from(rowMapDoc.getSubdocs());
|
||||||
|
//
|
||||||
for (const subdoc of subdocs) {
|
// for (const subdoc of subdocs) {
|
||||||
const promise = new Promise((resolve) => {
|
// const promise = new Promise((resolve) => {
|
||||||
const persistence = new IndexeddbPersistence(subdoc.guid, subdoc);
|
// const persistence = new IndexeddbPersistence(subdoc.guid, subdoc);
|
||||||
|
//
|
||||||
persistence.on('synced', () => {
|
// persistence.on('synced', () => {
|
||||||
resolve(true);
|
// resolve(true);
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
await promise;
|
// await promise;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const exist = (await hasViewMetaCache(name)) && hasCollabCache(doc);
|
const exist = (await hasViewMetaCache(name)) && hasCollabCache(doc);
|
||||||
|
|
||||||
@ -245,14 +245,21 @@ export async function revalidatePublishView<
|
|||||||
const subdoc = new Y.Doc({
|
const subdoc = new Y.Doc({
|
||||||
guid: key,
|
guid: key,
|
||||||
});
|
});
|
||||||
const persistence = new IndexeddbPersistence(subdoc.guid, subdoc);
|
|
||||||
|
|
||||||
persistence.on('synced', () => {
|
applyYDoc(subdoc, new Uint8Array(value));
|
||||||
applyYDoc(subdoc, new Uint8Array(value));
|
rowMapDoc.getMap().delete(subdoc.guid);
|
||||||
rowMapDoc.getMap().delete(subdoc.guid);
|
rowMapDoc.getMap().set(subdoc.guid, subdoc);
|
||||||
rowMapDoc.getMap().set(subdoc.guid, subdoc);
|
|
||||||
});
|
// const persistence = new IndexeddbPersistence(subdoc.guid, subdoc);
|
||||||
|
//
|
||||||
|
// persistence.on('synced', () => {
|
||||||
|
// applyYDoc(subdoc, new Uint8Array(value));
|
||||||
|
// rowMapDoc.getMap().delete(subdoc.guid);
|
||||||
|
// rowMapDoc.getMap().set(subdoc.guid, subdoc);
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('rows', rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = new Uint8Array(data);
|
const state = new Uint8Array(data);
|
||||||
@ -268,15 +275,15 @@ export async function deleteView(name: string) {
|
|||||||
console.log('deleteView', name);
|
console.log('deleteView', name);
|
||||||
await deleteViewMeta(name);
|
await deleteViewMeta(name);
|
||||||
await closeCollabDB(name);
|
await closeCollabDB(name);
|
||||||
const rowMapDoc = (await openCollabDB(`${name}_rows`)) as Y.Doc;
|
// const rowMapDoc = (await openCollabDB(`${name}_rows`)) as Y.Doc;
|
||||||
|
//
|
||||||
const subdocs = Array.from(rowMapDoc.getSubdocs());
|
// const subdocs = Array.from(rowMapDoc.getSubdocs());
|
||||||
|
//
|
||||||
for (const subdoc of subdocs) {
|
// for (const subdoc of subdocs) {
|
||||||
const persistence = new IndexeddbPersistence(subdoc.guid, subdoc);
|
// const persistence = new IndexeddbPersistence(subdoc.guid, subdoc);
|
||||||
|
//
|
||||||
await persistence.destroy();
|
// await persistence.destroy();
|
||||||
}
|
// }
|
||||||
|
|
||||||
await closeCollabDB(`${name}_rows`);
|
await closeCollabDB(`${name}_rows`);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ export class AFClientService implements AFService {
|
|||||||
|
|
||||||
private cacheDatabaseRowDocMap: Map<string, Y.Doc> = new Map();
|
private cacheDatabaseRowDocMap: Map<string, Y.Doc> = new Map();
|
||||||
|
|
||||||
|
private cacheDatabaseRowFolder: Map<string, Y.Map<YDoc>> = new Map();
|
||||||
|
|
||||||
constructor(config: AFServiceConfig) {
|
constructor(config: AFServiceConfig) {
|
||||||
initAPIService({
|
initAPIService({
|
||||||
...config.cloudConfig,
|
...config.cloudConfig,
|
||||||
@ -122,11 +124,18 @@ export class AFClientService implements AFService {
|
|||||||
return Promise.reject(new Error('Root rows doc not found'));
|
return Promise.reject(new Error('Root rows doc not found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const rowsFolder: Y.Map<YDoc> = rootRowsDoc.getMap();
|
if (!this.cacheDatabaseRowFolder.has(name)) {
|
||||||
|
const rowsFolder: Y.Map<YDoc> = rootRowsDoc.getMap();
|
||||||
|
|
||||||
|
this.cacheDatabaseRowFolder.set(name, rowsFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
const rowsFolder = this.cacheDatabaseRowFolder.get(name)!;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rows: rowsFolder,
|
rows: rowsFolder,
|
||||||
destroy: () => {
|
destroy: () => {
|
||||||
|
this.cacheDatabaseRowFolder.delete(name);
|
||||||
this.cacheDatabaseRowDocMap.delete(name);
|
this.cacheDatabaseRowDocMap.delete(name);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user