File tree Expand file tree Collapse file tree
apps/files_sharing/lib/Listener Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,9 +43,9 @@ class SharesUpdatedListener implements IEventListener {
4343 private float $ cutOffMarkTime ;
4444
4545 /**
46- * The total amount of time we've spent so far processing updates
46+ * Timestamp marking the start of the current timing period
4747 */
48- private float $ updatedTime = 0.0 ;
48+ private ? float $ lastPeriodStart = null ;
4949 private bool $ inUpdate = false ;
5050
5151 public function __construct (
@@ -134,14 +134,18 @@ public function handle(Event $event): void {
134134 }
135135
136136 private function markOrRun (IUser $ user , callable $ callback ): void {
137- $ start = floatval ($ this ->clock ->now ()->format ('U.u ' ));
138- if ($ this ->cutOffMarkTime === -1.0 || $ this ->updatedTime < $ this ->cutOffMarkTime ) {
137+ $ now = floatval ($ this ->clock ->now ()->format ('U.u ' ));
138+ $ elapsed = $ now - ($ this ->lastPeriodStart ?? $ now );
139+ $ this ->lastPeriodStart = $ now ;
140+
141+ if ($ this ->cutOffMarkTime === -1.0 && $ elapsed < $ this ->cutOffMarkTime ) {
139142 $ callback ();
140143 } else {
141144 $ this ->markUserForRefresh ($ user );
142145 }
146+
143147 $ end = floatval ($ this ->clock ->now ()->format ('U.u ' ));
144- $ this ->updatedTime + = $ end - $ start ;
148+ $ this ->lastPeriodStart = $ end ;
145149 }
146150
147151 private function updateOrMarkUser (IUser $ user ): void {
You can’t perform that action at this time.
0 commit comments