Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: dispose group controller

ascarbek96be3c6ebee6
diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useDatabase.ts b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useDatabase.ts
index 66e62977b7..13c9609ee3 100644
--- a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useDatabase.ts
+++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useDatabase.ts
@@ -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]);
diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.ts
index 2e482d089c..a9bfc66d75 100644
--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.ts
+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.ts
@@ -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();
diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/group/group_controller.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/group/group_controller.ts
index 3eeabc2534..ea500e64fe 100644
--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/group/group_controller.ts
+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/group/group_controller.ts
@@ -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';