dart_notification.rs 715 B

12345678910111213141516171819202122232425262728
  1. use dart_notify::DartNotifyBuilder;
  2. use flowy_derive::ProtoBuf_Enum;
  3. const OBSERVABLE_CATEGORY: &str = "User";
  4. #[derive(ProtoBuf_Enum, Debug)]
  5. pub(crate) enum UserNotification {
  6. Unknown = 0,
  7. UserAuthChanged = 1,
  8. UserProfileUpdated = 2,
  9. UserUnauthorized = 3,
  10. UserWsConnectStateChanged = 4,
  11. }
  12. impl std::default::Default for UserNotification {
  13. fn default() -> Self {
  14. UserNotification::Unknown
  15. }
  16. }
  17. impl std::convert::From<UserNotification> for i32 {
  18. fn from(notification: UserNotification) -> Self {
  19. notification as i32
  20. }
  21. }
  22. pub(crate) fn dart_notify(id: &str, ty: UserNotification) -> DartNotifyBuilder {
  23. DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
  24. }