ソースを参照

Prevent frequent rhs sidebar refresh

Vijayakrishnan 3 年 前
コミット
ad5f2c89a2
1 ファイル変更6 行追加5 行削除
  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');
                 });
             }