2023-07-29 01:46:24 +00:00
|
|
|
use std::sync::Weak;
|
2023-04-04 00:41:16 +00:00
|
|
|
|
2023-06-14 14:16:33 +00:00
|
|
|
use strum_macros::Display;
|
|
|
|
|
|
|
|
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
2023-04-04 00:41:16 +00:00
|
|
|
use lib_dispatch::prelude::*;
|
2023-05-23 15:55:21 +00:00
|
|
|
|
2023-06-14 14:16:33 +00:00
|
|
|
use crate::event_handler::*;
|
2023-07-05 12:57:09 +00:00
|
|
|
use crate::manager::FolderManager;
|
2023-04-04 00:41:16 +00:00
|
|
|
|
2023-07-29 01:46:24 +00:00
|
|
|
pub fn init(folder: Weak<FolderManager>) -> AFPlugin {
|
2023-04-04 00:41:16 +00:00
|
|
|
AFPlugin::new().name("Flowy-Folder").state(folder)
|
|
|
|
// Workspace
|
2024-03-13 07:07:52 +00:00
|
|
|
.event(FolderEvent::CreateFolderWorkspace, create_workspace_handler)
|
2023-11-05 06:00:24 +00:00
|
|
|
.event(FolderEvent::GetCurrentWorkspaceSetting, read_current_workspace_setting_handler)
|
2023-11-01 03:45:35 +00:00
|
|
|
.event(FolderEvent::ReadCurrentWorkspace, read_current_workspace_handler)
|
2023-07-14 05:37:13 +00:00
|
|
|
.event(FolderEvent::ReadWorkspaceViews, get_workspace_views_handler)
|
2023-04-04 00:41:16 +00:00
|
|
|
.event(FolderEvent::CreateView, create_view_handler)
|
2023-06-14 14:16:33 +00:00
|
|
|
.event(FolderEvent::CreateOrphanView, create_orphan_view_handler)
|
2024-03-15 14:58:55 +00:00
|
|
|
.event(FolderEvent::GetView, get_view_handler)
|
2024-04-23 13:46:57 +00:00
|
|
|
.event(FolderEvent::GetAllViews, get_all_views_handler)
|
2023-04-04 00:41:16 +00:00
|
|
|
.event(FolderEvent::UpdateView, update_view_handler)
|
|
|
|
.event(FolderEvent::DeleteView, delete_view_handler)
|
|
|
|
.event(FolderEvent::DuplicateView, duplicate_view_handler)
|
|
|
|
.event(FolderEvent::SetLatestView, set_latest_view_handler)
|
|
|
|
.event(FolderEvent::CloseView, close_view_handler)
|
2023-06-05 08:09:18 +00:00
|
|
|
.event(FolderEvent::MoveView, move_view_handler)
|
2023-07-26 08:49:50 +00:00
|
|
|
.event(FolderEvent::MoveNestedView, move_nested_view_handler)
|
2023-12-23 23:44:08 +00:00
|
|
|
.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)
|
2024-03-22 09:15:18 +00:00
|
|
|
.event(FolderEvent::PermanentlyDeleteAllTrashItem, delete_my_trash_handler)
|
2023-05-31 06:08:54 +00:00
|
|
|
.event(FolderEvent::ImportData, import_data_handler)
|
2023-08-21 16:19:15 +00:00
|
|
|
.event(FolderEvent::GetFolderSnapshots, get_folder_snapshots_handler)
|
|
|
|
.event(FolderEvent::UpdateViewIcon, update_view_icon_handler)
|
2023-08-02 13:20:51 +00:00
|
|
|
.event(FolderEvent::ReadFavorites, read_favorites_handler)
|
2023-11-13 02:07:46 +00:00
|
|
|
.event(FolderEvent::ReadRecentViews, read_recent_views_handler)
|
2023-08-02 13:20:51 +00:00
|
|
|
.event(FolderEvent::ToggleFavorite, toggle_favorites_handler)
|
2023-12-01 01:58:36 +00:00
|
|
|
.event(FolderEvent::UpdateRecentViews, update_recent_views_handler)
|
2024-03-21 04:02:03 +00:00
|
|
|
.event(FolderEvent::ReadPrivateViews, read_private_views_handler)
|
|
|
|
.event(FolderEvent::ReadCurrentWorkspaceViews, get_current_workspace_views_handler)
|
2024-04-01 06:27:29 +00:00
|
|
|
.event(FolderEvent::UpdateViewVisibilityStatus, update_view_visibility_status_handler)
|
2024-04-09 00:58:53 +00:00
|
|
|
.event(FolderEvent::GetViewAncestors, get_view_ancestors_handler)
|
2024-07-08 05:45:57 +00:00
|
|
|
.event(FolderEvent::PublishView, publish_view_handler)
|
|
|
|
.event(FolderEvent::GetPublishInfo, get_publish_info_handler)
|
|
|
|
.event(FolderEvent::UnpublishViews, unpublish_views_handler)
|
|
|
|
.event(FolderEvent::SetPublishNamespace, set_publish_namespace_handler)
|
|
|
|
.event(FolderEvent::GetPublishNamespace, get_publish_namespace_handler)
|
2023-04-04 00:41:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
|
|
|
#[event_err = "FlowyError"]
|
|
|
|
pub enum FolderEvent {
|
|
|
|
/// Create a new workspace
|
|
|
|
#[event(input = "CreateWorkspacePayloadPB", output = "WorkspacePB")]
|
2024-03-13 07:07:52 +00:00
|
|
|
CreateFolderWorkspace = 0,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
2023-06-03 05:40:12 +00:00
|
|
|
/// Read the current opening workspace. Currently, we only support one workspace
|
2023-04-04 00:41:16 +00:00
|
|
|
#[event(output = "WorkspaceSettingPB")]
|
2023-11-01 03:45:35 +00:00
|
|
|
GetCurrentWorkspaceSetting = 1,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
2023-06-05 05:10:14 +00:00
|
|
|
/// Return a list of workspaces that the current user can access.
|
2023-11-01 03:45:35 +00:00
|
|
|
#[event(output = "WorkspacePB")]
|
|
|
|
ReadCurrentWorkspace = 2,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Delete the workspace
|
|
|
|
#[event(input = "WorkspaceIdPB")]
|
|
|
|
DeleteWorkspace = 3,
|
|
|
|
|
2024-03-21 04:02:03 +00:00
|
|
|
/// Return a list of views of the specified workspace.
|
2023-06-05 05:10:14 +00:00
|
|
|
/// Only the first level of child views are included.
|
2024-03-21 04:02:03 +00:00
|
|
|
#[event(input = "GetWorkspaceViewPB", output = "RepeatedViewPB")]
|
2023-06-03 05:40:12 +00:00
|
|
|
ReadWorkspaceViews = 5,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Create a new view in the corresponding app
|
|
|
|
#[event(input = "CreateViewPayloadPB", output = "ViewPB")]
|
2023-05-31 06:08:54 +00:00
|
|
|
CreateView = 10,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Return the view info
|
|
|
|
#[event(input = "ViewIdPB", output = "ViewPB")]
|
2023-12-23 23:44:08 +00:00
|
|
|
GetView = 11,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Update the view's properties including the name,description, etc.
|
|
|
|
#[event(input = "UpdateViewPayloadPB", output = "ViewPB")]
|
2023-05-31 06:08:54 +00:00
|
|
|
UpdateView = 12,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Move the view to the trash folder
|
|
|
|
#[event(input = "RepeatedViewIdPB")]
|
2023-05-31 06:08:54 +00:00
|
|
|
DeleteView = 13,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Duplicate the view
|
2024-06-25 02:03:02 +00:00
|
|
|
#[event(input = "DuplicateViewPayloadPB")]
|
2023-05-31 06:08:54 +00:00
|
|
|
DuplicateView = 14,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Close and release the resources that are used by this view.
|
|
|
|
/// It should get called when the 'View' page get destroy
|
|
|
|
#[event(input = "ViewIdPB")]
|
2023-05-31 06:08:54 +00:00
|
|
|
CloseView = 15,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
2023-06-14 14:16:33 +00:00
|
|
|
/// Create a new view in the corresponding app
|
|
|
|
#[event(input = "CreateOrphanViewPayloadPB", output = "ViewPB")]
|
|
|
|
CreateOrphanView = 16,
|
|
|
|
|
2024-04-23 13:46:57 +00:00
|
|
|
/// Return the view info
|
|
|
|
#[event(output = "RepeatedViewPB")]
|
|
|
|
GetAllViews = 17,
|
|
|
|
|
2023-04-04 00:41:16 +00:00
|
|
|
#[event()]
|
2023-05-31 06:08:54 +00:00
|
|
|
CopyLink = 20,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Set the current visiting view
|
|
|
|
#[event(input = "ViewIdPB")]
|
2023-05-31 06:08:54 +00:00
|
|
|
SetLatestView = 21,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Move the view or app to another place
|
2023-06-05 08:09:18 +00:00
|
|
|
#[event(input = "MoveViewPayloadPB")]
|
|
|
|
MoveView = 22,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Read the trash that was deleted by the user
|
|
|
|
#[event(output = "RepeatedTrashPB")]
|
2023-12-23 23:44:08 +00:00
|
|
|
ListTrashItems = 23,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Put back the trash to the origin folder
|
|
|
|
#[event(input = "TrashIdPB")]
|
2023-12-23 23:44:08 +00:00
|
|
|
RestoreTrashItem = 24,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Delete the trash from the disk
|
|
|
|
#[event(input = "RepeatedTrashIdPB")]
|
2023-12-23 23:44:08 +00:00
|
|
|
PermanentlyDeleteTrashItem = 25,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Put back all the trash to its original folder
|
|
|
|
#[event()]
|
2023-12-23 23:44:08 +00:00
|
|
|
RecoverAllTrashItems = 26,
|
2023-04-04 00:41:16 +00:00
|
|
|
|
|
|
|
/// Delete all the trash from the disk
|
|
|
|
#[event()]
|
2023-12-23 23:44:08 +00:00
|
|
|
PermanentlyDeleteAllTrashItem = 27,
|
2023-05-31 06:08:54 +00:00
|
|
|
|
2024-07-01 06:44:08 +00:00
|
|
|
#[event(input = "ImportPayloadPB", output = "RepeatedViewPB")]
|
2023-05-31 06:08:54 +00:00
|
|
|
ImportData = 30,
|
2023-07-05 12:57:09 +00:00
|
|
|
|
2023-08-21 16:19:15 +00:00
|
|
|
#[event(input = "WorkspaceIdPB", output = "RepeatedFolderSnapshotPB")]
|
2023-07-05 12:57:09 +00:00
|
|
|
GetFolderSnapshots = 31,
|
2023-07-26 08:49:50 +00:00
|
|
|
/// Moves a nested view to a new location in the hierarchy.
|
|
|
|
///
|
|
|
|
/// This function takes the `view_id` of the view to be moved,
|
|
|
|
/// `new_parent_id` of the view under which the `view_id` should be moved,
|
|
|
|
/// and an optional `prev_view_id` to position the `view_id` right after
|
|
|
|
/// this specific view.
|
|
|
|
#[event(input = "MoveNestedViewPayloadPB")]
|
|
|
|
MoveNestedView = 32,
|
2023-08-02 13:20:51 +00:00
|
|
|
|
2024-05-27 00:51:49 +00:00
|
|
|
#[event(output = "RepeatedFavoriteViewPB")]
|
2023-08-02 13:20:51 +00:00
|
|
|
ReadFavorites = 33,
|
|
|
|
|
|
|
|
#[event(input = "RepeatedViewIdPB")]
|
|
|
|
ToggleFavorite = 34,
|
2023-08-04 11:27:14 +00:00
|
|
|
|
|
|
|
#[event(input = "UpdateViewIconPayloadPB")]
|
|
|
|
UpdateViewIcon = 35,
|
2023-11-13 02:07:46 +00:00
|
|
|
|
2024-07-15 06:23:20 +00:00
|
|
|
#[event(input = "ReadRecentViewsPB", output = "RepeatedRecentViewPB")]
|
2023-11-13 02:07:46 +00:00
|
|
|
ReadRecentViews = 36,
|
2023-12-01 01:58:36 +00:00
|
|
|
|
|
|
|
// used for add or remove recent views, like history
|
|
|
|
#[event(input = "UpdateRecentViewPayloadPB")]
|
|
|
|
UpdateRecentViews = 37,
|
2024-02-08 15:53:05 +00:00
|
|
|
|
2024-03-21 04:02:03 +00:00
|
|
|
#[event(input = "GetWorkspaceViewPB", output = "RepeatedViewPB")]
|
|
|
|
ReadPrivateViews = 39,
|
|
|
|
|
|
|
|
/// Return a list of views of the current workspace.
|
|
|
|
/// Only the first level of child views are included.
|
|
|
|
#[event(output = "RepeatedViewPB")]
|
|
|
|
ReadCurrentWorkspaceViews = 40,
|
2024-04-01 06:27:29 +00:00
|
|
|
|
|
|
|
#[event(input = "UpdateViewVisibilityStatusPayloadPB")]
|
|
|
|
UpdateViewVisibilityStatus = 41,
|
2024-04-09 00:58:53 +00:00
|
|
|
|
|
|
|
/// Return the ancestors of the view
|
|
|
|
#[event(input = "ViewIdPB", output = "RepeatedViewPB")]
|
|
|
|
GetViewAncestors = 42,
|
2024-07-08 05:45:57 +00:00
|
|
|
|
|
|
|
#[event(input = "PublishViewParamsPB")]
|
|
|
|
PublishView = 43,
|
|
|
|
|
|
|
|
#[event(input = "ViewIdPB", output = "PublishInfoResponsePB")]
|
|
|
|
GetPublishInfo = 44,
|
|
|
|
|
|
|
|
#[event(output = "PublishNamespacePB")]
|
|
|
|
GetPublishNamespace = 45,
|
|
|
|
|
|
|
|
#[event(input = "SetPublishNamespacePayloadPB")]
|
|
|
|
SetPublishNamespace = 46,
|
|
|
|
|
|
|
|
#[event(input = "UnpublishViewsPayloadPB")]
|
|
|
|
UnpublishViews = 47,
|
2023-04-04 00:41:16 +00:00
|
|
|
}
|