Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

At LiteFarm, resources are often cached in Redux, reducing the number of requests which need to be made to the server. In general, this is good as it reduces the data usage of the app and makes it more responsive. However, it can cause issues with notifications. Notifications keep a HTTP connection open for a long period of time (as long as the user has connectivity), and use it to send Server Sent Events (SSE). This long HTTP connection allows the alert count to update in real time as events trigger notifications for the user, but it also means that the notifications can get out of sync with the records which they are referencing. For example, if the user is on the tasks page currently then LiteFarm will have cached the tasks. If a notification is generated because one of these tasks was reassigned to another user, then when the user clicks on the “Take me there” button in the notification, they will be taken to the task but the task will not have been updated to display the new assignee.

...

  1. The code has to be able to figure out what type of record needs to be updated from a notification. If the notification is associated with a standard record(e.g. tasks), then this should be stored under notification.ref.entity.type in the notification. In this scenario, nothing needs to be changed. If for some reason the type of record which needs to be updated is not in this form, you need to update the function getUpdateFromNotification to return an appropriate string given the structure of the ref for that notification use case.

  2. The code has to know what redux action (or more generally, any function function) to dispatch for each type of update. For tasks, this action is the getTasks() redux action, although this will change for every type of record which needs to be updated. In order to tell the code what type of redux action must be dispatched for a specific update type, all you need to do is update the dispatchUpdate function to handle the updateType. This updateType should be the string returned from getUpdateFromNotification.

...