dart_notification.rs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. use dart_notify::DartNotifyBuilder;
  2. use flowy_derive::ProtoBuf_Enum;
  3. const OBSERVABLE_CATEGORY: &str = "Grid";
  4. #[derive(ProtoBuf_Enum, Debug)]
  5. pub enum GridNotification {
  6. Unknown = 0,
  7. DidCreateBlock = 11,
  8. DidUpdateGridBlock = 20,
  9. DidUpdateGridField = 21,
  10. DidUpdateRow = 30,
  11. DidUpdateCell = 40,
  12. DidUpdateField = 50,
  13. DidUpdateGroupView = 60,
  14. DidUpdateGroup = 61,
  15. }
  16. impl std::default::Default for GridNotification {
  17. fn default() -> Self {
  18. GridNotification::Unknown
  19. }
  20. }
  21. impl std::convert::From<GridNotification> for i32 {
  22. fn from(notification: GridNotification) -> Self {
  23. notification as i32
  24. }
  25. }
  26. #[tracing::instrument(level = "trace")]
  27. pub fn send_dart_notification(id: &str, ty: GridNotification) -> DartNotifyBuilder {
  28. DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
  29. }
  30. #[tracing::instrument(level = "trace")]
  31. pub fn send_anonymous_dart_notification(ty: GridNotification) -> DartNotifyBuilder {
  32. DartNotifyBuilder::new("", ty, OBSERVABLE_CATEGORY)
  33. }