From c033d56978a16f99cfe9cbc18b49484d82e25d47 Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Sun, 24 Dec 2023 07:44:08 +0800 Subject: [PATCH] chore: rename folder event (#4205) --- .../trash/application/trash_service.dart | 10 ++++---- .../application/home/home_service.dart | 2 +- .../application/view/view_service.dart | 6 ++--- .../database_view/database_view_service.ts | 4 ++-- .../effects/workspace/page/page_bd_svc.ts | 4 ++-- .../stores/effects/workspace/trash/bd_svc.ts | 20 ++++++++-------- .../event-integration/src/folder_event.rs | 4 ++-- .../tests/folder/local_test/script.rs | 10 ++++---- .../tests/folder/local_test/test.rs | 22 ++++++++--------- .../rust-lib/flowy-folder2/src/event_map.rs | 24 +++++++++---------- 10 files changed, 53 insertions(+), 53 deletions(-) diff --git a/frontend/appflowy_flutter/lib/plugins/trash/application/trash_service.dart b/frontend/appflowy_flutter/lib/plugins/trash/application/trash_service.dart index 29fb9f13c1..718f7b01ae 100644 --- a/frontend/appflowy_flutter/lib/plugins/trash/application/trash_service.dart +++ b/frontend/appflowy_flutter/lib/plugins/trash/application/trash_service.dart @@ -6,13 +6,13 @@ import 'package:appflowy_backend/protobuf/flowy-folder2/trash.pb.dart'; class TrashService { Future> readTrash() { - return FolderEventReadTrash().send(); + return FolderEventListTrashItems().send(); } Future> putback(String trashId) { final id = TrashIdPB.create()..id = trashId; - return FolderEventPutbackTrash(id).send(); + return FolderEventRestoreTrashItem(id).send(); } Future> deleteViews(List trash) { @@ -21,14 +21,14 @@ class TrashService { }); final ids = RepeatedTrashIdPB(items: items); - return FolderEventDeleteTrash(ids).send(); + return FolderEventPermanentlyDeleteTrashItem(ids).send(); } Future> restoreAll() { - return FolderEventRestoreAllTrash().send(); + return FolderEventRecoverAllTrashItems().send(); } Future> deleteAll() { - return FolderEventDeleteAllTrash().send(); + return FolderEventPermanentlyDeleteAllTrashItem().send(); } } diff --git a/frontend/appflowy_flutter/lib/workspace/application/home/home_service.dart b/frontend/appflowy_flutter/lib/workspace/application/home/home_service.dart index dd1c19b2b7..9bfb40ca49 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/home/home_service.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/home/home_service.dart @@ -9,6 +9,6 @@ class HomeService { Future> readApp({required String appId}) { final payload = ViewIdPB.create()..value = appId; - return FolderEventReadView(payload).send(); + return FolderEventGetView(payload).send(); } } diff --git a/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart b/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart index 8536d50fdc..e8c3de5a52 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/view/view_service.dart @@ -107,7 +107,7 @@ class ViewBackendService { }) { final payload = ViewIdPB.create()..value = viewId; - return FolderEventReadView(payload).send().then((result) { + return FolderEventGetView(payload).send().then((result) { return result.fold( (view) => left(view.childViews), (error) => right(error), @@ -247,7 +247,7 @@ class ViewBackendService { String viewID, ) async { final payload = ViewIdPB.create()..value = viewID; - return FolderEventReadView(payload).send(); + return FolderEventGetView(payload).send(); } Future> getChildView({ @@ -255,7 +255,7 @@ class ViewBackendService { required String childViewId, }) async { final payload = ViewIdPB.create()..value = parentViewId; - return FolderEventReadView(payload).send().then((result) { + return FolderEventGetView(payload).send().then((result) { return result.fold( (app) => left( app.childViews.firstWhere((e) => e.id == childViewId), diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/database/application/database_view/database_view_service.ts b/frontend/appflowy_tauri/src/appflowy_app/components/database/application/database_view/database_view_service.ts index 061139dc96..7d8d41f611 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/database/application/database_view/database_view_service.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/components/database/application/database_view/database_view_service.ts @@ -2,7 +2,7 @@ import { CreateViewPayloadPB, RepeatedViewIdPB, UpdateViewPayloadPB, ViewIdPB, V import { FolderEventCreateView, FolderEventDeleteView, - FolderEventReadView, + FolderEventGetView, FolderEventUpdateView, } from '@/services/backend/events/flowy-folder2'; import { databaseService } from '../database'; @@ -11,7 +11,7 @@ import { Page, parserViewPBToPage } from '$app_reducers/pages/slice'; export async function getDatabaseViews(viewId: string): Promise { const payload = ViewIdPB.fromObject({ value: viewId }); - const result = await FolderEventReadView(payload); + const result = await FolderEventGetView(payload); if (result.ok) { return [parserViewPBToPage(result.val), ...result.val.child_views.map(parserViewPBToPage)]; diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/workspace/page/page_bd_svc.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/workspace/page/page_bd_svc.ts index 35885e4660..23bc06608e 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/workspace/page/page_bd_svc.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/workspace/page/page_bd_svc.ts @@ -1,5 +1,4 @@ import { - FolderEventReadView, FolderEventCreateView, FolderEventUpdateView, FolderEventDeleteView, @@ -19,6 +18,7 @@ import { FolderEventUpdateViewIcon, FolderEventCreateOrphanView, CreateOrphanViewPayloadPB, + FolderEventGetView, } from '@/services/backend/events/flowy-folder2'; import { Page, PageIcon } from '$app_reducers/pages/slice'; @@ -32,7 +32,7 @@ export class PageBackendService { value: viewId, }); - return FolderEventReadView(payload); + return FolderEventGetView(payload); }; movePage = async (params: { viewId: string; parentId: string; prevId?: string }) => { diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/workspace/trash/bd_svc.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/workspace/trash/bd_svc.ts index b81ee0b4b4..5f174d9eb7 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/workspace/trash/bd_svc.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/workspace/trash/bd_svc.ts @@ -1,11 +1,11 @@ import { - FolderEventReadTrash, - FolderEventPutbackTrash, - FolderEventDeleteAllTrash, - FolderEventRestoreAllTrash, - FolderEventDeleteTrash, TrashIdPB, RepeatedTrashIdPB, + FolderEventListTrashItems, + FolderEventRestoreTrashItem, + FolderEventPermanentlyDeleteTrashItem, + FolderEventPermanentlyDeleteAllTrashItem, + FolderEventRecoverAllTrashItems, } from '@/services/backend/events/flowy-folder2'; export class TrashBackendService { @@ -14,7 +14,7 @@ export class TrashBackendService { } getTrash = async () => { - return FolderEventReadTrash(); + return FolderEventListTrashItems(); }; putback = async (id: string) => { @@ -22,7 +22,7 @@ export class TrashBackendService { id, }); - return FolderEventPutbackTrash(payload); + return FolderEventRestoreTrashItem(payload); }; delete = async (ids: string[]) => { @@ -31,14 +31,14 @@ export class TrashBackendService { items, }); - return FolderEventDeleteTrash(payload); + return FolderEventPermanentlyDeleteTrashItem(payload); }; deleteAll = async () => { - return FolderEventDeleteAllTrash(); + return FolderEventPermanentlyDeleteAllTrashItem(); }; restoreAll = async () => { - return FolderEventRestoreAllTrash(); + return FolderEventRecoverAllTrashItems(); }; } diff --git a/frontend/rust-lib/event-integration/src/folder_event.rs b/frontend/rust-lib/event-integration/src/folder_event.rs index df06634bd8..64d1d4d38f 100644 --- a/frontend/rust-lib/event-integration/src/folder_event.rs +++ b/frontend/rust-lib/event-integration/src/folder_event.rs @@ -66,7 +66,7 @@ impl EventIntegrationTest { pub async fn get_views(&self, parent_view_id: &str) -> ViewPB { EventBuilder::new(self.clone()) - .event(FolderEvent::ReadView) + .event(FolderEvent::GetView) .payload(ViewIdPB { value: parent_view_id.to_string(), }) @@ -129,7 +129,7 @@ impl EventIntegrationTest { pub async fn get_view(&self, view_id: &str) -> ViewPB { EventBuilder::new(self.clone()) - .event(FolderEvent::ReadView) + .event(FolderEvent::GetView) .payload(ViewIdPB { value: view_id.to_string(), }) diff --git a/frontend/rust-lib/event-integration/tests/folder/local_test/script.rs b/frontend/rust-lib/event-integration/tests/folder/local_test/script.rs index bf1c00e883..635d63039c 100644 --- a/frontend/rust-lib/event-integration/tests/folder/local_test/script.rs +++ b/frontend/rust-lib/event-integration/tests/folder/local_test/script.rs @@ -258,7 +258,7 @@ pub async fn create_view( pub async fn read_view(sdk: &EventIntegrationTest, view_id: &str) -> ViewPB { let view_id = ViewIdPB::from(view_id); EventBuilder::new(sdk.clone()) - .event(ReadView) + .event(GetView) .payload(view_id) .async_send() .await @@ -330,7 +330,7 @@ pub async fn delete_view(sdk: &EventIntegrationTest, view_ids: Vec) { pub async fn read_trash(sdk: &EventIntegrationTest) -> RepeatedTrashPB { EventBuilder::new(sdk.clone()) - .event(ReadTrash) + .event(ListTrashItems) .async_send() .await .parse::() @@ -341,7 +341,7 @@ pub async fn restore_app_from_trash(sdk: &EventIntegrationTest, app_id: &str) { id: app_id.to_owned(), }; EventBuilder::new(sdk.clone()) - .event(PutbackTrash) + .event(RestoreTrashItem) .payload(id) .async_send() .await; @@ -352,7 +352,7 @@ pub async fn restore_view_from_trash(sdk: &EventIntegrationTest, view_id: &str) id: view_id.to_owned(), }; EventBuilder::new(sdk.clone()) - .event(PutbackTrash) + .event(RestoreTrashItem) .payload(id) .async_send() .await; @@ -360,7 +360,7 @@ pub async fn restore_view_from_trash(sdk: &EventIntegrationTest, view_id: &str) pub async fn delete_all_trash(sdk: &EventIntegrationTest) { EventBuilder::new(sdk.clone()) - .event(DeleteAllTrash) + .event(PermanentlyDeleteAllTrashItem) .async_send() .await; } diff --git a/frontend/rust-lib/event-integration/tests/folder/local_test/test.rs b/frontend/rust-lib/event-integration/tests/folder/local_test/test.rs index 24b64110c3..36b7e8c613 100644 --- a/frontend/rust-lib/event-integration/tests/folder/local_test/test.rs +++ b/frontend/rust-lib/event-integration/tests/folder/local_test/test.rs @@ -122,7 +122,7 @@ async fn delete_view_event_test() { value: view.id.clone(), }; let error = EventBuilder::new(test.clone()) - .event(flowy_folder2::event_map::FolderEvent::ReadView) + .event(flowy_folder2::event_map::FolderEvent::GetView) .payload(payload) .async_send() .await @@ -145,7 +145,7 @@ async fn put_back_trash_event_test() { value: view.id.clone(), }; let error = EventBuilder::new(test.clone()) - .event(flowy_folder2::event_map::FolderEvent::ReadView) + .event(flowy_folder2::event_map::FolderEvent::GetView) .payload(payload) .async_send() .await @@ -157,7 +157,7 @@ async fn put_back_trash_event_test() { id: view.id.clone(), }; EventBuilder::new(test.clone()) - .event(flowy_folder2::event_map::FolderEvent::PutbackTrash) + .event(flowy_folder2::event_map::FolderEvent::RestoreTrashItem) .payload(payload) .async_send() .await; @@ -166,7 +166,7 @@ async fn put_back_trash_event_test() { value: view.id.clone(), }; let error = EventBuilder::new(test.clone()) - .event(flowy_folder2::event_map::FolderEvent::ReadView) + .event(flowy_folder2::event_map::FolderEvent::GetView) .payload(payload) .async_send() .await @@ -193,7 +193,7 @@ async fn delete_view_permanently_event_test() { .await; let trash = EventBuilder::new(test.clone()) - .event(flowy_folder2::event_map::FolderEvent::ReadTrash) + .event(flowy_folder2::event_map::FolderEvent::ListTrashItems) .async_send() .await .parse::() @@ -208,14 +208,14 @@ async fn delete_view_permanently_event_test() { }], }; EventBuilder::new(test.clone()) - .event(flowy_folder2::event_map::FolderEvent::DeleteTrash) + .event(flowy_folder2::event_map::FolderEvent::PermanentlyDeleteTrashItem) .payload(payload) .async_send() .await; // After delete the last view, the trash should be empty let trash = EventBuilder::new(test.clone()) - .event(flowy_folder2::event_map::FolderEvent::ReadTrash) + .event(flowy_folder2::event_map::FolderEvent::ListTrashItems) .async_send() .await .parse::() @@ -244,7 +244,7 @@ async fn delete_all_trash_test() { } let trash = EventBuilder::new(test.clone()) - .event(flowy_folder2::event_map::FolderEvent::ReadTrash) + .event(flowy_folder2::event_map::FolderEvent::ListTrashItems) .async_send() .await .parse::() @@ -253,13 +253,13 @@ async fn delete_all_trash_test() { // Delete all the trash EventBuilder::new(test.clone()) - .event(flowy_folder2::event_map::FolderEvent::DeleteAllTrash) + .event(flowy_folder2::event_map::FolderEvent::PermanentlyDeleteAllTrashItem) .async_send() .await; // After delete the last view, the trash should be empty let trash = EventBuilder::new(test.clone()) - .event(flowy_folder2::event_map::FolderEvent::ReadTrash) + .event(flowy_folder2::event_map::FolderEvent::ListTrashItems) .async_send() .await .parse::() @@ -323,7 +323,7 @@ async fn multiple_hierarchy_view_test() { }; let child = EventBuilder::new(test.clone()) - .event(flowy_folder2::event_map::FolderEvent::ReadView) + .event(flowy_folder2::event_map::FolderEvent::GetView) .payload(payload) .async_send() .await diff --git a/frontend/rust-lib/flowy-folder2/src/event_map.rs b/frontend/rust-lib/flowy-folder2/src/event_map.rs index 75b5b9cfe5..573ff9c727 100644 --- a/frontend/rust-lib/flowy-folder2/src/event_map.rs +++ b/frontend/rust-lib/flowy-folder2/src/event_map.rs @@ -18,7 +18,7 @@ pub fn init(folder: Weak) -> AFPlugin { // View .event(FolderEvent::CreateView, create_view_handler) .event(FolderEvent::CreateOrphanView, create_orphan_view_handler) - .event(FolderEvent::ReadView, read_view_handler) + .event(FolderEvent::GetView, read_view_handler) .event(FolderEvent::UpdateView, update_view_handler) .event(FolderEvent::DeleteView, delete_view_handler) .event(FolderEvent::DuplicateView, duplicate_view_handler) @@ -27,11 +27,11 @@ pub fn init(folder: Weak) -> AFPlugin { .event(FolderEvent::MoveView, move_view_handler) .event(FolderEvent::MoveNestedView, move_nested_view_handler) // Trash - .event(FolderEvent::ReadTrash, read_trash_handler) - .event(FolderEvent::PutbackTrash, putback_trash_handler) - .event(FolderEvent::DeleteTrash, delete_trash_handler) - .event(FolderEvent::RestoreAllTrash, restore_all_trash_handler) - .event(FolderEvent::DeleteAllTrash, delete_all_trash_handler) + .event(FolderEvent::ListTrashItems, read_trash_handler) + .event(FolderEvent::RestoreTrashItem, putback_trash_handler) + .event(FolderEvent::PermanentlyDeleteTrashItem, delete_trash_handler) + .event(FolderEvent::RecoverAllTrashItems, restore_all_trash_handler) + .event(FolderEvent::PermanentlyDeleteAllTrashItem, delete_all_trash_handler) .event(FolderEvent::ImportData, import_data_handler) .event(FolderEvent::GetFolderSnapshots, get_folder_snapshots_handler) .event(FolderEvent::UpdateViewIcon, update_view_icon_handler) @@ -71,7 +71,7 @@ pub enum FolderEvent { /// Return the view info #[event(input = "ViewIdPB", output = "ViewPB")] - ReadView = 11, + GetView = 11, /// Update the view's properties including the name,description, etc. #[event(input = "UpdateViewPayloadPB", output = "ViewPB")] @@ -107,23 +107,23 @@ pub enum FolderEvent { /// Read the trash that was deleted by the user #[event(output = "RepeatedTrashPB")] - ReadTrash = 23, + ListTrashItems = 23, /// Put back the trash to the origin folder #[event(input = "TrashIdPB")] - PutbackTrash = 24, + RestoreTrashItem = 24, /// Delete the trash from the disk #[event(input = "RepeatedTrashIdPB")] - DeleteTrash = 25, + PermanentlyDeleteTrashItem = 25, /// Put back all the trash to its original folder #[event()] - RestoreAllTrash = 26, + RecoverAllTrashItems = 26, /// Delete all the trash from the disk #[event()] - DeleteAllTrash = 27, + PermanentlyDeleteAllTrashItem = 27, #[event(input = "ImportPB")] ImportData = 30,