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

39 lines
1.2 KiB
Rust
Raw Normal View History

2021-11-19 15:00:51 +08:00
use dart_notify::DartNotifyBuilder;
2021-07-21 15:43:05 +08:00
use flowy_derive::ProtoBuf_Enum;
2021-11-27 19:19:41 +08:00
const OBSERVABLE_CATEGORY: &str = "Workspace";
2021-07-21 15:43:05 +08:00
#[derive(ProtoBuf_Enum, Debug)]
2021-10-14 14:34:22 +08:00
pub(crate) enum WorkspaceNotification {
2021-09-06 16:18:34 +08:00
Unknown = 0,
UserCreateWorkspace = 10,
UserDeleteWorkspace = 11,
WorkspaceUpdated = 12,
2021-10-30 17:19:50 +08:00
WorkspaceListUpdated = 13,
WorkspaceAppsChanged = 14,
2021-09-06 16:18:34 +08:00
AppUpdated = 21,
2021-10-13 23:11:45 +08:00
AppViewsChanged = 24,
2021-09-06 16:18:34 +08:00
ViewUpdated = 31,
ViewDeleted = 32,
ViewRestored = 33,
UserUnauthorized = 100,
2021-10-14 14:34:22 +08:00
TrashUpdated = 1000,
2021-07-21 15:43:05 +08:00
}
2021-10-14 14:34:22 +08:00
impl std::default::Default for WorkspaceNotification {
fn default() -> Self { WorkspaceNotification::Unknown }
2021-07-21 15:43:05 +08:00
}
2021-11-27 19:19:41 +08:00
impl std::convert::From<WorkspaceNotification> for i32 {
fn from(notification: WorkspaceNotification) -> Self { notification as i32 }
2021-07-21 15:43:05 +08:00
}
2021-10-14 14:34:22 +08:00
#[tracing::instrument(level = "debug")]
pub(crate) fn send_dart_notification(id: &str, ty: WorkspaceNotification) -> DartNotifyBuilder {
2021-10-05 11:46:56 +08:00
DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
}
2021-10-14 14:34:22 +08:00
#[tracing::instrument(level = "debug")]
pub(crate) fn send_anonymous_dart_notification(ty: WorkspaceNotification) -> DartNotifyBuilder {
DartNotifyBuilder::new("", ty, OBSERVABLE_CATEGORY)
}