FIX: We shouldn't memoize the last time something is read

FIX: We shouldn’t memoize the last time something is read

diff --git a/app/assets/javascripts/discourse/lib/screen-track.js.es6 b/app/assets/javascripts/discourse/lib/screen-track.js.es6
index d048c79..363454e 100644
--- a/app/assets/javascripts/discourse/lib/screen-track.js.es6
+++ b/app/assets/javascripts/discourse/lib/screen-track.js.es6
@@ -60,7 +60,7 @@ export default class {
 
   // Reset our timers
   reset() {
-    const now = this._getTime();
+    const now = new Date().getTime();
     this._lastTick = now;
     this._lastScrolled = now;
     this._lastFlush = 0;
@@ -74,7 +74,7 @@ export default class {
   }
 
   scrolled() {
-    this._lastScrolled = this._getTime();
+    this._lastScrolled = new Date().getTime();
   }
 
   registerAnonCallback(cb) {
@@ -224,8 +224,4 @@ export default class {
       });
     }
   }
-
-  _getTime() {
-    return (this._time = this._time || new Date().getTime());
-  }
 }

GitHub sha: 9bdfaa19

2 Likes

Can you elaborate on how this fix works?

In this commit:

The date was changed to be memoized. This was a mistake as the date needs to be updated to check how long it’s been since we submitted post timings.

This commit puts it back the way it was.

2 Likes