From 8d3bb116d8e96e04a96d69b30db62b3c7a426698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Alby?= Date: Thu, 18 Feb 2021 12:46:18 +0100 Subject: [PATCH] Merge pull request #3650 from overleaf/ta-file-tree-new-doc-listener-fix Prevent Multiple Listeners on FileTreeReactBridge GitOrigin-RevId: 49a09238156472f6cf18eafbf628a0443e9214a9 --- .../ide/file-tree/controllers/FileTreeController.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/js/ide/file-tree/controllers/FileTreeController.js b/services/web/frontend/js/ide/file-tree/controllers/FileTreeController.js index 59123cdb5b..8e64371eb2 100644 --- a/services/web/frontend/js/ide/file-tree/controllers/FileTreeController.js +++ b/services/web/frontend/js/ide/file-tree/controllers/FileTreeController.js @@ -76,7 +76,11 @@ App.controller('FileTreeController', function($scope, $modal, ide, $rootScope) { } }) - if (window.showReactFileTree) { + if ( + window.showReactFileTree && + !window.FileTreeReactBridgeOpenNewDocModalListened + ) { + window.FileTreeReactBridgeOpenNewDocModalListened = true window.addEventListener( 'FileTreeReactBridge.openNewDocModal', ({ detail }) => { @@ -203,7 +207,11 @@ App.controller('NewFileModalController', function( $modalInstance.dismiss('done') }) - if (window.showReactFileTree) { + if ( + window.showReactFileTree && + !window.FileTreeReactBridgeOpenNewFileModalListened + ) { + window.FileTreeReactBridgeOpenNewFileModalListened = true window.addEventListener( 'FileTreeReactBridge.openNewFileModal', ({ detail }) => {