chore: rename folder event (#4205)

This commit is contained in:
Nathan.fooo 2023-12-24 07:44:08 +08:00 committed by GitHub
parent a4a21c7e94
commit c033d56978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 53 additions and 53 deletions

View File

@ -6,13 +6,13 @@ import 'package:appflowy_backend/protobuf/flowy-folder2/trash.pb.dart';
class TrashService {
Future<Either<RepeatedTrashPB, FlowyError>> readTrash() {
return FolderEventReadTrash().send();
return FolderEventListTrashItems().send();
}
Future<Either<Unit, FlowyError>> putback(String trashId) {
final id = TrashIdPB.create()..id = trashId;
return FolderEventPutbackTrash(id).send();
return FolderEventRestoreTrashItem(id).send();
}
Future<Either<Unit, FlowyError>> deleteViews(List<String> trash) {
@ -21,14 +21,14 @@ class TrashService {
});
final ids = RepeatedTrashIdPB(items: items);
return FolderEventDeleteTrash(ids).send();
return FolderEventPermanentlyDeleteTrashItem(ids).send();
}
Future<Either<Unit, FlowyError>> restoreAll() {
return FolderEventRestoreAllTrash().send();
return FolderEventRecoverAllTrashItems().send();
}
Future<Either<Unit, FlowyError>> deleteAll() {
return FolderEventDeleteAllTrash().send();
return FolderEventPermanentlyDeleteAllTrashItem().send();
}
}

View File

@ -9,6 +9,6 @@ class HomeService {
Future<Either<ViewPB, FlowyError>> readApp({required String appId}) {
final payload = ViewIdPB.create()..value = appId;
return FolderEventReadView(payload).send();
return FolderEventGetView(payload).send();
}
}

View File

@ -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<Either<ViewPB, FlowyError>> 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),

View File

@ -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<Page[]> {
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)];

View File

@ -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 }) => {

View File

@ -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();
};
}

View File

@ -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(),
})

View File

@ -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<String>) {
pub async fn read_trash(sdk: &EventIntegrationTest) -> RepeatedTrashPB {
EventBuilder::new(sdk.clone())
.event(ReadTrash)
.event(ListTrashItems)
.async_send()
.await
.parse::<RepeatedTrashPB>()
@ -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;
}

View File

@ -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::<flowy_folder2::entities::RepeatedTrashPB>()
@ -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::<flowy_folder2::entities::RepeatedTrashPB>()
@ -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::<flowy_folder2::entities::RepeatedTrashPB>()
@ -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::<flowy_folder2::entities::RepeatedTrashPB>()
@ -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

View File

@ -18,7 +18,7 @@ pub fn init(folder: Weak<FolderManager>) -> 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<FolderManager>) -> 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,