2024-02-03 21:50:23 +00:00
|
|
|
use crate::entities::UserFolderPB;
|
2023-12-29 05:02:27 +00:00
|
|
|
use collab_folder::Folder;
|
2024-02-03 21:50:23 +00:00
|
|
|
use flowy_error::{ErrorCode, FlowyError};
|
2024-01-11 06:42:03 +00:00
|
|
|
use flowy_folder_pub::folder_builder::ParentChildViews;
|
2024-01-22 05:34:15 +00:00
|
|
|
use tracing::{event, instrument};
|
2023-12-17 19:14:05 +00:00
|
|
|
|
|
|
|
pub(crate) fn folder_not_init_error() -> FlowyError {
|
|
|
|
FlowyError::internal().with_context("Folder not initialized")
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn workspace_data_not_sync_error(uid: i64, workspace_id: &str) -> FlowyError {
|
|
|
|
FlowyError::from(ErrorCode::WorkspaceDataNotSync).with_payload(UserFolderPB {
|
|
|
|
uid,
|
|
|
|
workspace_id: workspace_id.to_string(),
|
|
|
|
})
|
|
|
|
}
|
2023-12-29 05:02:27 +00:00
|
|
|
|
2024-01-12 06:34:59 +00:00
|
|
|
#[instrument(level = "debug", skip(folder, view))]
|
2024-08-18 03:16:42 +00:00
|
|
|
pub(crate) fn insert_parent_child_views(folder: &mut Folder, view: ParentChildViews) {
|
2024-01-12 06:34:59 +00:00
|
|
|
event!(
|
|
|
|
tracing::Level::DEBUG,
|
|
|
|
"Inserting view: {}, view children: {}",
|
|
|
|
view.parent_view.id,
|
|
|
|
view.child_views.len()
|
|
|
|
);
|
2023-12-29 05:02:27 +00:00
|
|
|
folder.insert_view(view.parent_view, None);
|
|
|
|
for child_view in view.child_views {
|
|
|
|
insert_parent_child_views(folder, child_view);
|
|
|
|
}
|
|
|
|
}
|