mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: open next page when current page get deleted
This commit is contained in:
@ -16,6 +16,7 @@ pub(crate) enum FolderNotification {
|
||||
ViewUpdated = 31,
|
||||
ViewDeleted = 32,
|
||||
ViewRestored = 33,
|
||||
ViewMoveToTrash = 34,
|
||||
UserUnauthorized = 100,
|
||||
TrashUpdated = 1000,
|
||||
}
|
||||
|
@ -251,8 +251,6 @@ pub trait ViewDataProcessor {
|
||||
|
||||
fn create_container(&self, user_id: &str, view_id: &str, delta_data: Bytes) -> FutureResult<(), FlowyError>;
|
||||
|
||||
fn delete_container(&self, view_id: &str) -> FutureResult<(), FlowyError>;
|
||||
|
||||
fn close_container(&self, view_id: &str) -> FutureResult<(), FlowyError>;
|
||||
|
||||
fn get_delta_data(&self, view_id: &str) -> FutureResult<Bytes, FlowyError>;
|
||||
|
@ -125,7 +125,7 @@ impl ViewController {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self, view_id), fields(view_id = %view_id.value), err)]
|
||||
pub(crate) async fn read_view_info(&self, view_id: ViewIdPB) -> Result<ViewInfoPB, FlowyError> {
|
||||
pub(crate) async fn read_view_pb(&self, view_id: ViewIdPB) -> Result<ViewInfoPB, FlowyError> {
|
||||
let view_info = self
|
||||
.persistence
|
||||
.begin_transaction(|transaction| {
|
||||
@ -179,14 +179,20 @@ impl ViewController {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self,params), fields(doc_id = %params.value), err)]
|
||||
pub(crate) async fn delete_view(&self, params: TextBlockIdPB) -> Result<(), FlowyError> {
|
||||
if let Some(view_id) = KV::get_str(LATEST_VIEW_ID) {
|
||||
if view_id == params.value {
|
||||
pub(crate) async fn move_view_to_trash(&self, params: TextBlockIdPB) -> Result<(), FlowyError> {
|
||||
let view_id = params.value;
|
||||
if let Some(latest_view_id) = KV::get_str(LATEST_VIEW_ID) {
|
||||
if latest_view_id == view_id {
|
||||
let _ = KV::remove(LATEST_VIEW_ID);
|
||||
}
|
||||
}
|
||||
let processor = self.get_data_processor_from_view_id(¶ms.value).await?;
|
||||
let _ = processor.delete_container(¶ms.value).await?;
|
||||
let view_id_pb = ViewIdPB::from(view_id.as_str());
|
||||
send_dart_notification(&view_id, FolderNotification::ViewMoveToTrash)
|
||||
.payload(view_id_pb)
|
||||
.send();
|
||||
|
||||
let processor = self.get_data_processor_from_view_id(&view_id).await?;
|
||||
let _ = processor.close_container(&view_id).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ pub(crate) async fn read_view_info_handler(
|
||||
controller: AppData<Arc<ViewController>>,
|
||||
) -> DataResult<ViewInfoPB, FlowyError> {
|
||||
let view_id: ViewIdPB = data.into_inner();
|
||||
let view_info = controller.read_view_info(view_id.clone()).await?;
|
||||
let view_info = controller.read_view_pb(view_id.clone()).await?;
|
||||
data_result(view_info)
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ pub(crate) async fn delete_view_handler(
|
||||
) -> Result<(), FlowyError> {
|
||||
let params: RepeatedViewIdPB = data.into_inner();
|
||||
for view_id in ¶ms.items {
|
||||
let _ = view_controller.delete_view(view_id.into()).await;
|
||||
let _ = view_controller.move_view_to_trash(view_id.into()).await;
|
||||
}
|
||||
|
||||
let trash = view_controller
|
||||
|
Reference in New Issue
Block a user