notification.rs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. use flowy_derive::ProtoBuf_Enum;
  2. use flowy_notification::NotificationBuilder;
  3. const OBSERVABLE_CATEGORY: &str = "Workspace";
  4. #[derive(ProtoBuf_Enum, Debug)]
  5. pub(crate) enum FolderNotification {
  6. Unknown = 0,
  7. /// Trigger after creating a workspace
  8. DidCreateWorkspace = 1,
  9. /// Trigger after deleting a workspace
  10. DidDeleteWorkspace = 2,
  11. /// Trigger after updating a workspace
  12. DidUpdateWorkspace = 3,
  13. /// Trigger when the number of apps of the workspace is changed
  14. DidUpdateWorkspaceApps = 4,
  15. /// Trigger when the settings of the workspace are changed. The changes including the latest visiting view, etc
  16. DidUpdateWorkspaceSetting = 5,
  17. /// Trigger when the properties including rename,update description of the app are changed
  18. DidUpdateApp = 20,
  19. /// Trigger when the properties including rename,update description of the view are changed
  20. DidUpdateView = 30,
  21. /// Trigger after deleting the view
  22. DidDeleteView = 31,
  23. /// Trigger when restore the view from trash
  24. DidRestoreView = 32,
  25. /// Trigger after moving the view to trash
  26. DidMoveViewToTrash = 33,
  27. /// Trigger when the number of trash is changed
  28. DidUpdateTrash = 34,
  29. }
  30. impl std::default::Default for FolderNotification {
  31. fn default() -> Self {
  32. FolderNotification::Unknown
  33. }
  34. }
  35. impl std::convert::From<FolderNotification> for i32 {
  36. fn from(notification: FolderNotification) -> Self {
  37. notification as i32
  38. }
  39. }
  40. #[tracing::instrument(level = "trace")]
  41. pub(crate) fn send_notification(id: &str, ty: FolderNotification) -> NotificationBuilder {
  42. NotificationBuilder::new(id, ty, OBSERVABLE_CATEGORY)
  43. }
  44. #[tracing::instrument(level = "trace")]
  45. pub(crate) fn send_anonymous_notification(ty: FolderNotification) -> NotificationBuilder {
  46. NotificationBuilder::new("", ty, OBSERVABLE_CATEGORY)
  47. }