Mercurial > hg > isophonics-drupal-site
comparison core/modules/history/js/history.es6.js @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
8 (function ($, Drupal, drupalSettings, storage) { | 8 (function ($, Drupal, drupalSettings, storage) { |
9 const currentUserID = parseInt(drupalSettings.user.uid, 10); | 9 const currentUserID = parseInt(drupalSettings.user.uid, 10); |
10 | 10 |
11 // Any comment that is older than 30 days is automatically considered read, | 11 // Any comment that is older than 30 days is automatically considered read, |
12 // so for these we don't need to perform a request at all! | 12 // so for these we don't need to perform a request at all! |
13 const thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - 30 * 24 * 60 * 60; | 13 const secondsIn30Days = 2592000; |
14 const thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - secondsIn30Days; | |
14 | 15 |
15 // Use the data embedded in the page, if available. | 16 // Use the data embedded in the page, if available. |
16 let embeddedLastReadTimestamps = false; | 17 let embeddedLastReadTimestamps = false; |
17 if (drupalSettings.history && drupalSettings.history.lastReadTimestamps) { | 18 if (drupalSettings.history && drupalSettings.history.lastReadTimestamps) { |
18 embeddedLastReadTimestamps = drupalSettings.history.lastReadTimestamps; | 19 embeddedLastReadTimestamps = drupalSettings.history.lastReadTimestamps; |
42 url: Drupal.url('history/get_node_read_timestamps'), | 43 url: Drupal.url('history/get_node_read_timestamps'), |
43 type: 'POST', | 44 type: 'POST', |
44 data: { 'node_ids[]': nodeIDs }, | 45 data: { 'node_ids[]': nodeIDs }, |
45 dataType: 'json', | 46 dataType: 'json', |
46 success(results) { | 47 success(results) { |
47 for (const nodeID in results) { | 48 Object.keys(results || {}).forEach((nodeID) => { |
48 if (results.hasOwnProperty(nodeID)) { | 49 storage.setItem(`Drupal.history.${currentUserID}.${nodeID}`, results[nodeID]); |
49 storage.setItem(`Drupal.history.${currentUserID}.${nodeID}`, results[nodeID]); | 50 }); |
50 } | |
51 } | |
52 callback(); | 51 callback(); |
53 }, | 52 }, |
54 }); | 53 }); |
55 }, | 54 }, |
56 | 55 |