(&mut self, doc_id: String)
| 160 | } |
| 161 | |
| 162 | pub async fn create_collab(&mut self, doc_id: String) { |
| 163 | let object_id = Uuid::parse_str(&doc_id) |
| 164 | .unwrap_or_else(|_| Uuid::new_v5(&Uuid::NAMESPACE_OID, doc_id.as_bytes())); |
| 165 | let disk_plugin = disk_plugin_with_db( |
| 166 | self.uid, |
| 167 | self.workspace_id.clone(), |
| 168 | self.db.clone(), |
| 169 | &object_id.to_string(), |
| 170 | CollabType::Unknown, |
| 171 | ); |
| 172 | let data_source = KVDBCollabPersistenceImpl { |
| 173 | db: Arc::downgrade(&self.db), |
| 174 | uid: self.uid, |
| 175 | workspace_id: self.workspace_id.clone(), |
| 176 | }; |
| 177 | |
| 178 | let options = |
| 179 | CollabOptions::new(object_id, default_client_id()).with_data_source(data_source.into()); |
| 180 | let mut collab = Collab::new_with_options(CollabOrigin::Empty, options).unwrap(); |
| 181 | collab.add_plugin(Box::new(disk_plugin)); |
| 182 | collab.initialize(); |
| 183 | self |
| 184 | .collab_by_id |
| 185 | .insert(doc_id, Arc::new(RwLock::from(collab))); |
| 186 | } |
| 187 | |
| 188 | pub async fn enable_undo_redo(&self, doc_id: &str) { |
| 189 | self |
no test coverage detected