2021-11-19 07:00:51 +00:00
|
|
|
use dart_notify::DartNotifyBuilder;
|
2021-12-04 15:54:14 +00:00
|
|
|
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
2021-09-07 15:30:43 +00:00
|
|
|
|
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 {
|
2021-09-07 15:30:43 +00:00
|
|
|
Unknown = 0,
|
|
|
|
UserAuthChanged = 1,
|
|
|
|
UserProfileUpdated = 2,
|
2021-09-08 05:50:20 +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 {
|
|
|
|
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 {
|
|
|
|
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)
|
|
|
|
}
|
2021-12-04 14:24:32 +00:00
|
|
|
|
2021-12-04 15:54:14 +00:00
|
|
|
#[derive(ProtoBuf_Enum, Debug, Clone)]
|
2021-12-04 14:24:32 +00:00
|
|
|
pub enum NetworkType {
|
|
|
|
UnknownNetworkType = 0,
|
|
|
|
Wifi = 1,
|
|
|
|
Cell = 2,
|
|
|
|
Ethernet = 3,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::default::Default for NetworkType {
|
|
|
|
fn default() -> Self { NetworkType::UnknownNetworkType }
|
|
|
|
}
|
|
|
|
|
2021-12-04 15:54:14 +00:00
|
|
|
#[derive(ProtoBuf, Debug, Default, Clone)]
|
2021-12-04 14:24:32 +00:00
|
|
|
pub struct NetworkState {
|
|
|
|
#[pb(index = 1)]
|
|
|
|
pub ty: NetworkType,
|
|
|
|
}
|