dart_notification.rs 972 B

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