dart_notification.rs 1002 B

12345678910111213141516171819202122232425262728293031323334353637
  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. DidUpdateGroup = 60,
  14. }
  15. impl std::default::Default for GridNotification {
  16. fn default() -> Self {
  17. GridNotification::Unknown
  18. }
  19. }
  20. impl std::convert::From<GridNotification> for i32 {
  21. fn from(notification: GridNotification) -> Self {
  22. notification as i32
  23. }
  24. }
  25. #[tracing::instrument(level = "trace")]
  26. pub fn send_dart_notification(id: &str, ty: GridNotification) -> DartNotifyBuilder {
  27. DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
  28. }
  29. #[tracing::instrument(level = "trace")]
  30. pub fn send_anonymous_dart_notification(ty: GridNotification) -> DartNotifyBuilder {
  31. DartNotifyBuilder::new("", ty, OBSERVABLE_CATEGORY)
  32. }