(
&mut self,
collection_id: Uuid,
node_id: Uuid,
cx: &mut Context<Self>,
)
| 489 | let previous = std::mem::take(&mut self.collections); |
| 490 | self.workspace_collections |
| 491 | .insert(self.active_workspace_id, previous); |
| 492 | self.active_workspace_id = workspace_id; |
| 493 | self.collections = self |
| 494 | .workspace_collections |
| 495 | .remove(&workspace_id) |
| 496 | .unwrap_or_default(); |
| 497 | self.bump_revision(); |
| 498 | self.save_to_file(); |
| 499 | cx.notify(); |
| 500 | } |
| 501 | |
| 502 | pub fn remove_workspace(&mut self, workspace_id: Uuid) { |
| 503 | if workspace_id != self.active_workspace_id { |
| 504 | self.workspace_collections.remove(&workspace_id); |
| 505 | self.save_to_file(); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | fn bump_revision(&mut self) { |
| 510 | self.revision = self.revision.wrapping_add(1); |
| 511 | } |
| 512 | |
| 513 | /// Monotonically changes whenever the collection tree changes. Views use this |
| 514 | /// to rebuild their virtualized snapshots only when the source data changes. |
| 515 | pub fn revision(&self) -> u64 { |
| 516 | self.revision |
| 517 | } |
no test coverage detected