Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / history / js / history.js
index aa5ca78a8b15af4e92be6a65bbe14989def8503f..b9cb9fc5fb00e0e38e748226fd6b838257aab8eb 100644 (file)
@@ -8,7 +8,8 @@
 (function ($, Drupal, drupalSettings, storage) {
   var currentUserID = parseInt(drupalSettings.user.uid, 10);
 
-  var thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - 30 * 24 * 60 * 60;
+  var secondsIn30Days = 2592000;
+  var thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - secondsIn30Days;
 
   var embeddedLastReadTimestamps = false;
   if (drupalSettings.history && drupalSettings.history.lastReadTimestamps) {
         data: { 'node_ids[]': nodeIDs },
         dataType: 'json',
         success: function success(results) {
-          for (var nodeID in results) {
-            if (results.hasOwnProperty(nodeID)) {
-              storage.setItem('Drupal.history.' + currentUserID + '.' + nodeID, results[nodeID]);
-            }
-          }
+          Object.keys(results || {}).forEach(function (nodeID) {
+            storage.setItem('Drupal.history.' + currentUserID + '.' + nodeID, results[nodeID]);
+          });
           callback();
         }
       });