dart_notification.rs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 WorkspaceNotification {
  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 WorkspaceNotification {
  21. fn default() -> Self { WorkspaceNotification::Unknown }
  22. }
  23. impl std::convert::From<WorkspaceNotification> for i32 {
  24. fn from(notification: WorkspaceNotification) -> Self { notification as i32 }
  25. }
  26. #[tracing::instrument(level = "debug")]
  27. pub(crate) fn send_dart_notification(id: &str, ty: WorkspaceNotification) -> DartNotifyBuilder {
  28. DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
  29. }
  30. #[tracing::instrument(level = "debug")]
  31. pub(crate) fn send_anonymous_dart_notification(ty: WorkspaceNotification) -> DartNotifyBuilder {
  32. DartNotifyBuilder::new("", ty, OBSERVABLE_CATEGORY)
  33. }