notification.rs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. use flowy_derive::ProtoBuf_Enum;
  2. use flowy_notification::NotificationBuilder;
  3. const OBSERVABLE_CATEGORY: &str = "Grid";
  4. #[derive(ProtoBuf_Enum, Debug)]
  5. pub enum DatabaseNotification {
  6. Unknown = 0,
  7. /// Trigger after inserting/deleting/updating a row
  8. DidUpdateViewRows = 20,
  9. /// Trigger when the visibility of the row was changed. For example, updating the filter will trigger the notification
  10. DidUpdateViewRowsVisibility = 21,
  11. /// Trigger after inserting/deleting/updating a field
  12. DidUpdateFields = 22,
  13. /// Trigger after editing a cell
  14. DidUpdateCell = 40,
  15. /// Trigger after editing a field properties including rename,update type option, etc
  16. DidUpdateField = 50,
  17. /// Trigger after the number of groups is changed
  18. DidUpdateGroups = 60,
  19. /// Trigger after inserting/deleting/updating/moving a row
  20. DidUpdateGroupRow = 61,
  21. /// Trigger when setting a new grouping field
  22. DidGroupByField = 62,
  23. /// Trigger after inserting/deleting/updating a filter
  24. DidUpdateFilter = 63,
  25. /// Trigger after inserting/deleting/updating a sort
  26. DidUpdateSort = 64,
  27. /// Trigger after the sort configurations are changed
  28. DidReorderRows = 65,
  29. /// Trigger after editing the row that hit the sort rule
  30. DidReorderSingleRow = 66,
  31. /// Trigger when the settings of the database are changed
  32. DidUpdateSettings = 70,
  33. // Trigger when the layout setting of the database is updated
  34. DidUpdateLayoutSettings = 80,
  35. // Trigger when the layout field of the database is changed
  36. DidSetNewLayoutField = 81,
  37. }
  38. impl std::default::Default for DatabaseNotification {
  39. fn default() -> Self {
  40. DatabaseNotification::Unknown
  41. }
  42. }
  43. impl std::convert::From<DatabaseNotification> for i32 {
  44. fn from(notification: DatabaseNotification) -> Self {
  45. notification as i32
  46. }
  47. }
  48. #[tracing::instrument(level = "trace")]
  49. pub fn send_notification(id: &str, ty: DatabaseNotification) -> NotificationBuilder {
  50. NotificationBuilder::new(id, ty, OBSERVABLE_CATEGORY)
  51. }