]> source.dussan.org Git - gitea.git/commitdiff
Check if stopwatch element empty (#15278)
authorKyle D <kdumontnu@gmail.com>
Mon, 5 Apr 2021 16:45:01 +0000 (10:45 -0600)
committerGitHub <noreply@github.com>
Mon, 5 Apr 2021 16:45:01 +0000 (18:45 +0200)
web_src/js/features/stopwatch.js

index 9352ef292d508921f4a663e7484fc94914a9d168..ed20ca3227dfe48d148529c2d2c2a1b391095206 100644 (file)
@@ -9,6 +9,11 @@ export async function initStopwatch() {
   }
 
   const stopwatchEl = $('.active-stopwatch-trigger');
+
+  if (!stopwatchEl.length) {
+    return;
+  }
+
   stopwatchEl.removeAttr('href'); // intended for noscript mode only
   stopwatchEl.popup({
     position: 'bottom right',
@@ -20,10 +25,6 @@ export async function initStopwatch() {
     $(this).parent().trigger('submit');
   });
 
-  if (!stopwatchEl) {
-    return;
-  }
-
   if (NotificationSettings.EventSourceUpdateTime > 0 && !!window.EventSource && window.SharedWorker) {
     // Try to connect to the event source via the shared worker first
     const worker = new SharedWorker(`${__webpack_public_path__}js/eventsource.sharedworker.js`, 'notification-worker');