Pārlūkot izejas kodu

Avoid excessive, duplicate selection change notifications

That leads to unnecessary re-renderings.
Yevhen Pavliuk 7 gadus atpakaļ
vecāks
revīzija
0cd0866bb9
1 mainītis faili ar 13 papildinājumiem un 1 dzēšanām
  1. 13
    1
      src/editor.html

+ 13
- 1
src/editor.html Parādīt failu

@@ -1537,7 +1537,19 @@
1537 1537
 
1538 1538
 				}
1539 1539
 
1540
-				WebViewBridge.send(JSON.stringify({type: 'SELECTION_CHANGE', data: {items: items}}))
1540
+				notifyIfSelectionHasChanged(items);
1541
+			}
1542
+
1543
+			function notifyIfSelectionHasChanged(items) {
1544
+				var selectionChangeMessage = JSON.stringify({
1545
+					data: {items: items},
1546
+					type: 'SELECTION_CHANGE'
1547
+				});
1548
+
1549
+				if (selectionChangeMessage !== zss_editor.previousSelectionChangeMessage) {
1550
+					WebViewBridge.send(selectionChangeMessage);
1551
+					zss_editor.previousSelectionChangeMessage = selectionChangeMessage;
1552
+				}
1541 1553
 			}
1542 1554
 
1543 1555
 			zss_editor.focusContent = function() {