dart_notification.rs 1.2 KB

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