2021-10-05 03:52:50 +00:00
|
|
|
use flowy_dart_notify::DartNotifyBuilder;
|
2021-07-21 07:43:05 +00:00
|
|
|
use flowy_derive::ProtoBuf_Enum;
|
|
|
|
const OBSERVABLE_CATEGORY: &'static str = "Workspace";
|
|
|
|
|
2021-10-31 09:24:55 +00:00
|
|
|
// Opti: Using the Rust macro to generate the serde code automatically that can
|
|
|
|
// be use directly in flutter
|
2021-07-21 07:43:05 +00:00
|
|
|
#[derive(ProtoBuf_Enum, Debug)]
|
2021-10-14 06:34:22 +00:00
|
|
|
pub(crate) enum WorkspaceNotification {
|
2021-09-06 08:18:34 +00:00
|
|
|
Unknown = 0,
|
|
|
|
UserCreateWorkspace = 10,
|
|
|
|
UserDeleteWorkspace = 11,
|
|
|
|
WorkspaceUpdated = 12,
|
2021-10-30 09:19:50 +00:00
|
|
|
WorkspaceListUpdated = 13,
|
|
|
|
WorkspaceAppsChanged = 14,
|
2021-09-06 08:18:34 +00:00
|
|
|
AppUpdated = 21,
|
2021-10-13 15:11:45 +00:00
|
|
|
AppViewsChanged = 24,
|
2021-09-06 08:18:34 +00:00
|
|
|
ViewUpdated = 31,
|
2021-10-31 09:24:55 +00:00
|
|
|
ViewDeleted = 32,
|
|
|
|
ViewRestored = 33,
|
2021-09-08 05:50:20 +00:00
|
|
|
UserUnauthorized = 100,
|
2021-10-14 06:34:22 +00:00
|
|
|
TrashUpdated = 1000,
|
2021-07-21 07:43:05 +00:00
|
|
|
}
|
|
|
|
|
2021-10-14 06:34:22 +00:00
|
|
|
impl std::default::Default for WorkspaceNotification {
|
|
|
|
fn default() -> Self { WorkspaceNotification::Unknown }
|
2021-07-21 07:43:05 +00:00
|
|
|
}
|
|
|
|
|
2021-10-14 06:34:22 +00:00
|
|
|
impl std::convert::Into<i32> for WorkspaceNotification {
|
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-14 06:34:22 +00:00
|
|
|
#[tracing::instrument(level = "debug")]
|
|
|
|
pub(crate) fn send_dart_notification(id: &str, ty: WorkspaceNotification) -> DartNotifyBuilder {
|
2021-10-05 03:46:56 +00:00
|
|
|
DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
|
2021-10-01 11:39:08 +00:00
|
|
|
}
|
2021-10-14 06:34:22 +00:00
|
|
|
|
|
|
|
#[tracing::instrument(level = "debug")]
|
|
|
|
pub(crate) fn send_anonymous_dart_notification(ty: WorkspaceNotification) -> DartNotifyBuilder {
|
|
|
|
DartNotifyBuilder::new("", ty, OBSERVABLE_CATEGORY)
|
|
|
|
}
|