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.

chore: fix database filter (#6094)

Nathan.fooo9a295daf99a6
diff --git a/frontend/appflowy_flutter/lib/plugins/database/application/row/row_cache.dart b/frontend/appflowy_flutter/lib/plugins/database/application/row/row_cache.dart
index 1d11185a54..4d9f594471 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/application/row/row_cache.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/application/row/row_cache.dart
@@ -55,6 +55,8 @@ class RowCache {
final RowLifeCycle _rowLifeCycle;
final RowFieldsDelegate _fieldDelegate;
RowChangesetNotifier? _changedNotifier;
+ bool _isInitialRows = false;
+ final List<RowsVisibilityChangePB> _pendingVisibilityChanges = [];
/// Returns a unmodifiable list of RowInfo
UnmodifiableListView<RowInfo> get rowInfos {
@@ -80,7 +82,13 @@ class RowCache {
final rowInfo = buildGridRow(row);
_rowList.add(rowInfo);
}
+ _isInitialRows = true;
_changedNotifier?.receive(const ChangedReason.setInitialRows());
+
+ for (final changeset in _pendingVisibilityChanges) {
+ applyRowsVisibility(changeset);
+ }
+ _pendingVisibilityChanges.clear();
}
void setRowMeta(RowMetaPB rowMeta) {
@@ -103,8 +111,12 @@ class RowCache {
}
void applyRowsVisibility(RowsVisibilityChangePB changeset) {
- _hideRows(changeset.invisibleRows);
- _showRows(changeset.visibleRows);
+ if (_isInitialRows) {
+ _hideRows(changeset.invisibleRows);
+ _showRows(changeset.visibleRows);
+ } else {
+ _pendingVisibilityChanges.add(changeset);
+ }
}
void reorderAllRows(List<String> rowIds) {
diff --git a/frontend/appflowy_flutter/lib/plugins/database/board/application/board_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database/board/application/board_bloc.dart
index 0fa07a69c8..24926531b7 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/board/application/board_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/board/application/board_bloc.dart
@@ -202,11 +202,18 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
);
},
endEditingHeader: (String groupId, String? groupName) async {
- await groupBackendSvc.updateGroup(
- fieldId: groupControllers.values.first.group.fieldId,
- groupId: groupId,
- name: groupName,
- );
+ final group = groupControllers[groupId]?.group;
+ if (group != null) {
+ if (generateGroupNameFromGroup(group) != groupName) {
+ await groupBackendSvc.updateGroup(
+ fieldId: groupControllers.values.first.group.fieldId,
+ groupId: groupId,
+ name: groupName,
+ );
+ return;
+ }
+ }
+
state.maybeMap(
ready: (state) => emit(state.copyWith(editingHeaderId: null)),
orElse: () {},
diff --git a/frontend/appflowy_flutter/lib/plugins/database/board/presentation/board_page.dart b/frontend/appflowy_flutter/lib/plugins/database/board/presentation/board_page.dart
index fc258acd11..49c7517372 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/board/presentation/board_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/board/presentation/board_page.dart
@@ -556,10 +556,8 @@ class _BoardCardState extends State<_BoardCard> {
@override
Widget build(BuildContext context) {
final boardBloc = context.read<BoardBloc>();
-
final groupData = widget.afGroupData.customData as GroupData;
final rowCache = boardBloc.rowCache;
-
final databaseController = boardBloc.databaseController;
final rowMeta =
rowCache.getRow(widget.groupItem.id)?.rowMeta ?? widget.groupItem.row;
diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lock
index 4b8421d9c3..f3fdd16d6a 100644
--- a/frontend/appflowy_tauri/src-tauri/Cargo.lock
+++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock
@@ -172,7 +172,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]]
name = "app-error"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bincode",
@@ -192,7 +192,7 @@ dependencies = [
[[package]]
name = "appflowy-ai-client"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bytes",
@@ -837,7 +837,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"again",
"anyhow",
@@ -888,7 +888,7 @@ dependencies = [
[[package]]
name = "client-api-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"collab-entity",
"collab-rt-entity",
@@ -901,7 +901,7 @@ dependencies = [
[[package]]
name = "client-websocket"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"futures-channel",
"futures-util",
@@ -1149,7 +1149,7 @@ dependencies = [
[[package]]
name = "collab-rt-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bincode",
@@ -1174,7 +1174,7 @@ dependencies = [
[[package]]
name = "collab-rt-protocol"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"async-trait",
@@ -1571,7 +1571,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"app-error",
@@ -3117,7 +3117,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"futures-util",
@@ -3134,7 +3134,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"app-error",
@@ -3566,7 +3566,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bytes",
@@ -6169,7 +6169,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"app-error",
diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.toml
index 32cf0aa188..f47bd7ae01 100644
--- a/frontend/appflowy_tauri/src-tauri/Cargo.toml
+++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml
@@ -53,7 +53,7 @@ collab-user = { version = "0.2" }
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "5badffc97b17984d5f25a178c0c5a477338039c4" }
+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "cccdf76116f41631daa5533b56238aec323684de" }
[dependencies]
serde_json.workspace = true
diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.lock b/frontend/appflowy_web_app/src-tauri/Cargo.lock
index f176748d1e..a3a4d98f60 100644
--- a/frontend/appflowy_web_app/src-tauri/Cargo.lock
+++ b/frontend/appflowy_web_app/src-tauri/Cargo.lock
@@ -163,7 +163,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]]
name = "app-error"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bincode",
@@ -183,7 +183,7 @@ dependencies = [
[[package]]
name = "appflowy-ai-client"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bytes",
@@ -811,7 +811,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"again",
"anyhow",
@@ -862,7 +862,7 @@ dependencies = [
[[package]]
name = "client-api-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"collab-entity",
"collab-rt-entity",
@@ -875,7 +875,7 @@ dependencies = [
[[package]]
name = "client-websocket"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"futures-channel",
"futures-util",
@@ -1132,7 +1132,7 @@ dependencies = [
[[package]]
name = "collab-rt-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bincode",
@@ -1157,7 +1157,7 @@ dependencies = [
[[package]]
name = "collab-rt-protocol"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"async-trait",
@@ -1561,7 +1561,7 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
[[package]]
name = "database-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"app-error",
@@ -3184,7 +3184,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"futures-util",
@@ -3201,7 +3201,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"app-error",
@@ -3638,7 +3638,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bytes",
@@ -6233,7 +6233,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"app-error",
diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.toml b/frontend/appflowy_web_app/src-tauri/Cargo.toml
index 588364dbfa..619395b2b2 100644
--- a/frontend/appflowy_web_app/src-tauri/Cargo.toml
+++ b/frontend/appflowy_web_app/src-tauri/Cargo.toml
@@ -52,7 +52,7 @@ collab-user = { version = "0.2" }
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "5badffc97b17984d5f25a178c0c5a477338039c4" }
+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "cccdf76116f41631daa5533b56238aec323684de" }
[dependencies]
serde_json.workspace = true
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock
index ea1cc43186..bbaa13656c 100644
--- a/frontend/rust-lib/Cargo.lock
+++ b/frontend/rust-lib/Cargo.lock
@@ -163,7 +163,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]]
name = "app-error"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bincode",
@@ -183,7 +183,7 @@ dependencies = [
[[package]]
name = "appflowy-ai-client"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bytes",
@@ -729,7 +729,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"again",
"anyhow",
@@ -780,7 +780,7 @@ dependencies = [
[[package]]
name = "client-api-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"collab-entity",
"collab-rt-entity",
@@ -793,7 +793,7 @@ dependencies = [
[[package]]
name = "client-websocket"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"futures-channel",
"futures-util",
@@ -1010,7 +1010,7 @@ dependencies = [
[[package]]
name = "collab-rt-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bincode",
@@ -1035,7 +1035,7 @@ dependencies = [
[[package]]
name = "collab-rt-protocol"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"async-trait",
@@ -1395,7 +1395,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"app-error",
@@ -2795,7 +2795,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"futures-util",
@@ -2812,7 +2812,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"app-error",
@@ -3177,7 +3177,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"bytes",
@@ -5377,7 +5377,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=5badffc97b17984d5f25a178c0c5a477338039c4#5badffc97b17984d5f25a178c0c5a477338039c4"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=cccdf76116f41631daa5533b56238aec323684de#cccdf76116f41631daa5533b56238aec323684de"
dependencies = [
"anyhow",
"app-error",
diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml
index 22e4d9cc70..e91bf6a66d 100644
--- a/frontend/rust-lib/Cargo.toml
+++ b/frontend/rust-lib/Cargo.toml
@@ -100,8 +100,8 @@ dashmap = "6.0.1"
# Run the script.add_workspace_members:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "5badffc97b17984d5f25a178c0c5a477338039c4" }
-client-api-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "5badffc97b17984d5f25a178c0c5a477338039c4" }
+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "cccdf76116f41631daa5533b56238aec323684de" }
+client-api-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "cccdf76116f41631daa5533b56238aec323684de" }
[profile.dev]
opt-level = 0
diff --git a/frontend/rust-lib/flowy-core/src/integrate/user.rs b/frontend/rust-lib/flowy-core/src/integrate/user.rs
index f382398e8f..a39ddb3945 100644
--- a/frontend/rust-lib/flowy-core/src/integrate/user.rs
+++ b/frontend/rust-lib/flowy-core/src/integrate/user.rs
@@ -38,6 +38,7 @@ impl UserStatusCallback for UserStatusCallbackImpl {
cloud_config: &Option<UserCloudConfig>,
user_workspace: &UserWorkspace,
_device_id: &str,
+ authenticator: &Authenticator,
) -> FlowyResult<()> {
self
.server_provider
@@ -64,7 +65,10 @@ impl UserStatusCallback for UserStatusCallbackImpl {
},
)
.await?;
- self.database_manager.initialize(user_id).await?;
+ self
+ .database_manager
+ .initialize(user_id, authenticator == &Authenticator::Local)
+ .await?;
self.document_manager.initialize(user_id).await?;
Ok(())
}
@@ -74,6 +78,7 @@ impl UserStatusCallback for UserStatusCallbackImpl {
user_id: i64,
user_workspace: &UserWorkspace,
device_id: &str,
+ authenticator: &Authenticator,
) -> FlowyResult<()> {
event!(
tracing::Level::TRACE,
@@ -86,7 +91,10 @@ impl UserStatusCallback for UserStatusCallbackImpl {
.folder_manager
.initialize_with_workspace_id(user_id)
.await?;
- self.database_manager.initialize(user_id).await?;
+ self
+ .database_manager
+ .initialize(user_id, authenticator.is_local())
+ .await?;
self.document_manager.initialize(user_id).await?;
Ok(())
}
@@ -97,6 +105,7 @@ impl UserStatusCallback for UserStatusCallbackImpl {
user_profile: &UserProfile,
user_workspace: &UserWorkspace,
device_id: &str,
+ authenticator: &Authenticator,
) -> FlowyResult<()> {
self
.server_provider
@@ -156,7 +165,7 @@ impl UserStatusCallback for UserStatusCallbackImpl {
self
.database_manager
- .initialize_with_new_user(user_profile.uid)
+ .initialize_with_new_user(user_profile.uid, authenticator.is_local())
.await
.context("DatabaseManager error")?;
@@ -173,12 +182,20 @@ impl UserStatusCallback for UserStatusCallbackImpl {
Ok(())
}
- async fn open_workspace(&self, user_id: i64, user_workspace: &UserWorkspace) -> FlowyResult<()> {
+ async fn open_workspace(
+ &self,
+ user_id: i64,
+ user_workspace: &UserWorkspace,
+ authenticator: &Authenticator,
+ ) -> FlowyResult<()> {
self
.folder_manager
.initialize_with_workspace_id(user_id)
.await?;
- self.database_manager.initialize(user_id).await?;
+ self
+ .database_manager
+ .initialize(user_id, authenticator.is_local())
+ .await?;
self.document_manager.initialize(user_id).await?;
self.ai_manager.initialize(&user_workspace.id).await?;
self.storage_manager.initialize(&user_workspace.id).await;
diff --git a/frontend/rust-lib/flowy-database2/src/manager.rs b/frontend/rust-lib/flowy-database2/src/manager.rs
index db37387451..0c4b13cab8 100644
--- a/frontend/rust-lib/flowy-database2/src/manager.rs
+++ b/frontend/rust-lib/flowy-database2/src/manager.rs
@@ -82,7 +82,7 @@ impl DatabaseManager {
}
/// When initialize with new workspace, all the resources will be cleared.
- pub async fn initialize(&self, uid: i64) -> FlowyResult<()> {
+ pub async fn initialize(&self, uid: i64, is_local_user: bool) -> FlowyResult<()> {
// 1. Clear all existing tasks
self.task_scheduler.write().await.clear_task();
// 2. Release all existing editors
@@ -99,6 +99,7 @@ impl DatabaseManager {
let collab_db = self.user.collab_db(uid)?;
let collab_service = WorkspaceDatabaseCollabServiceImpl::new(
+ is_local_user,
self.user.clone(),
self.collab_builder.clone(),
self.cloud_service.clone(),
@@ -168,8 +169,12 @@ impl DatabaseManager {
skip_all,
err
)]
- pub async fn initialize_with_new_user(&self, user_id: i64) -> FlowyResult<()> {
- self.initialize(user_id).await?;
+ pub async fn initialize_with_new_user(
+ &self,
+ user_id: i64,
+ is_local_user: bool,
+ ) -> FlowyResult<()> {
+ self.initialize(user_id, is_local_user).await?;
Ok(())
}
@@ -630,6 +635,7 @@ impl DatabaseManager {
}
struct WorkspaceDatabaseCollabServiceImpl {
+ is_local_user: bool,
user: Arc<dyn DatabaseUser>,
collab_builder: Arc<AppFlowyCollabBuilder>,
persistence: Arc<dyn DatabaseCollabPersistenceService>,
@@ -639,12 +645,14 @@ struct WorkspaceDatabaseCollabServiceImpl {
impl WorkspaceDatabaseCollabServiceImpl {
fn new(
+ is_local_user: bool,
user: Arc<dyn DatabaseUser>,
collab_builder: Arc<AppFlowyCollabBuilder>,
cloud_service: Arc<dyn DatabaseCloudService>,
) -> Self {
let persistence = DatabasePersistenceImpl { user: user.clone() };
Self {
+ is_local_user,
user,
collab_builder,
persistence: Arc::new(persistence),
@@ -783,15 +791,18 @@ impl DatabaseCollabService for WorkspaceDatabaseCollabServiceImpl {
DataSource::from(encode_collab)
},
Ok(None) => {
- info!(
- "build collab: {}:{} with empty encode collab",
- collab_type, object_id
- );
- // when collab not exist, create a default collab
- CollabPersistenceImpl {
- persistence: Some(self.persistence.clone()),
+ if self.is_local_user {
+ CollabPersistenceImpl {
+ persistence: Some(self.persistence.clone()),
+ }
+ .into()
+ } else {
+ error!(
+ "build collab: {}:{} with empty encode collab",
+ collab_type, object_id
+ );
+ return Err(DatabaseError::RecordNotFound);
}
- .into()
},
Err(err) => {
error!("build collab: failed to get encode collab: {}", err);
diff --git a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs
index 0b8ae12030..043e2ceb24 100644
--- a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs
@@ -5,7 +5,7 @@ use crate::services::cell::{apply_cell_changeset, get_cell_protobuf, CellCache};
use crate::services::database::database_observe::*;
use crate::services::database::util::database_view_setting_pb_from_view;
use crate::services::database_view::{
- DatabaseViewChanged, DatabaseViewOperation, DatabaseViews, EditorByViewId,
+ DatabaseViewChanged, DatabaseViewEditor, DatabaseViewOperation, DatabaseViews, EditorByViewId,
};
use crate::services::field::type_option_transform::transform_type_option;
use crate::services::field::{
@@ -1355,23 +1355,48 @@ impl DatabaseEditor {
}
let row_orders = self.database.read().await.get_row_orders_for_view(view_id);
- let cloned_database = Arc::downgrade(&self.database);
let cloned_row_orders = row_orders.clone();
- let opening_database_views = self.database_views.clone();
+ // Collect database details in a single block holding the `read` lock
+ let (database_id, fields, is_linked) = {
+ let database = self.database.read().await;
+ (
+ database.get_database_id(),
+ database
+ .get_all_field_orders()
+ .into_iter()
+ .map(FieldIdPB::from)
+ .collect::<Vec<_>>(),
+ database.is_inline_view(view_id),
+ )
+ };
+
+ let rows = row_orders
+ .into_iter()
+ .map(RowMetaPB::from)
+ .collect::<Vec<RowMetaPB>>();
+
+ trace!(
+ "database: {}, num fields: {}, num rows: {}",
+ database_id,
+ fields.len(),
+ rows.len()
+ );
+
+ trace!("[Database]: start loading rows");
+ let cloned_database = Arc::downgrade(&self.database);
+ let view_editor = self.database_views.get_view_editor(view_id).await?;
tokio::spawn(async move {
const CHUNK_SIZE: usize = 10;
let apply_filter_and_sort =
- |mut loaded_rows, opening_database_views: Arc<DatabaseViews>| async move {
- for database_view in opening_database_views.editors().await {
- if database_view.has_filters().await {
- database_view
- .v_filter_rows_and_notify(&mut loaded_rows)
- .await;
- }
+ |mut loaded_rows: Vec<Arc<Row>>, view_editor: Arc<DatabaseViewEditor>| async move {
+ if view_editor.has_filters().await {
+ trace!("[Database]: filtering rows:{}", loaded_rows.len());
+ view_editor.v_filter_rows_and_notify(&mut loaded_rows).await;
+ }
- if database_view.has_sorts().await {
- database_view.v_sort_rows_and_notify(&mut loaded_rows).await;
- }
+ if view_editor.has_sorts().await {
+ trace!("[Database]: sorting rows:{}", loaded_rows.len());
+ view_editor.v_sort_rows_and_notify(&mut loaded_rows).await;
}
};
@@ -1392,45 +1417,18 @@ impl DatabaseEditor {
// stop init database rows
if new_token.is_cancelled() {
+ info!("[Database]: stop loading database rows");
return;
}
-
- if loaded_rows.len() % 1000 == 0 {
- apply_filter_and_sort(loaded_rows.clone(), opening_database_views.clone()).await;
- }
},
}
tokio::task::yield_now().await;
}
- apply_filter_and_sort(loaded_rows.clone(), opening_database_views).await;
+ info!("[Database]: Finish loading rows: {}", loaded_rows.len());
+ apply_filter_and_sort(loaded_rows.clone(), view_editor).await;
});
- // Collect database details in a single block holding the `read` lock
- let (database_id, fields, is_linked) = {
- let database = self.database.read().await;
- (
- database.get_database_id(),
- database
- .get_all_field_orders()
- .into_iter()
- .map(FieldIdPB::from)
- .collect::<Vec<_>>(),
- database.is_inline_view(view_id),
- )
- };
-
- let rows = row_orders
- .into_iter()
- .map(RowMetaPB::from)
- .collect::<Vec<RowMetaPB>>();
-
- trace!(
- "database: {}, num fields: {}, num rows: {}",
- database_id,
- fields.len(),
- rows.len()
- );
Ok::<_, FlowyError>(DatabasePB {
id: database_id,
fields,
diff --git a/frontend/rust-lib/flowy-database2/src/services/filter/controller.rs b/frontend/rust-lib/flowy-database2/src/services/filter/controller.rs
index b9c61ca1fa..cb3231f948 100644
--- a/frontend/rust-lib/flowy-database2/src/services/filter/controller.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/filter/controller.rs
@@ -11,7 +11,7 @@ use flowy_error::FlowyResult;
use lib_infra::priority_task::{QualityOfService, Task, TaskContent, TaskDispatcher};
use serde::{Deserialize, Serialize};
use tokio::sync::RwLock;
-use tracing::error;
+use tracing::{error, trace};
use crate::entities::filter_entities::*;
use crate::entities::{FieldType, InsertedRowPB, RowMetaPB};
@@ -74,14 +74,13 @@ impl FilterController {
let mut need_save = false;
let mut filters = delegate.get_all_filters(view_id).await;
+ trace!("[Database]: filters: {:?}", filters);
let mut filtering_field_ids: HashMap<String, Vec<String>> = HashMap::new();
-
for filter in filters.iter() {
filter.get_all_filtering_field_ids(&mut filtering_field_ids);
}
let mut delete_filter_ids = vec![];
-
for (field_id, filter_ids) in &filtering_field_ids {
if !field_ids.contains(field_id) {
need_save = true;
@@ -385,7 +384,6 @@ impl FilterController {
invisible_rows,
visible_rows,
};
- tracing::trace!("filter result {:?}", notification);
let _ = self
.notifier
.send(DatabaseViewChanged::FilterNotification(notification));
diff --git a/frontend/rust-lib/flowy-user/src/event_map.rs b/frontend/rust-lib/flowy-user/src/event_map.rs
index 6e03928c6e..844d640415 100644
--- a/frontend/rust-lib/flowy-user/src/event_map.rs
+++ b/frontend/rust-lib/flowy-user/src/event_map.rs
@@ -290,6 +290,7 @@ pub trait UserStatusCallback: Send + Sync + 'static {
_cloud_config: &Option<UserCloudConfig>,
_user_workspace: &UserWorkspace,
_device_id: &str,
+ _authenticator: &Authenticator,
) -> FlowyResult<()> {
Ok(())
}
@@ -299,6 +300,7 @@ pub trait UserStatusCallback: Send + Sync + 'static {
_user_id: i64,
_user_workspace: &UserWorkspace,
_device_id: &str,
+ _authenticator: &Authenticator,
) -> FlowyResult<()> {
Ok(())
}
@@ -309,6 +311,7 @@ pub trait UserStatusCallback: Send + Sync + 'static {
_user_profile: &UserProfile,
_user_workspace: &UserWorkspace,
_device_id: &str,
+ _authenticator: &Authenticator,
) -> FlowyResult<()> {
Ok(())
}
@@ -320,6 +323,7 @@ pub trait UserStatusCallback: Send + Sync + 'static {
&self,
_user_id: i64,
_user_workspace: &UserWorkspace,
+ _authenticator: &Authenticator,
) -> FlowyResult<()> {
Ok(())
}
diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
index 78443360aa..1b38599814 100644
--- a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
+++ b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
@@ -280,6 +280,7 @@ impl UserManager {
&cloud_config,
&session.user_workspace,
&self.authenticate_user.user_config.device_id,
+ &user.authenticator,
)
.await?;
}
@@ -352,6 +353,7 @@ impl UserManager {
user_profile.uid,
&latest_workspace,
&self.authenticate_user.user_config.device_id,
+ &authenticator,
)
.await?;
send_auth_state_notification(AuthStateChangedPB {
@@ -443,6 +445,7 @@ impl UserManager {
new_user_profile,
&new_session.user_workspace,
&self.authenticate_user.user_config.device_id,
+ authenticator,
)
.await?;
diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs
index 4b56b51df0..b674019265 100644
--- a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs
+++ b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs
@@ -196,7 +196,7 @@ impl UserManager {
.user_status_callback
.read()
.await
- .open_workspace(uid, &user_workspace)
+ .open_workspace(uid, &user_workspace, &user_profile.authenticator)
.await
{
error!("Open workspace failed: {:?}", err);