The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

31 lines
840 B

  1. export const submitMarkers = () => (dispatch, getState) => {
  2. const accessToken = getState().getIn(['meta', 'access_token'], '');
  3. const params = {};
  4. const lastHomeId = getState().getIn(['timelines', 'home', 'items', 0]);
  5. const lastNotificationId = getState().getIn(['notifications', 'items', 0, 'id']);
  6. if (lastHomeId) {
  7. params.home = {
  8. last_read_id: lastHomeId,
  9. };
  10. }
  11. if (lastNotificationId) {
  12. params.notifications = {
  13. last_read_id: lastNotificationId,
  14. };
  15. }
  16. if (Object.keys(params).length === 0) {
  17. return;
  18. }
  19. const client = new XMLHttpRequest();
  20. client.open('POST', '/api/v1/markers', false);
  21. client.setRequestHeader('Content-Type', 'application/json');
  22. client.setRequestHeader('Authorization', `Bearer ${accessToken}`);
  23. client.send(JSON.stringify(params));
  24. };