notification.rs 804 B

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