Skip to content

Commit f618632

Browse files
committed
message_admin - Properly cleanup the onPreview listener
Use-case: 1. Open the editor a message template (eg `#/edit?id=17&lang=fr_FR`). This renders the edit screen. 2. Click on the "Preview" icon. 3. Close the "Preview" dialog. 4. Change the URL to navigate internally to another template (eg `#/edit?id=17&lang=de_DE`). This renders the edit screen again. 5. Click on the "Preview" icon. Before: * It subsequently opens two copies of the "Preview" dialog (each with slightly different options). Initially, you see one dialog. When that close, you will see the other dialog. * As you proceed through closing the dialogs, you may get console warnings because the dialogs have the same name -- and they consequently trip-up each other. After: * It only opens one copy of the "Preview" dialog. Technical Details: * When rendering the setup screen (`#1`/`#4`), it registers a listener which will handle the "Preview" clicks. But the listener is not properly unregistered. Consequently, old listeners hang around. So the click at step `#5` calls both the old+new listeners, creating two dialogs.
1 parent 617345f commit f618632

File tree

1 file changed

+3
-3
lines changed
  • ext/message_admin/ang/crmMsgadm

1 file changed

+3
-3
lines changed

ext/message_admin/ang/crmMsgadm/Edit.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@
308308
});
309309

310310
}
311-
$rootScope.$on('previewMsgTpl', onPreview);
312-
$rootScope.$on('$destroy', function (){
313-
$rootScope.$off('previewMsgTpl', onPreview);
311+
var unreg = $rootScope.$on('previewMsgTpl', onPreview);
312+
$scope.$on('$destroy', function (){
313+
unreg();
314314
});
315315
});
316316

0 commit comments

Comments
 (0)