Skip to content

Commit 00a2ba4

Browse files
fix: onMailAccountActiveChange triggers error if editor with error state is opened
refs #274
1 parent d13bed8 commit 00a2ba4

File tree

2 files changed

+58
-40
lines changed

2 files changed

+58
-40
lines changed

src/app/PackageController.js

+40-40
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
314314
* @return false if no action was initiated and the activatedPanel is the
315315
* MailInboxView, otherwise true
316316
*/
317-
onMailDesktopViewTabChange: function (panel, activatedPanel) {
317+
onMailDesktopViewTabChange (panel, activatedPanel) {
318318

319319
const me = this;
320320

@@ -382,7 +382,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
382382
* @param {Boolean} deleteDis, optional. True to disable the delete-button,
383383
* false to enable it.
384384
*/
385-
disableEmailEditButtons: function (editDis, deleteDis) {
385+
disableEmailEditButtons (editDis, deleteDis) {
386386

387387
const me = this,
388388
editBtn = me.getEditButton(),
@@ -403,7 +403,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
403403
*
404404
* @param {Boolean} disable true to disable the buttons, false to enable them.
405405
*/
406-
disableEmailActionButtons: function (disable) {
406+
disableEmailActionButtons (disable) {
407407
const me = this,
408408
replyToBtn = me.getReplyToButton(),
409409
replyAllBtn = me.getReplyAllButton(),
@@ -423,7 +423,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
423423
* @see disableEmailActionButtons
424424
* @see disableEmailEditButtons
425425
*/
426-
activateButtonsForMessageGrid: function () {
426+
activateButtonsForMessageGrid () {
427427
const me = this,
428428
selection = me.getMailMessageGrid().getSelection();
429429

@@ -443,7 +443,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
443443
* @see disableEmailActionButtons
444444
* @see disableEmailEditButtons
445445
*/
446-
activateButtonsForMessageItem: function (record) {
446+
activateButtonsForMessageItem (record) {
447447

448448
const me = this,
449449
isDraft = record.get("draft");
@@ -469,7 +469,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
469469
*
470470
* @param {conjoon.cn_mail.view.mail.inbox.InboxView} view
471471
*/
472-
onMailInboxViewActivate: function (view) {
472+
onMailInboxViewActivate (view) {
473473

474474
const me = this,
475475
ACCOUNT = conjoon.cn_mail.data.mail.folder.MailFolderTypes.ACCOUNT;
@@ -506,7 +506,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
506506
*
507507
* @param {conjoon.cn_mail.view.mail.inbox.InboxView} view
508508
*/
509-
onMailInboxViewDeactivate: function (inboxView) {
509+
onMailInboxViewDeactivate (inboxView) {
510510
var me = this;
511511

512512
me.getToggleGridListButton().setDisabled(true);
@@ -520,7 +520,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
520520
*
521521
* @param {conjoon.cn_mail.store.mail.message.MessageItemStore} store
522522
*/
523-
onMailMessageGridBeforeLoad: function (store) {
523+
onMailMessageGridBeforeLoad (store) {
524524
var me = this;
525525

526526
me.getToggleGridListButton().setDisabled(true);
@@ -533,7 +533,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
533533
*
534534
* @param {conjoon.cn_mail.store.mail.message.MessageItemStore} store
535535
*/
536-
onMailMessageGridLoad: function () {
536+
onMailMessageGridLoad () {
537537
var me = this;
538538

539539
if (me.getMailDesktopView().getLayout().getActiveItem() !== me.getMailInboxView()) {
@@ -553,7 +553,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
553553
* @param {Ext.Button} btn
554554
* @param {Boolean} pressed
555555
*/
556-
onToggleFolderViewButtonClick: function (btn, pressed) {
556+
onToggleFolderViewButtonClick (btn, pressed) {
557557

558558
var me = this,
559559
mailFolder = me.getMailFolderTree();
@@ -574,7 +574,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
574574
* @param {Ext.Button} btn
575575
* @param {Boolean} pressed
576576
*/
577-
onToggleListViewButtonClick: function (btn, pressed) {
577+
onToggleListViewButtonClick (btn, pressed) {
578578

579579
var me = this,
580580
messageGrid = me.getMailMessageGrid();
@@ -590,7 +590,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
590590
* @param {Ext.menu.CheckItem} menuItem
591591
* @param {boolean} checked
592592
*/
593-
onReadingPaneCheckChange: function (menuItem, checked) {
593+
onReadingPaneCheckChange (menuItem, checked) {
594594

595595
// exit if checked is set to false. There will
596596
// follow an immediate call to this method with the
@@ -628,7 +628,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
628628
* @throws if this method was called with more than one record available
629629
* in records
630630
*/
631-
onMailFolderTreeSelectionChange: function (treeList, records) {
631+
onMailFolderTreeSelectionChange (treeList, records) {
632632

633633
const me = this;
634634

@@ -663,7 +663,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
663663
* @param selectionModel
664664
* @param record
665665
*/
666-
onMailMessageGridDeselect: function (selectionModel, record) {
666+
onMailMessageGridDeselect (selectionModel, record) {
667667

668668
const me = this;
669669

@@ -689,7 +689,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
689689
* @param selectionModel
690690
* @param record
691691
*/
692-
onMailMessageGridSelect: function (selectionModel, record) {
692+
onMailMessageGridSelect (selectionModel, record) {
693693

694694
const me = this;
695695

@@ -701,7 +701,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
701701
/**
702702
* Action for cn_mail/home.
703703
*/
704-
onHomeTabRoute: function () {
704+
onHomeTabRoute () {
705705
var me = this,
706706
mailDesktopView = me.getMainPackageView();
707707

@@ -718,7 +718,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
718718
*
719719
* @see {conjoon.cn_mail.view.mail.MailDesktopView#showMailMessageViewFor}
720720
*/
721-
onReadMessageRoute: function (mailAccountId, mailFolderId, id) {
721+
onReadMessageRoute (mailAccountId, mailFolderId, id) {
722722

723723
const
724724
me = this,
@@ -736,7 +736,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
736736
*
737737
* @see {conjoon.cn_mail.view.mail.MailDesktopView#showMailAccountFor}
738738
*/
739-
onMailAccountRoute: function (mailAccountId) {
739+
onMailAccountRoute (mailAccountId) {
740740
const me = this,
741741
mailDesktopView = me.getMainPackageView();
742742

@@ -752,7 +752,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
752752
*
753753
* @see {conjoon.cn_mail.view.mail.MailDesktopView#showMailFolderFor}
754754
*/
755-
onMailFolderRoute: function (mailAccountId, mailFolderId) {
755+
onMailFolderRoute (mailAccountId, mailFolderId) {
756756
const me = this,
757757
mailDesktopView = me.getMainPackageView();
758758

@@ -767,7 +767,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
767767
*
768768
* @param {String} id the id to be able to track this MessageEditor instance
769769
*/
770-
onComposeMessageRoute: function (id) {
770+
onComposeMessageRoute (id) {
771771
this.showMailEditor(id, "compose");
772772
},
773773

@@ -777,7 +777,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
777777
*
778778
* @param {String} id the id to be able to track this MessageEditor instance
779779
*/
780-
onComposeMailtoMessageRoute: function (id) {
780+
onComposeMailtoMessageRoute (id) {
781781
id = "mailto%3A" + id;
782782
this.showMailEditor(id, "compose");
783783
},
@@ -788,7 +788,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
788788
*
789789
* @param {Ext.Button} btn
790790
*/
791-
onMessageComposeButtonClick: function (btn) {
791+
onMessageComposeButtonClick (btn) {
792792
this.showMailEditor(Date.now(), "compose");
793793
},
794794

@@ -798,7 +798,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
798798
*
799799
* @param {String} id the id of the message to edit
800800
*/
801-
onEditMessageRoute: function (mailAccountId, mailFolderId, id) {
801+
onEditMessageRoute (mailAccountId, mailFolderId, id) {
802802
const me = this;
803803

804804
me.showMailEditor(
@@ -813,7 +813,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
813813
*
814814
* @param {String} id the id of the message to edit
815815
*/
816-
onReplyToRoute: function (mailAccountId, mailFolderId, id) {
816+
onReplyToRoute (mailAccountId, mailFolderId, id) {
817817
const me = this;
818818

819819
me.showMailEditor(
@@ -828,7 +828,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
828828
*
829829
* @param {String} id the id of the message to edit
830830
*/
831-
onReplyAllRoute: function (mailAccountId, mailFolderId, id) {
831+
onReplyAllRoute (mailAccountId, mailFolderId, id) {
832832
const me = this;
833833

834834
me.showMailEditor(
@@ -843,7 +843,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
843843
*
844844
* @param {String} id the id of the message to edit
845845
*/
846-
onForwardRoute: function (mailAccountId, mailFolderId, id) {
846+
onForwardRoute (mailAccountId, mailFolderId, id) {
847847
const me = this;
848848

849849
me.showMailEditor(
@@ -858,7 +858,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
858858
*
859859
* @param {Ext.Button} btn
860860
*/
861-
onMessageEditButtonClick: function (btn) {
861+
onMessageEditButtonClick (btn) {
862862
const me = this,
863863
key = me.getCompoundKeyFromGridOrMessageView();
864864

@@ -871,7 +871,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
871871
*
872872
* @param {Ext.Button} btn
873873
*/
874-
onMessageDeleteButtonClick: function (btn) {
874+
onMessageDeleteButtonClick (btn) {
875875
const me = this,
876876
item = me.getItemOrDraftFromActiveView();
877877

@@ -892,7 +892,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
892892
*
893893
* @param {Ext.Button} btn
894894
*/
895-
onReplyToButtonClick: function (btn) {
895+
onReplyToButtonClick (btn) {
896896
const me = this,
897897
key = me.getCompoundKeyFromGridOrMessageView();
898898

@@ -905,7 +905,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
905905
*
906906
* @param {Ext.Button} btn
907907
*/
908-
onReplyAllButtonClick: function (btn) {
908+
onReplyAllButtonClick (btn) {
909909
const me = this,
910910
key = me.getCompoundKeyFromGridOrMessageView();
911911

@@ -918,7 +918,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
918918
*
919919
* @param {Ext.Button} btn
920920
*/
921-
onForwardButtonClick: function (btn) {
921+
onForwardButtonClick (btn) {
922922
const me = this,
923923
key = me.getCompoundKeyFromGridOrMessageView();
924924

@@ -1114,7 +1114,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
11141114
*
11151115
* @return {conjoon.cn_mail.view.mail.MailDesktopView}
11161116
*/
1117-
getMainPackageView: function () {
1117+
getMainPackageView () {
11181118
var me = this,
11191119
app = me.getApplication();
11201120

@@ -1143,7 +1143,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
11431143
*
11441144
* @return {null|conjoon.cn_mail.model.mail.message.AbstractMessageItem}
11451145
*/
1146-
getItemOrDraftFromActiveView: function () {
1146+
getItemOrDraftFromActiveView () {
11471147

11481148
const me = this,
11491149
tab = me.getMailDesktopView().getActiveTab();
@@ -1169,7 +1169,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
11691169
*
11701170
* @private
11711171
*/
1172-
getCompoundKeyFromGridOrMessageView: function () {
1172+
getCompoundKeyFromGridOrMessageView () {
11731173

11741174
const me = this,
11751175
tab = me.getMailDesktopView().getActiveTab();
@@ -1190,20 +1190,20 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
11901190
* information whether the MessageItem which is about to load is a message
11911191
* flagged as "draft".
11921192
*
1193-
* @param {cconjoon.cn_mail.view.mail.message.reader.MessageView} messageView
1193+
* @param {conjoon.cn_mail.view.mail.message.reader.MessageView} messageView
11941194
* @param {conjoon.cn_mail.model.mail.message.MessageItem}} messageItem
11951195
*
11961196
* @private
11971197
*/
1198-
onMailMessageItemLoadForActivatedView: function (messageView, messageItem) {
1198+
onMailMessageItemLoadForActivatedView (messageView, messageItem) {
11991199

12001200
const me = this;
12011201

12021202
if (!messageItem) {
12031203
messageItem = messageView.getViewModel().get("messageItem");
12041204
}
12051205

1206-
if (messageItem.get("draft")) {
1206+
if (messageItem?.get("draft")) {
12071207
me.disableEmailActionButtons(true);
12081208
me.disableEmailEditButtons(false, false);
12091209
} else {
@@ -1226,7 +1226,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
12261226
*
12271227
* @throws if type is not "compose" and key is not an instance of conjoon.cn_mail.data.mail.message.compoundKey.MessageEntityCompoundKey
12281228
*/
1229-
showMailEditor: function (key, type) {
1229+
showMailEditor (key, type) {
12301230

12311231
var me = this,
12321232
mailDesktopView = me.getMainPackageView();
@@ -1258,7 +1258,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
12581258
*
12591259
* @private
12601260
*/
1261-
createCompoundKeyFromUrlFragments: function (mailAccountId, mailFolderId, id) {
1261+
createCompoundKeyFromUrlFragments (mailAccountId, mailFolderId, id) {
12621262

12631263
return conjoon.cn_mail.data.mail.message.compoundKey.MessageEntityCompoundKey.createFor(
12641264
decodeURIComponent(mailAccountId),
@@ -1275,7 +1275,7 @@ Ext.define("conjoon.cn_mail.app.PackageController", {
12751275
*
12761276
* @private
12771277
*/
1278-
messageEditorIsActivatedTab: function () {
1278+
messageEditorIsActivatedTab () {
12791279
const me = this;
12801280

12811281
me.disableEmailActionButtons(true);

tests/src/app/PackageControllerTest.js

+18
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,24 @@ StartTest(async t => {
11621162
});
11631163

11641164

1165+
t.it("onMailMessageItemLoadForActivatedView() - missing messageItem", t => {
1166+
packageCtrl = Ext.create("conjoon.cn_mail.app.PackageController");
1167+
1168+
const funcSpy = t.spyOn(packageCtrl, "onMailMessageItemLoadForActivatedView");
1169+
1170+
let activatedPanel = Ext.create("conjoon.cn_mail.view.mail.message.reader.MessageView");
1171+
activatedPanel.loadingItem = {};
1172+
configurePackageCtrlWithButtonMocks(packageCtrl, configureButtonMockCaller());
1173+
packageCtrl.onMailDesktopViewTabChange(null, activatedPanel);
1174+
1175+
t.spyOn(activatedPanel.getViewModel(), "get").and.callFake(() => undefined);
1176+
1177+
activatedPanel.fireEvent("cn_mail-messageitemload", activatedPanel, undefined);
1178+
1179+
t.expect(funcSpy.calls.mostRecent().args[1]).toBeUndefined();
1180+
});
1181+
1182+
11651183
t.it("onMailDesktopViewTabChange() - panel is MessageView with loading item, panel switched before loading finishes", t => {
11661184

11671185
let ISDRAFT,

0 commit comments

Comments
 (0)