AppFlowy/frontend/rust-lib/flowy-user/src/dart_notification.rs

29 lines
715 B
Rust
Raw Normal View History

2021-11-19 07:00:51 +00:00
use dart_notify::DartNotifyBuilder;
2021-12-05 01:29:42 +00:00
use flowy_derive::ProtoBuf_Enum;
2021-11-27 11:19:41 +00:00
const OBSERVABLE_CATEGORY: &str = "User";
2021-09-07 15:30:43 +00:00
#[derive(ProtoBuf_Enum, Debug)]
2021-10-14 06:34:22 +00:00
pub(crate) enum UserNotification {
2022-01-23 04:14:00 +00:00
Unknown = 0,
UserAuthChanged = 1,
2021-09-07 15:30:43 +00:00
UserProfileUpdated = 2,
2022-01-23 04:14:00 +00:00
UserUnauthorized = 3,
2021-12-04 09:31:32 +00:00
UserWsConnectStateChanged = 4,
2021-09-07 15:30:43 +00:00
}
2021-10-14 06:34:22 +00:00
impl std::default::Default for UserNotification {
2022-01-23 04:14:00 +00:00
fn default() -> Self {
UserNotification::Unknown
}
2021-09-07 15:30:43 +00:00
}
2021-11-27 11:19:41 +00:00
impl std::convert::From<UserNotification> for i32 {
2022-01-23 04:14:00 +00:00
fn from(notification: UserNotification) -> Self {
notification as i32
}
2021-09-07 15:30:43 +00:00
}
2021-10-14 06:34:22 +00:00
pub(crate) fn dart_notify(id: &str, ty: UserNotification) -> DartNotifyBuilder {
2021-10-05 03:46:56 +00:00
DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
}