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: grid tasks

appflowydc81ac8e2422
diff --git a/frontend/app_flowy/lib/workspace/application/grid/grid_service.dart b/frontend/app_flowy/lib/workspace/application/grid/grid_service.dart
index 3380ad4349..984b50d0a2 100644
--- a/frontend/app_flowy/lib/workspace/application/grid/grid_service.dart
+++ b/frontend/app_flowy/lib/workspace/application/grid/grid_service.dart
@@ -22,7 +22,7 @@ class GridService {
await FolderEventSetLatestView(ViewId(value: gridId)).send();
final payload = GridId(value: gridId);
- return GridEventGetGridData(payload).send();
+ return GridEventGetGrid(payload).send();
}
Future<Either<Row, FlowyError>> createRow({Option<String>? startRowId}) {
diff --git a/frontend/rust-lib/flowy-grid/src/services/filter/filter_runner.rs b/frontend/rust-lib/flowy-grid/src/services/filter/filter_runner.rs
new file mode 100644
index 0000000000..195dd8c5f8
--- /dev/null
+++ b/frontend/rust-lib/flowy-grid/src/services/filter/filter_runner.rs
@@ -0,0 +1 @@
+pub(crate) struct FilterRunner {}
diff --git a/frontend/rust-lib/flowy-grid/src/services/filter/mod.rs b/frontend/rust-lib/flowy-grid/src/services/filter/mod.rs
new file mode 100644
index 0000000000..04be28a6ef
--- /dev/null
+++ b/frontend/rust-lib/flowy-grid/src/services/filter/mod.rs
@@ -0,0 +1,3 @@
+mod filter_runner;
+
+pub use filter_runner::*;
diff --git a/frontend/rust-lib/flowy-grid/src/services/mod.rs b/frontend/rust-lib/flowy-grid/src/services/mod.rs
index 222b7b8b83..9fd0067416 100644
--- a/frontend/rust-lib/flowy-grid/src/services/mod.rs
+++ b/frontend/rust-lib/flowy-grid/src/services/mod.rs
@@ -3,7 +3,9 @@ mod util;
mod block_manager;
pub mod block_revision_editor;
pub mod field;
+mod filter;
pub mod grid_editor;
pub mod persistence;
pub mod row;
pub mod setting;
+// mod tasks;
diff --git a/frontend/rust-lib/flowy-grid/src/services/tasks/filter/mod.rs b/frontend/rust-lib/flowy-grid/src/services/tasks/filter/mod.rs
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/frontend/rust-lib/flowy-grid/src/services/tasks/mod.rs b/frontend/rust-lib/flowy-grid/src/services/tasks/mod.rs
new file mode 100644
index 0000000000..5dade00d39
--- /dev/null
+++ b/frontend/rust-lib/flowy-grid/src/services/tasks/mod.rs
@@ -0,0 +1,3 @@
+mod filter;
+mod runner;
+mod scheduler;
diff --git a/frontend/rust-lib/flowy-grid/src/services/tasks/runner.rs b/frontend/rust-lib/flowy-grid/src/services/tasks/runner.rs
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/frontend/rust-lib/flowy-grid/src/services/tasks/scheduler.rs b/frontend/rust-lib/flowy-grid/src/services/tasks/scheduler.rs
new file mode 100644
index 0000000000..5ae3feafef
--- /dev/null
+++ b/frontend/rust-lib/flowy-grid/src/services/tasks/scheduler.rs
@@ -0,0 +1,76 @@
+use std::cmp::Ordering;
+use std::collections::BinaryHeap;
+use std::ops::{Deref, DerefMut};
+
+enum TaskType {
+ /// Remove the row if it doesn't satisfy the filter.
+ Filter,
+ /// Generate snapshot for grid, unused by now.
+ Snapshot,
+}
+
+/// Two tasks are equal if they have the same type.
+impl PartialEq for TaskType {
+ fn eq(&self, other: &Self) -> bool {
+ matches!((self, other),)
+ }
+}
+
+pub type TaskId = u32;
+
+#[derive(Eq, Debug, Clone, Copy)]
+struct PendingTask {
+ kind: TaskType,
+ id: TaskId,
+}
+
+impl PartialEq for PendingTask {
+ fn eq(&self, other: &Self) -> bool {
+ self.id.eq(&other.id)
+ }
+}
+
+impl PartialOrd for PendingTask {
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl Ord for PendingTask {
+ fn cmp(&self, other: &Self) -> Ordering {
+ self.id.cmp(&other.id).reverse()
+ }
+}
+
+#[derive(PartialEq, Eq, Hash, Debug, Clone)]
+enum TaskListIdentifier {
+ Filter(String),
+ Snapshot(String),
+}
+
+#[derive(Debug)]
+struct TaskList {
+ tasks: BinaryHeap<PendingTask>,
+}
+
+impl Deref for TaskList {
+ type Target = BinaryHeap<PendingTask>;
+
+ fn deref(&self) -> &Self::Target {
+ &self.tasks
+ }
+}
+
+impl DerefMut for TaskList {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ &mut self.tasks
+ }
+}
+
+impl TaskList {
+ fn new() -> Self {
+ Self {
+ tasks: Default::default(),
+ }
+ }
+}
diff --git a/shared-lib/flowy-folder-data-model/src/revision/view_rev.rs b/shared-lib/flowy-folder-data-model/src/revision/view_rev.rs
index 7d78e555f6..72ab0079b5 100644
--- a/shared-lib/flowy-folder-data-model/src/revision/view_rev.rs
+++ b/shared-lib/flowy-folder-data-model/src/revision/view_rev.rs
@@ -30,13 +30,10 @@ pub struct ViewRevision {
#[serde(default)]
pub thumbnail: String,
- #[serde(default = "default_plugin_type")]
+ #[serde(default = "DEFAULT_PLUGIN_TYPE")]
pub plugin_type: i32,
}
-
-fn default_plugin_type() -> i32 {
- 0
-}
+const DEFAULT_PLUGIN_TYPE: fn() -> i32 = || 0;
impl std::convert::From<ViewRevision> for View {
fn from(view_serde: ViewRevision) -> Self {
diff --git a/shared-lib/flowy-grid-data-model/src/revision/grid_rev.rs b/shared-lib/flowy-grid-data-model/src/revision/grid_rev.rs
index 1012232cde..77f1110ece 100644
--- a/shared-lib/flowy-grid-data-model/src/revision/grid_rev.rs
+++ b/shared-lib/flowy-grid-data-model/src/revision/grid_rev.rs
@@ -127,13 +127,11 @@ pub struct FieldRevision {
#[serde(with = "indexmap::serde_seq")]
pub type_options: IndexMap<String, String>,
- #[serde(default = "default_is_primary")]
+ #[serde(default = "DEFAULT_IS_PRIMARY")]
pub is_primary: bool,
}
-fn default_is_primary() -> bool {
- false
-}
+const DEFAULT_IS_PRIMARY: fn() -> bool = || false;
impl FieldRevision {
pub fn new(name: &str, desc: &str, field_type: FieldType, is_primary: bool) -> Self {
diff --git a/shared-lib/flowy-user-data-model/src/entities/user_setting.rs b/shared-lib/flowy-user-data-model/src/entities/user_setting.rs
index f4543b6b5c..8f7beadb4a 100644
--- a/shared-lib/flowy-user-data-model/src/entities/user_setting.rs
+++ b/shared-lib/flowy-user-data-model/src/entities/user_setting.rs
@@ -20,10 +20,12 @@ pub struct AppearanceSettings {
pub locale: LocaleSettings,
#[pb(index = 3)]
- #[serde(default = "reset_default_value")]
+ #[serde(default = "DEFAULT_RESET_VALUE")]
pub reset_as_default: bool,
}
+const DEFAULT_RESET_VALUE: fn() -> bool = || APPEARANCE_RESET_AS_DEFAULT;
+
#[derive(ProtoBuf, Serialize, Deserialize, Debug, Clone)]
pub struct LocaleSettings {
#[pb(index = 1)]
@@ -42,12 +44,8 @@ impl std::default::Default for LocaleSettings {
}
}
-fn reset_default_value() -> bool {
- APPEARANCE_RESET_AS_DEFAULT
-}
-
pub const APPEARANCE_DEFAULT_THEME: &str = "light";
-pub const APPEARANCE_RESET_AS_DEFAULT: bool = true;
+const APPEARANCE_RESET_AS_DEFAULT: bool = true;
impl std::default::Default for AppearanceSettings {
fn default() -> Self {