notification.rs 1.8 KB

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