mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
* fix: search workspace sync indexing * chore: update collab rev temporarily * feat: revert comparison and implement index check * chore: fixes after merg * feat: clean code + support delete workspace * fix: improve code * fix: improvements after merge * fix: cargo fmt * fix: remove indices for workspace method * fix: clippy errors * fix: clippy too many arguments
48 lines
1.4 KiB
Rust
48 lines
1.4 KiB
Rust
use std::any::Any;
|
|
use std::sync::Arc;
|
|
|
|
use collab::core::collab::IndexContentReceiver;
|
|
use collab_folder::{folder_diff::FolderViewChange, View, ViewIcon, ViewLayout};
|
|
use flowy_error::FlowyError;
|
|
|
|
pub struct IndexableData {
|
|
pub id: String,
|
|
pub data: String,
|
|
pub icon: Option<ViewIcon>,
|
|
pub layout: ViewLayout,
|
|
pub workspace_id: String,
|
|
}
|
|
|
|
impl IndexableData {
|
|
pub fn from_view(view: Arc<View>, workspace_id: String) -> Self {
|
|
IndexableData {
|
|
id: view.id.clone(),
|
|
data: view.name.clone(),
|
|
icon: view.icon.clone(),
|
|
layout: view.layout.clone(),
|
|
workspace_id: workspace_id.clone(),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub trait IndexManager: Send + Sync {
|
|
fn set_index_content_receiver(&self, rx: IndexContentReceiver, workspace_id: String);
|
|
fn add_index(&self, data: IndexableData) -> Result<(), FlowyError>;
|
|
fn update_index(&self, data: IndexableData) -> Result<(), FlowyError>;
|
|
fn remove_indices(&self, ids: Vec<String>) -> Result<(), FlowyError>;
|
|
fn remove_indices_for_workspace(&self, workspace_id: String) -> Result<(), FlowyError>;
|
|
fn is_indexed(&self) -> bool;
|
|
|
|
fn as_any(&self) -> &dyn Any;
|
|
}
|
|
|
|
pub trait FolderIndexManager: IndexManager {
|
|
fn index_all_views(&self, views: Vec<Arc<View>>, workspace_id: String);
|
|
fn index_view_changes(
|
|
&self,
|
|
views: Vec<Arc<View>>,
|
|
changes: Vec<FolderViewChange>,
|
|
workspace_id: String,
|
|
);
|
|
}
|