41 lines
1.3 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;
const OBSERVABLE_CATEGORY: &'static str = "Workspace";
// Opti: Using the Rust macro to generate the serde code automatically that can
// be use directly in flutter
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-10-14 14:34:22 +08:00
impl std::convert::Into<i32> for WorkspaceNotification {
2021-09-07 23:30:43 +08:00
fn into(self) -> i32 { self 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)
}