mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: stuck when importing large csv file (#4878)
* chore: fix import csv file * chore: update collab * chore: bump collab * chore: workaround for row creating * fix: test
This commit is contained in:
@ -59,14 +59,14 @@ pub struct ViewPB {
|
||||
pub is_favorite: bool,
|
||||
}
|
||||
|
||||
pub fn view_pb_without_child_views(view: Arc<View>) -> ViewPB {
|
||||
pub fn view_pb_without_child_views(view: View) -> ViewPB {
|
||||
ViewPB {
|
||||
id: view.id.clone(),
|
||||
parent_view_id: view.parent_view_id.clone(),
|
||||
name: view.name.clone(),
|
||||
id: view.id,
|
||||
parent_view_id: view.parent_view_id,
|
||||
name: view.name,
|
||||
create_time: view.created_at,
|
||||
child_views: Default::default(),
|
||||
layout: view.layout.clone().into(),
|
||||
layout: view.layout.into(),
|
||||
icon: view.icon.clone().map(|icon| icon.into()),
|
||||
is_favorite: view.is_favorite,
|
||||
}
|
||||
@ -81,7 +81,7 @@ pub fn view_pb_with_child_views(view: Arc<View>, child_views: Vec<Arc<View>>) ->
|
||||
create_time: view.created_at,
|
||||
child_views: child_views
|
||||
.into_iter()
|
||||
.map(view_pb_without_child_views)
|
||||
.map(|view| view_pb_without_child_views(view.as_ref().clone()))
|
||||
.collect(),
|
||||
layout: view.layout.clone().into(),
|
||||
icon: view.icon.clone().map(|icon| icon.into()),
|
||||
|
@ -28,7 +28,7 @@ pub(crate) async fn create_workspace_handler(
|
||||
.get_views_belong_to(&workspace.id)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(view_pb_without_child_views)
|
||||
.map(|view| view_pb_without_child_views(view.as_ref().clone()))
|
||||
.collect::<Vec<ViewPB>>();
|
||||
data_result_ok(WorkspacePB {
|
||||
id: workspace.id,
|
||||
@ -85,7 +85,7 @@ pub(crate) async fn create_view_handler(
|
||||
if set_as_current {
|
||||
let _ = folder.set_current_view(&view.id).await;
|
||||
}
|
||||
data_result_ok(view_pb_without_child_views(Arc::new(view)))
|
||||
data_result_ok(view_pb_without_child_views(view))
|
||||
}
|
||||
|
||||
pub(crate) async fn create_orphan_view_handler(
|
||||
@ -99,7 +99,7 @@ pub(crate) async fn create_orphan_view_handler(
|
||||
if set_as_current {
|
||||
let _ = folder.set_current_view(&view.id).await;
|
||||
}
|
||||
data_result_ok(view_pb_without_child_views(Arc::new(view)))
|
||||
data_result_ok(view_pb_without_child_views(view))
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, folder), err)]
|
||||
@ -313,11 +313,12 @@ pub(crate) async fn delete_all_trash_handler(
|
||||
pub(crate) async fn import_data_handler(
|
||||
data: AFPluginData<ImportPB>,
|
||||
folder: AFPluginState<Weak<FolderManager>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
) -> DataResult<ViewPB, FlowyError> {
|
||||
let folder = upgrade_folder(folder)?;
|
||||
let params: ImportParams = data.into_inner().try_into()?;
|
||||
folder.import(params).await?;
|
||||
Ok(())
|
||||
let view = folder.import(params).await?;
|
||||
let view_pb = view_pb_without_child_views(view);
|
||||
data_result_ok(view_pb)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(folder), err)]
|
||||
|
@ -124,7 +124,7 @@ pub enum FolderEvent {
|
||||
#[event()]
|
||||
PermanentlyDeleteAllTrashItem = 27,
|
||||
|
||||
#[event(input = "ImportPB")]
|
||||
#[event(input = "ImportPB", output = "ViewPB")]
|
||||
ImportData = 30,
|
||||
|
||||
#[event(input = "WorkspaceIdPB", output = "RepeatedFolderSnapshotPB")]
|
||||
|
@ -374,7 +374,7 @@ impl FolderManager {
|
||||
.views
|
||||
.get_views_belong_to(&workspace.id)
|
||||
.into_iter()
|
||||
.map(view_pb_without_child_views)
|
||||
.map(|view| view_pb_without_child_views(view.as_ref().clone()))
|
||||
.collect::<Vec<ViewPB>>();
|
||||
|
||||
WorkspacePB {
|
||||
@ -556,7 +556,7 @@ impl FolderManager {
|
||||
.send();
|
||||
|
||||
notify_child_views_changed(
|
||||
view_pb_without_child_views(view),
|
||||
view_pb_without_child_views(view.as_ref().clone()),
|
||||
ChildViewChangeReason::Delete,
|
||||
);
|
||||
}
|
||||
@ -573,7 +573,7 @@ impl FolderManager {
|
||||
let favorite_descendant_views: Vec<ViewPB> = all_descendant_views
|
||||
.iter()
|
||||
.filter(|view| view.is_favorite)
|
||||
.map(|view| view_pb_without_child_views(view.clone()))
|
||||
.map(|view| view_pb_without_child_views(view.as_ref().clone()))
|
||||
.collect();
|
||||
|
||||
if !favorite_descendant_views.is_empty() {
|
||||
|
@ -32,7 +32,7 @@ pub(crate) fn subscribe_folder_view_changed(
|
||||
match value {
|
||||
ViewChange::DidCreateView { view } => {
|
||||
notify_child_views_changed(
|
||||
view_pb_without_child_views(Arc::new(view.clone())),
|
||||
view_pb_without_child_views(view.clone()),
|
||||
ChildViewChangeReason::Create,
|
||||
);
|
||||
notify_parent_view_did_change(folder.clone(), vec![view.parent_view_id]);
|
||||
@ -40,7 +40,7 @@ pub(crate) fn subscribe_folder_view_changed(
|
||||
ViewChange::DidDeleteView { views } => {
|
||||
for view in views {
|
||||
notify_child_views_changed(
|
||||
view_pb_without_child_views(view),
|
||||
view_pb_without_child_views(view.as_ref().clone()),
|
||||
ChildViewChangeReason::Delete,
|
||||
);
|
||||
}
|
||||
@ -48,7 +48,7 @@ pub(crate) fn subscribe_folder_view_changed(
|
||||
ViewChange::DidUpdate { view } => {
|
||||
notify_view_did_change(view.clone());
|
||||
notify_child_views_changed(
|
||||
view_pb_without_child_views(Arc::new(view.clone())),
|
||||
view_pb_without_child_views(view.clone()),
|
||||
ChildViewChangeReason::Update,
|
||||
);
|
||||
notify_parent_view_did_change(folder.clone(), vec![view.parent_view_id.clone()]);
|
||||
@ -190,8 +190,9 @@ pub(crate) fn notify_did_update_workspace(workspace_id: &str, folder: &Folder) {
|
||||
}
|
||||
|
||||
fn notify_view_did_change(view: View) -> Option<()> {
|
||||
let view_pb = view_pb_without_child_views(Arc::new(view.clone()));
|
||||
send_notification(&view.id, FolderNotification::DidUpdateView)
|
||||
let view_id = view.id.clone();
|
||||
let view_pb = view_pb_without_child_views(view);
|
||||
send_notification(&view_id, FolderNotification::DidUpdateView)
|
||||
.payload(view_pb)
|
||||
.send();
|
||||
None
|
||||
|
Reference in New Issue
Block a user