ソースを参照

Prevent frequent rhs sidebar refresh

Vijayakrishnan 3 年 前
コミット
57b28944f8
1 ファイル変更17 行追加4 行削除
  1. 17 4
      resources/views/app/patient/note/segment_script.blade.php

+ 17 - 4
resources/views/app/patient/note/segment_script.blade.php

@@ -41,10 +41,23 @@
         }
 
         window.refreshRHSSidebar = function() {
-            $.get('/note-rhs-sidebar/{{$patient->uid}}/{{$note->uid}}', _data => {
-                $('#note-rhs-sidebar').replaceWith(_data);
-                $(window).trigger('scroll');
-            });
+            if($('#note-rhs-sidebar').length) {
+                let lastUpdatedAt = $('#note-rhs-sidebar').attr('last-updated-at');
+                if(lastUpdatedAt) {
+                    lastUpdatedAt = +lastUpdatedAt;
+                    if(new Date().getTime() - lastUpdatedAt < 500) { // dont refresh if refreshed less than a second ago
+                        console.log('Skipping rhs sidebar refresh');
+                        return false;
+                    }
+                }
+                $.get('/note-rhs-sidebar/{{$patient->uid}}/{{$note->uid}}', _data => {
+                    $('#note-rhs-sidebar')
+                        .empty()
+                        .html($(_data).html())
+                        .attr('last-updated-at', new Date().getTime());
+                    $(window).trigger('scroll');
+                });
+            }
         };
 
         window.updateSegmentByUid = function(_uid, _summaryHtml, _editHtml, _updateOnlySummary) {