dart_notification.rs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. use dart_notify::DartNotifyBuilder;
  2. use flowy_derive::ProtoBuf_Enum;
  3. const OBSERVABLE_CATEGORY: &str = "Workspace";
  4. #[derive(ProtoBuf_Enum, Debug)]
  5. pub(crate) enum FolderNotification {
  6. Unknown = 0,
  7. UserCreateWorkspace = 10,
  8. UserDeleteWorkspace = 11,
  9. WorkspaceUpdated = 12,
  10. WorkspaceListUpdated = 13,
  11. WorkspaceAppsChanged = 14,
  12. WorkspaceSetting = 15,
  13. AppUpdated = 21,
  14. AppViewsChanged = 24,
  15. ViewUpdated = 31,
  16. ViewDeleted = 32,
  17. ViewRestored = 33,
  18. ViewMoveToTrash = 34,
  19. UserUnauthorized = 100,
  20. TrashUpdated = 1000,
  21. }
  22. impl std::default::Default for FolderNotification {
  23. fn default() -> Self {
  24. FolderNotification::Unknown
  25. }
  26. }
  27. impl std::convert::From<FolderNotification> for i32 {
  28. fn from(notification: FolderNotification) -> Self {
  29. notification as i32
  30. }
  31. }
  32. #[tracing::instrument(level = "trace")]
  33. pub(crate) fn send_dart_notification(id: &str, ty: FolderNotification) -> DartNotifyBuilder {
  34. DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
  35. }
  36. #[tracing::instrument(level = "trace")]
  37. pub(crate) fn send_anonymous_dart_notification(ty: FolderNotification) -> DartNotifyBuilder {
  38. DartNotifyBuilder::new("", ty, OBSERVABLE_CATEGORY)
  39. }