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