Skip to content

Commit 13641fa

Browse files
committed
chore: fmt
1 parent ef11d85 commit 13641fa

File tree

5 files changed

+85
-39
lines changed

5 files changed

+85
-39
lines changed

collab/src/folder/folder.rs

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ impl Folder {
172172
/// This function fetches the ID of the current workspace from the meta object,
173173
/// and uses this ID to fetch the actual workspace object.
174174
///
175-
pub fn get_workspace_info(&self, workspace_id: &WorkspaceId, uid: Option<i64>) -> Option<Workspace> {
175+
pub fn get_workspace_info(
176+
&self,
177+
workspace_id: &WorkspaceId,
178+
uid: Option<i64>,
179+
) -> Option<Workspace> {
176180
let txn = self.collab.transact();
177181
self.body.get_workspace_info(&txn, workspace_id, uid)
178182
}
@@ -205,8 +209,7 @@ impl Folder {
205209

206210
pub fn move_view(&mut self, view_id: &ViewId, from: u32, to: u32, uid: i64) -> Option<Arc<View>> {
207211
let mut txn = self.collab.transact_mut();
208-
self.body
209-
.move_view(&mut txn, view_id, from, to, Some(uid))
212+
self.body.move_view(&mut txn, view_id, from, to, Some(uid))
210213
}
211214

212215
/// Moves a nested view to a new location in the hierarchy.
@@ -323,14 +326,22 @@ impl Folder {
323326

324327
pub fn remove_all_my_favorite_sections(&mut self, uid: i64) {
325328
let mut txn = self.collab.transact_mut();
326-
if let Some(op) = self.body.section.section_op(&txn, Section::Favorite, Some(uid)) {
329+
if let Some(op) = self
330+
.body
331+
.section
332+
.section_op(&txn, Section::Favorite, Some(uid))
333+
{
327334
op.clear(&mut txn);
328335
}
329336
}
330337

331338
pub fn move_favorite_view_id(&mut self, id: &str, prev_id: Option<&str>, uid: i64) {
332339
let mut txn = self.collab.transact_mut();
333-
if let Some(op) = self.body.section.section_op(&txn, Section::Favorite, Some(uid)) {
340+
if let Some(op) = self
341+
.body
342+
.section
343+
.section_op(&txn, Section::Favorite, Some(uid))
344+
{
334345
op.move_section_item_with_txn(&mut txn, id, prev_id);
335346
}
336347
}
@@ -395,14 +406,22 @@ impl Folder {
395406

396407
pub fn remove_all_my_trash_sections(&mut self, uid: i64) {
397408
let mut txn = self.collab.transact_mut();
398-
if let Some(op) = self.body.section.section_op(&txn, Section::Trash, Some(uid)) {
409+
if let Some(op) = self
410+
.body
411+
.section
412+
.section_op(&txn, Section::Trash, Some(uid))
413+
{
399414
op.clear(&mut txn);
400415
}
401416
}
402417

403418
pub fn move_trash_view_id(&mut self, id: &str, prev_id: Option<&str>, uid: i64) {
404419
let mut txn = self.collab.transact_mut();
405-
if let Some(op) = self.body.section.section_op(&txn, Section::Trash, Some(uid)) {
420+
if let Some(op) = self
421+
.body
422+
.section
423+
.section_op(&txn, Section::Trash, Some(uid))
424+
{
406425
op.move_section_item_with_txn(&mut txn, id, prev_id);
407426
}
408427
}
@@ -467,14 +486,22 @@ impl Folder {
467486

468487
pub fn remove_all_my_private_sections(&mut self, uid: i64) {
469488
let mut txn = self.collab.transact_mut();
470-
if let Some(op) = self.body.section.section_op(&txn, Section::Private, Some(uid)) {
489+
if let Some(op) = self
490+
.body
491+
.section
492+
.section_op(&txn, Section::Private, Some(uid))
493+
{
471494
op.clear(&mut txn);
472495
}
473496
}
474497

475498
pub fn move_private_view_id(&mut self, id: &str, prev_id: Option<&str>, uid: i64) {
476499
let mut txn = self.collab.transact_mut();
477-
if let Some(op) = self.body.section.section_op(&txn, Section::Private, Some(uid)) {
500+
if let Some(op) = self
501+
.body
502+
.section
503+
.section_op(&txn, Section::Private, Some(uid))
504+
{
478505
op.move_section_item_with_txn(&mut txn, id, prev_id);
479506
}
480507
}
@@ -734,7 +761,8 @@ impl FolderBody {
734761
);
735762
}
736763

737-
if let Some(fav_section) = section.section_op(&txn, Section::Favorite, Some(folder_data.uid)) {
764+
if let Some(fav_section) = section.section_op(&txn, Section::Favorite, Some(folder_data.uid))
765+
{
738766
for (uid, sections) in folder_data.favorites {
739767
fav_section.add_sections_for_user_with_txn(&mut txn, &uid, sections);
740768
}
@@ -855,7 +883,10 @@ impl FolderBody {
855883
.iter()
856884
.map(|view| view.as_ref().clone())
857885
.collect::<Vec<View>>();
858-
for view in self.views.get_views_belong_to(txn, &workspace_uuid, Some(uid)) {
886+
for view in self
887+
.views
888+
.get_views_belong_to(txn, &workspace_uuid, Some(uid))
889+
{
859890
let mut all_views_in_workspace = vec![];
860891
self.get_view_recursively_with_txn(
861892
txn,
@@ -988,10 +1019,7 @@ impl FolderBody {
9881019
.and_then(|uuid| self.views.get_view_with_txn(txn, &uuid, uid))
9891020
.and_then(|root_view| {
9901021
let first_public_space_view_id_with_child = root_view.children.iter().find(|space_id| {
991-
match self
992-
.views
993-
.get_view_with_txn(txn, &space_id.id, uid)
994-
{
1022+
match self.views.get_view_with_txn(txn, &space_id.id, uid) {
9951023
Some(space_view) => {
9961024
let is_public_space = space_view
9971025
.space_info()

collab/src/folder/view.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ impl ViewsMap {
211211
}
212212

213213
/// Get multiple views by ids. When uid is provided, includes user-specific enrichment.
214-
pub fn get_views<T: ReadTxn>(&self, txn: &T, view_ids: &[ViewId], uid: Option<i64>) -> Vec<Arc<View>> {
214+
pub fn get_views<T: ReadTxn>(
215+
&self,
216+
txn: &T,
217+
view_ids: &[ViewId],
218+
uid: Option<i64>,
219+
) -> Vec<Arc<View>> {
215220
view_ids
216221
.iter()
217222
.flat_map(|view_id| self.get_view_with_txn(txn, view_id, uid))
@@ -261,7 +266,12 @@ impl ViewsMap {
261266

262267
/// Get a view by id. When uid is provided, includes user-specific enrichment like is_favorite.
263268
#[instrument(level = "trace", skip_all)]
264-
pub fn get_view<T: ReadTxn>(&self, txn: &T, view_id: &ViewId, uid: Option<i64>) -> Option<Arc<View>> {
269+
pub fn get_view<T: ReadTxn>(
270+
&self,
271+
txn: &T,
272+
view_id: &ViewId,
273+
uid: Option<i64>,
274+
) -> Option<Arc<View>> {
265275
self.get_view_with_txn(txn, view_id, uid)
266276
}
267277

collab/tests/folder/child_views_test.rs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ fn create_child_views_test() {
5151
.get_views_belong_to(&txn, &v_1.id, Some(uid.as_i64()));
5252
assert_eq!(v_1_child_views.len(), 3);
5353

54-
let v_1_2_child_views = folder
55-
.body
56-
.views
57-
.get_views_belong_to(&txn, &v_1_2.id, Some(uid.as_i64()));
54+
let v_1_2_child_views =
55+
folder
56+
.body
57+
.views
58+
.get_views_belong_to(&txn, &v_1_2.id, Some(uid.as_i64()));
5859
assert_eq!(v_1_2_child_views.len(), 2);
5960

6061
let workspace_uuid_str = workspace_id.to_string();
@@ -280,10 +281,11 @@ fn delete_view_test() {
280281
.insert(&mut txn, view_3, None, uid.as_i64());
281282

282283
folder.body.views.remove_child(&mut txn, &workspace_id, 1);
283-
let w_1_child_views = folder
284-
.body
285-
.views
286-
.get_views_belong_to(&txn, &workspace_id, Some(uid.as_i64()));
284+
let w_1_child_views =
285+
folder
286+
.body
287+
.views
288+
.get_views_belong_to(&txn, &workspace_id, Some(uid.as_i64()));
287289
assert_eq!(
288290
w_1_child_views[0].id.to_string(),
289291
uuid::Uuid::new_v5(&uuid::Uuid::NAMESPACE_OID, "1_1".as_bytes()).to_string()
@@ -321,17 +323,19 @@ fn delete_child_view_test() {
321323
.views
322324
.insert(&mut txn, view_2, None, uid.as_i64());
323325

324-
let views = folder
325-
.body
326-
.views
327-
.get_views_belong_to(&txn, &parse_view_id(&view_1_id), Some(uid.as_i64()));
326+
let views =
327+
folder
328+
.body
329+
.views
330+
.get_views_belong_to(&txn, &parse_view_id(&view_1_id), Some(uid.as_i64()));
328331
assert_eq!(views.len(), 1);
329332

330333
folder.body.views.delete_views(&mut txn, vec![view_1_1_id]);
331-
let views = folder
332-
.body
333-
.views
334-
.get_views_belong_to(&txn, &parse_view_id(&view_1_id), Some(uid.as_i64()));
334+
let views =
335+
folder
336+
.body
337+
.views
338+
.get_views_belong_to(&txn, &parse_view_id(&view_1_id), Some(uid.as_i64()));
335339
assert!(views.is_empty());
336340
}
337341

collab/tests/folder/custom_section.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ fn custom_section_test() {
3333
let op = folder
3434
.body
3535
.section
36-
.section_op(&txn, Section::Custom("private".to_string()), Some(uid.as_i64()))
36+
.section_op(
37+
&txn,
38+
Section::Custom("private".to_string()),
39+
Some(uid.as_i64()),
40+
)
3741
.unwrap();
3842
op.add_sections_item(
3943
&mut txn,

collab/tests/folder/favorite_test.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ fn create_favorite_test() {
3636
let view_2 = make_test_view("2", workspace_id, vec![]);
3737
folder.insert_view(view_2, None, uid.as_i64());
3838

39-
let views =
40-
folder
41-
.body
42-
.views
43-
.get_views_belong_to(&folder.collab.transact(), &workspace_id, Some(uid.as_i64()));
39+
let views = folder.body.views.get_views_belong_to(
40+
&folder.collab.transact(),
41+
&workspace_id,
42+
Some(uid.as_i64()),
43+
);
4444
assert_eq!(views.len(), 2);
4545
assert_eq!(
4646
views[0].id.to_string(),

0 commit comments

Comments
 (0)