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,
|
||||
useDatabaseFields,
|
||||
useDatabaseView,
|
||||
useIsDatabaseRowPage,
|
||||
useRowDocMap,
|
||||
useViewId,
|
||||
} from '@/application/database-yjs/context';
|
||||
@ -434,7 +433,6 @@ export function useRowsByGroup(groupId: string) {
|
||||
}
|
||||
|
||||
export function useRowOrdersSelector() {
|
||||
const isDatabaseRowPage = useIsDatabaseRowPage();
|
||||
const { rows, clock } = useRowDocMapSelector();
|
||||
const [rowOrders, setRowOrders] = useState<Row[]>();
|
||||
const view = useDatabaseView();
|
||||
@ -446,7 +444,6 @@ export function useRowOrdersSelector() {
|
||||
|
||||
if (!originalRowOrders || !rows) return;
|
||||
|
||||
if (originalRowOrders.length > rows.size && !isDatabaseRowPage) return;
|
||||
if (sorts?.length === 0 && filters?.length === 0) {
|
||||
setRowOrders(originalRowOrders);
|
||||
return;
|
||||
@ -467,7 +464,7 @@ export function useRowOrdersSelector() {
|
||||
} else {
|
||||
setRowOrders(originalRowOrders);
|
||||
}
|
||||
}, [fields, filters, rows, sorts, view, isDatabaseRowPage]);
|
||||
}, [fields, filters, rows, sorts, view]);
|
||||
|
||||
useEffect(() => {
|
||||
onConditionsChange();
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
import { applyYDoc } from '@/application/ydoc/apply';
|
||||
import { closeCollabDB, db, openCollabDB } from '@/application/db';
|
||||
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';
|
||||
|
||||
export function collabTypeToDBType(type: CollabType) {
|
||||
@ -139,19 +139,19 @@ export async function getPublishView<
|
||||
const doc = await openCollabDB(name);
|
||||
const rowMapDoc = (await openCollabDB(`${name}_rows`)) as Y.Doc;
|
||||
|
||||
const subdocs = Array.from(rowMapDoc.getSubdocs());
|
||||
|
||||
for (const subdoc of subdocs) {
|
||||
const promise = new Promise((resolve) => {
|
||||
const persistence = new IndexeddbPersistence(subdoc.guid, subdoc);
|
||||
|
||||
persistence.on('synced', () => {
|
||||
resolve(true);
|
||||
});
|
||||
});
|
||||
|
||||
await promise;
|
||||
}
|
||||
// const subdocs = Array.from(rowMapDoc.getSubdocs());
|
||||
//
|
||||
// for (const subdoc of subdocs) {
|
||||
// const promise = new Promise((resolve) => {
|
||||
// const persistence = new IndexeddbPersistence(subdoc.guid, subdoc);
|
||||
//
|
||||
// persistence.on('synced', () => {
|
||||
// resolve(true);
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// await promise;
|
||||
// }
|
||||
|
||||
const exist = (await hasViewMetaCache(name)) && hasCollabCache(doc);
|
||||
|
||||
@ -245,14 +245,21 @@ export async function revalidatePublishView<
|
||||
const subdoc = new Y.Doc({
|
||||
guid: key,
|
||||
});
|
||||
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);
|
||||
});
|
||||
|
||||
// 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);
|
||||
@ -268,15 +275,15 @@ export async function deleteView(name: string) {
|
||||
console.log('deleteView', name);
|
||||
await deleteViewMeta(name);
|
||||
await closeCollabDB(name);
|
||||
const rowMapDoc = (await openCollabDB(`${name}_rows`)) as Y.Doc;
|
||||
|
||||
const subdocs = Array.from(rowMapDoc.getSubdocs());
|
||||
|
||||
for (const subdoc of subdocs) {
|
||||
const persistence = new IndexeddbPersistence(subdoc.guid, subdoc);
|
||||
|
||||
await persistence.destroy();
|
||||
}
|
||||
// const rowMapDoc = (await openCollabDB(`${name}_rows`)) as Y.Doc;
|
||||
//
|
||||
// const subdocs = Array.from(rowMapDoc.getSubdocs());
|
||||
//
|
||||
// for (const subdoc of subdocs) {
|
||||
// const persistence = new IndexeddbPersistence(subdoc.guid, subdoc);
|
||||
//
|
||||
// await persistence.destroy();
|
||||
// }
|
||||
|
||||
await closeCollabDB(`${name}_rows`);
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ export class AFClientService implements AFService {
|
||||
|
||||
private cacheDatabaseRowDocMap: Map<string, Y.Doc> = new Map();
|
||||
|
||||
private cacheDatabaseRowFolder: Map<string, Y.Map<YDoc>> = new Map();
|
||||
|
||||
constructor(config: AFServiceConfig) {
|
||||
initAPIService({
|
||||
...config.cloudConfig,
|
||||
@ -122,11 +124,18 @@ export class AFClientService implements AFService {
|
||||
return Promise.reject(new Error('Root rows doc not found'));
|
||||
}
|
||||
|
||||
if (!this.cacheDatabaseRowFolder.has(name)) {
|
||||
const rowsFolder: Y.Map<YDoc> = rootRowsDoc.getMap();
|
||||
|
||||
this.cacheDatabaseRowFolder.set(name, rowsFolder);
|
||||
}
|
||||
|
||||
const rowsFolder = this.cacheDatabaseRowFolder.get(name)!;
|
||||
|
||||
return {
|
||||
rows: rowsFolder,
|
||||
destroy: () => {
|
||||
this.cacheDatabaseRowFolder.delete(name);
|
||||
this.cacheDatabaseRowDocMap.delete(name);
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user