notification.rs 2.1 KB

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