@@ -89,25 +89,18 @@ impl ViewsMap {
8989 * self . subscription . lock ( ) . await = subscription;
9090 }
9191
92- pub fn move_child ( & self , txn : & mut TransactionMut , parent_id : & str , from : u32 , to : u32 ) {
93- if let Ok ( parent_uuid) = uuid:: Uuid :: parse_str ( parent_id) {
94- self
95- . parent_children_relation
96- . move_child_with_txn ( txn, & parent_uuid, from, to) ;
97- }
92+ pub fn move_child ( & self , txn : & mut TransactionMut , parent_id : & Uuid , from : u32 , to : u32 ) {
93+ self
94+ . parent_children_relation
95+ . move_child_with_txn ( txn, parent_id, from, to) ;
9896 }
9997
10098 /// Dissociate the relationship between parent_id and view_id.
10199 /// Why don't we use the move method to replace dissociate_parent_child and associate_parent_child?
102100 /// Because the views and workspaces are stored in two separate maps, we can't directly move a view from one map to another.
103101 /// So, we have to dissociate the relationship between parent_id and view_id, and then associate the relationship between parent_id and view_id.
104- pub fn dissociate_parent_child ( & self , txn : & mut TransactionMut , parent_id : & str , view_id : & str ) {
105- if let ( Ok ( parent_uuid) , Ok ( view_uuid) ) = (
106- uuid:: Uuid :: parse_str ( parent_id) ,
107- uuid:: Uuid :: parse_str ( view_id) ,
108- ) {
109- self . dissociate_parent_child_with_txn ( txn, & parent_uuid. to_string ( ) , & view_uuid. to_string ( ) ) ;
110- }
102+ pub fn dissociate_parent_child ( & self , txn : & mut TransactionMut , parent_id : & Uuid , view_id : & Uuid ) {
103+ self . dissociate_parent_child_with_txn ( txn, & parent_id. to_string ( ) , & view_id. to_string ( ) ) ;
111104 }
112105
113106 /// Establish a relationship between the parent_id and view_id, and insert the view below the prev_id.
@@ -117,11 +110,11 @@ impl ViewsMap {
117110 pub fn associate_parent_child (
118111 & self ,
119112 txn : & mut TransactionMut ,
120- parent_id : & str ,
121- view_id : & str ,
113+ parent_id : & Uuid ,
114+ view_id : & Uuid ,
122115 prev_id : Option < ViewId > ,
123116 ) {
124- self . associate_parent_child_with_txn ( txn, parent_id, view_id, prev_id) ;
117+ self . associate_parent_child_with_txn ( txn, & parent_id. to_string ( ) , & view_id. to_string ( ) , prev_id) ;
125118 }
126119
127120 pub fn dissociate_parent_child_with_txn (
@@ -157,15 +150,13 @@ impl ViewsMap {
157150 }
158151 }
159152
160- pub fn remove_child ( & self , txn : & mut TransactionMut , parent_id : & str , child_index : u32 ) {
161- if let Ok ( parent_uuid) = uuid:: Uuid :: parse_str ( parent_id) {
162- if let Some ( parent) = self
163- . parent_children_relation
164- . get_children_with_txn ( txn, & parent_uuid)
165- {
166- if let Some ( identifier) = parent. remove_child_with_txn ( txn, child_index) {
167- self . delete_views ( txn, vec ! [ identifier. id] ) ;
168- }
153+ pub fn remove_child ( & self , txn : & mut TransactionMut , parent_id : & Uuid , child_index : u32 ) {
154+ if let Some ( parent) = self
155+ . parent_children_relation
156+ . get_children_with_txn ( txn, parent_id)
157+ {
158+ if let Some ( identifier) = parent. remove_child_with_txn ( txn, child_index) {
159+ self . delete_views ( txn, vec ! [ identifier. id] ) ;
169160 }
170161 }
171162 }
0 commit comments