dart_notification.rs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. UserUnauthorized = 100,
  19. TrashUpdated = 1000,
  20. }
  21. impl std::default::Default for FolderNotification {
  22. fn default() -> Self {
  23. FolderNotification::Unknown
  24. }
  25. }
  26. impl std::convert::From<FolderNotification> for i32 {
  27. fn from(notification: FolderNotification) -> Self {
  28. notification as i32
  29. }
  30. }
  31. #[tracing::instrument(level = "trace")]
  32. pub(crate) fn send_dart_notification(id: &str, ty: FolderNotification) -> DartNotifyBuilder {
  33. DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
  34. }
  35. #[tracing::instrument(level = "trace")]
  36. pub(crate) fn send_anonymous_dart_notification(ty: FolderNotification) -> DartNotifyBuilder {
  37. DartNotifyBuilder::new("", ty, OBSERVABLE_CATEGORY)
  38. }