Explorar o código

Prevent frequent rhs sidebar refresh

Vijayakrishnan %!s(int64=3) %!d(string=hai) anos
pai
achega
ad5f2c89a2
Modificáronse 1 ficheiros con 6 adicións e 5 borrados
  1. 6 5
      resources/views/app/patient/note/segment_script.blade.php

+ 6 - 5
resources/views/app/patient/note/segment_script.blade.php

@@ -41,8 +41,9 @@
         }
 
         window.refreshRHSSidebar = function() {
-            if($('#note-rhs-sidebar').length) {
-                let lastUpdatedAt = $('#note-rhs-sidebar').attr('last-updated-at');
+            let noteRHSSidebar = $('#note-rhs-sidebar');
+            if(noteRHSSidebar.length) {
+                let lastUpdatedAt = noteRHSSidebar.attr('last-updated-at');
                 if(lastUpdatedAt) {
                     lastUpdatedAt = +lastUpdatedAt;
                     if(new Date().getTime() - lastUpdatedAt < 500) { // dont refresh if refreshed less than a second ago
@@ -50,11 +51,11 @@
                         return false;
                     }
                 }
+                noteRHSSidebar.attr('last-updated-at', new Date().getTime());
                 $.get('/note-rhs-sidebar/{{$patient->uid}}/{{$note->uid}}', _data => {
-                    $('#note-rhs-sidebar')
+                    noteRHSSidebar
                         .empty()
-                        .html($(_data).html())
-                        .attr('last-updated-at', new Date().getTime());
+                        .html($(_data).html());
                     $(window).trigger('scroll');
                 });
             }