AppFlowy/rust-lib/flowy-workspace/src/notify/observable.rs

33 lines
970 B
Rust
Raw Normal View History

use flowy_dart_notify::DartNotifyBuilder;
2021-07-21 07:43:05 +00:00
use flowy_derive::ProtoBuf_Enum;
const OBSERVABLE_CATEGORY: &'static str = "Workspace";
#[derive(ProtoBuf_Enum, Debug)]
2021-10-13 03:10:29 +00:00
pub(crate) enum Notification {
2021-09-06 08:18:34 +00:00
Unknown = 0,
UserCreateWorkspace = 10,
UserDeleteWorkspace = 11,
WorkspaceUpdated = 12,
WorkspaceCreateApp = 13,
WorkspaceDeleteApp = 14,
WorkspaceListUpdated = 15,
AppUpdated = 21,
2021-10-13 15:11:45 +00:00
AppViewsChanged = 24,
2021-09-06 08:18:34 +00:00
ViewUpdated = 31,
UserUnauthorized = 100,
2021-07-21 07:43:05 +00:00
}
2021-10-13 03:10:29 +00:00
impl std::default::Default for Notification {
fn default() -> Self { Notification::Unknown }
2021-07-21 07:43:05 +00:00
}
2021-10-13 03:10:29 +00:00
impl std::convert::Into<i32> for Notification {
2021-09-07 15:30:43 +00:00
fn into(self) -> i32 { self as i32 }
2021-07-21 07:43:05 +00:00
}
2021-10-13 03:10:29 +00:00
pub(crate) fn dart_notify(id: &str, ty: Notification) -> DartNotifyBuilder {
tracing::Span::current().record("dart_notify", &format!("{:?} => notify_id: {}", ty, id).as_str());
2021-10-05 03:46:56 +00:00
DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
}