notification.rs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. }
  34. impl std::default::Default for DatabaseNotification {
  35. fn default() -> Self {
  36. DatabaseNotification::Unknown
  37. }
  38. }
  39. impl std::convert::From<DatabaseNotification> for i32 {
  40. fn from(notification: DatabaseNotification) -> Self {
  41. notification as i32
  42. }
  43. }
  44. #[tracing::instrument(level = "trace")]
  45. pub fn send_notification(id: &str, ty: DatabaseNotification) -> NotificationBuilder {
  46. NotificationBuilder::new(id, ty, OBSERVABLE_CATEGORY)
  47. }