From 0b61fd4184566d377bc988ecfae8eaceff77187e Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 23 Sep 2014 12:19:28 +0000 Subject: [PATCH] Make sure the opener window is still there before asking about its widgets. -Fix mail compose save as draft throws an error if the mail tab is closed while saving. --- mail/js/app.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mail/js/app.js b/mail/js/app.js index 7f0e087585..b750f6e064 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -3229,7 +3229,8 @@ app.classes.mail = AppJS.extend( { var content = this.et2.getArrayMgr('content'); var lastDrafted = this.et2.getWidgetById('lastDrafted'); - var folderTree = opener.etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]'); + var folderTree = typeof opener.etemplate2.getByApplication('mail')[0] !='undefined'? + opener.etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]'): null; var activeFolder = folderTree?folderTree.getSelectedNode():null; if (content) { @@ -3237,14 +3238,17 @@ app.classes.mail = AppJS.extend( content.data.lastDrafted = _responseData.draftedId; this.et2.setArrayMgr('content', content); lastDrafted.set_value(_responseData.draftedId); - if (typeof activeFolder.id !='undefined'&& activeFolder && _responseData.draftfolder == activeFolder.id) + if (folderTree && activeFolder) { - if (prevDraftedId) + if (typeof activeFolder.id !='undefined' && _responseData.draftfolder == activeFolder.id) { - opener.egw_refresh(_responseData.message,'mail', prevDraftedId, 'delete'); + if (prevDraftedId) + { + opener.egw_refresh(_responseData.message,'mail', prevDraftedId, 'delete'); + } + this.egw.refresh(_responseData.message,'mail',_responseData.draftedId); } - this.egw.refresh(_responseData.message,'mail',_responseData.draftedId); - } + } switch (_action) { case 'button[saveAsDraftAndPrint]':