Skip to content

Commit 506af26

Browse files
committed
chore: save move to no status card
1 parent 7b53b2c commit 506af26

File tree

5 files changed

+53
-52
lines changed

5 files changed

+53
-52
lines changed

frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
44
const DART_LOG = "Dart_LOG";
55

66
class Log {
7-
static const enableLog = true;
7+
static const enableLog = false;
88

99
static void info(String? message) {
1010
if (enableLog) {

frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_option.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,12 @@ pub fn select_option_color_from_index(index: usize) -> SelectOptionColorPB {
155155
}
156156
}
157157

158+
#[derive(Default)]
158159
pub struct SelectOptionIds(Vec<String>);
159160

160161
impl SelectOptionIds {
161162
pub fn new() -> Self {
162-
Self(vec![])
163+
Self::default()
163164
}
164165
pub fn into_inner(self) -> Vec<String> {
165166
self.0

frontend/rust-lib/flowy-grid/src/services/grid_view_manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl GridViewManager {
134134
row_rev: Arc<RowRevision>,
135135
to_group_id: String,
136136
to_row_id: Option<String>,
137-
with_row_changeset: impl FnOnce(RowChangeset) -> AFFuture<()>,
137+
recv_row_changeset: impl FnOnce(RowChangeset) -> AFFuture<()>,
138138
) -> FlowyResult<()> {
139139
let mut row_changeset = RowChangeset::new(row_rev.id.clone());
140140
let view_editor = self.get_default_view_editor().await?;
@@ -143,7 +143,7 @@ impl GridViewManager {
143143
.await;
144144

145145
if !row_changeset.is_empty() {
146-
with_row_changeset(row_changeset).await;
146+
recv_row_changeset(row_changeset).await;
147147
}
148148

149149
for group_changeset in group_changesets {

frontend/rust-lib/flowy-grid/src/services/group/configuration.rs

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,47 @@ where
9393
})
9494
}
9595

96-
pub(crate) fn groups(&self) -> Vec<&Group> {
96+
/// Returns the groups without the default group
97+
pub(crate) fn concrete_groups(&self) -> Vec<&Group> {
9798
self.groups_map.values().collect()
9899
}
99100

101+
/// Returns the all the groups that contain the default group.
100102
pub(crate) fn clone_groups(&self) -> Vec<Group> {
101103
let mut groups: Vec<Group> = self.groups_map.values().cloned().collect();
102104
groups.push(self.default_group.clone());
103105
groups
104106
}
105107

108+
/// Iterate mut the groups. The default group will be the last one that get mutated.
109+
pub(crate) fn iter_mut_groups(&mut self, mut each: impl FnMut(&mut Group)) {
110+
self.groups_map.iter_mut().for_each(|(_, group)| {
111+
each(group);
112+
});
113+
114+
each(&mut self.default_group);
115+
}
116+
117+
pub(crate) fn move_group(&mut self, from_id: &str, to_id: &str) -> FlowyResult<()> {
118+
let from_index = self.groups_map.get_index_of(from_id);
119+
let to_index = self.groups_map.get_index_of(to_id);
120+
match (from_index, to_index) {
121+
(Some(from_index), Some(to_index)) => {
122+
self.groups_map.swap_indices(from_index, to_index);
123+
self.mut_configuration(|configuration| {
124+
let from_index = configuration.groups.iter().position(|group| group.id == from_id);
125+
let to_index = configuration.groups.iter().position(|group| group.id == to_id);
126+
if let (Some(from), Some(to)) = (from_index, to_index) {
127+
configuration.groups.swap(from, to);
128+
}
129+
true
130+
})?;
131+
Ok(())
132+
}
133+
_ => Err(FlowyError::out_of_bounds()),
134+
}
135+
}
136+
106137
pub(crate) fn merge_groups(&mut self, groups: Vec<Group>) -> FlowyResult<Option<GroupViewChangesetPB>> {
107138
let MergeGroupResult {
108139
groups,
@@ -154,53 +185,26 @@ where
154185

155186
#[allow(dead_code)]
156187
pub(crate) async fn hide_group(&mut self, group_id: &str) -> FlowyResult<()> {
157-
self.mut_configuration_group(group_id, |group_rev| {
188+
self.mut_group_rev(group_id, |group_rev| {
158189
group_rev.visible = false;
159190
})?;
160191
Ok(())
161192
}
162193

163194
#[allow(dead_code)]
164195
pub(crate) async fn show_group(&mut self, group_id: &str) -> FlowyResult<()> {
165-
self.mut_configuration_group(group_id, |group_rev| {
196+
self.mut_group_rev(group_id, |group_rev| {
166197
group_rev.visible = true;
167198
})?;
168199
Ok(())
169200
}
170201

171-
pub(crate) fn iter_mut_groups(&mut self, mut each: impl FnMut(&mut Group)) {
172-
self.groups_map.iter_mut().for_each(|(_, group)| {
173-
each(group);
174-
})
175-
}
176-
177-
pub(crate) fn get_mut_group(&mut self, group_id: &str) -> Option<&mut Group> {
178-
self.groups_map.get_mut(group_id)
179-
}
180-
181202
pub(crate) fn get_mut_default_group(&mut self) -> &mut Group {
182203
&mut self.default_group
183204
}
184205

185-
pub(crate) fn move_group(&mut self, from_id: &str, to_id: &str) -> FlowyResult<()> {
186-
let from_index = self.groups_map.get_index_of(from_id);
187-
let to_index = self.groups_map.get_index_of(to_id);
188-
match (from_index, to_index) {
189-
(Some(from_index), Some(to_index)) => {
190-
self.groups_map.swap_indices(from_index, to_index);
191-
192-
self.mut_configuration(|configuration| {
193-
let from_index = configuration.groups.iter().position(|group| group.id == from_id);
194-
let to_index = configuration.groups.iter().position(|group| group.id == to_id);
195-
if let (Some(from), Some(to)) = (from_index, to_index) {
196-
configuration.groups.swap(from, to);
197-
}
198-
true
199-
})?;
200-
Ok(())
201-
}
202-
_ => Err(FlowyError::out_of_bounds()),
203-
}
206+
pub(crate) fn get_mut_group(&mut self, group_id: &str) -> Option<&mut Group> {
207+
self.groups_map.get_mut(group_id)
204208
}
205209

206210
// Returns the index and group specified by the group_id
@@ -231,11 +235,19 @@ where
231235
Ok(())
232236
}
233237

234-
fn mut_configuration_group(
238+
fn mut_configuration(
235239
&mut self,
236-
group_id: &str,
237-
mut_groups_fn: impl Fn(&mut GroupRevision),
240+
mut_configuration_fn: impl FnOnce(&mut GroupConfigurationRevision) -> bool,
238241
) -> FlowyResult<()> {
242+
let configuration = Arc::make_mut(&mut self.configuration);
243+
let is_changed = mut_configuration_fn(configuration);
244+
if is_changed {
245+
let _ = self.save_configuration()?;
246+
}
247+
Ok(())
248+
}
249+
250+
fn mut_group_rev(&mut self, group_id: &str, mut_groups_fn: impl Fn(&mut GroupRevision)) -> FlowyResult<()> {
239251
self.mut_configuration(|configuration| {
240252
match configuration.groups.iter_mut().find(|group| group.id == group_id) {
241253
None => false,
@@ -246,18 +258,6 @@ where
246258
}
247259
})
248260
}
249-
250-
fn mut_configuration(
251-
&mut self,
252-
mut_configuration_fn: impl FnOnce(&mut GroupConfigurationRevision) -> bool,
253-
) -> FlowyResult<()> {
254-
let configuration = Arc::make_mut(&mut self.configuration);
255-
let is_changed = mut_configuration_fn(configuration);
256-
if is_changed {
257-
let _ = self.save_configuration()?;
258-
}
259-
Ok(())
260-
}
261261
}
262262

263263
fn merge_groups(old_groups: &[GroupRevision], groups: Vec<Group>) -> MergeGroupResult {

frontend/rust-lib/flowy-grid/src/services/group/controller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ where
195195
let mut grouped_rows: Vec<GroupedRow> = vec![];
196196
let cell_bytes = decode_any_cell_data(cell_rev.data.clone(), field_rev);
197197
let cell_data = cell_bytes.parser::<P>()?;
198-
for group in self.configuration.groups() {
198+
for group in self.configuration.concrete_groups() {
199199
if self.can_group(&group.content, &cell_data) {
200200
grouped_rows.push(GroupedRow {
201201
row: row_rev.into(),

0 commit comments

Comments
 (0)