fix: dispose group controller

This commit is contained in:
ascarbek 2023-03-15 20:19:09 +06:00
parent 1d6f74180f
commit 96be3c6ebe
3 changed files with 9 additions and 13 deletions

View File

@ -1,10 +1,10 @@
import { useEffect, useState } from 'react';
import { DatabaseController } from '../../../stores/effects/database/database_controller';
import { databaseActions, DatabaseFieldMap, IDatabaseColumn } from '../../../stores/reducers/database/slice';
import { useAppDispatch } from '../../../stores/store';
import { DatabaseController } from '$app/stores/effects/database/database_controller';
import { databaseActions, DatabaseFieldMap, IDatabaseColumn } from '$app/stores/reducers/database/slice';
import { useAppDispatch } from '$app/stores/store';
import loadField from './loadField';
import { FieldInfo } from '../../../stores/effects/database/field/field_controller';
import { RowInfo } from '../../../stores/effects/database/row/row_cache';
import { FieldInfo } from '$app/stores/effects/database/field/field_controller';
import { RowInfo } from '$app/stores/effects/database/row/row_cache';
import { ViewLayoutTypePB } from '@/services/backend';
import { DatabaseGroupController } from '$app/stores/effects/database/group/group_controller';
@ -19,7 +19,6 @@ export const useDatabase = (viewId: string, type?: ViewLayoutTypePB) => {
const c = new DatabaseController(viewId);
setController(c);
// dispose is causing an error
return () => void c.dispose();
}, [viewId]);

View File

@ -146,6 +146,9 @@ export class DatabaseController {
};
dispose = async () => {
this.groups.value.forEach((group) => {
void group.dispose();
});
await this.backendService.closeDatabase();
await this.fieldController.dispose();
await this.databaseViewCache.dispose();

View File

@ -1,10 +1,4 @@
import {
DatabaseNotification,
FlowyError,
GroupPB,
GroupRowsNotificationPB,
RowPB,
} from '@/services/backend';
import { DatabaseNotification, FlowyError, GroupPB, GroupRowsNotificationPB, RowPB } from '@/services/backend';
import { ChangeNotifier } from '$app/utils/change_notifier';
import { None, Ok, Option, Result, Some } from 'ts-results';
import { DatabaseNotificationObserver } from '../notifications/observer';