updating displayAdditionHdrsInMsgView without a refresh

Interested in talking about Mash-up's? This is the place.
Post Reply
User avatar
JDunphy
Outstanding Member
Outstanding Member
Posts: 889
Joined: Fri Sep 12, 2014 11:18 pm
Location: Victoria, BC
ZCS/ZD Version: 9.0.0_P39 NETWORK Edition

updating displayAdditionHdrsInMsgView without a refresh

Post by JDunphy »

Was looking through the zimlet samples on github and I saw this pattern repeated a few times and thought I would improve it.
During the zimlet initialization, they do something like this.

Code: Select all

if (appCtxt.get(ZmSetting.MAIL_ENABLED)) {
                AjxPackage.require({name:"MailCore", callback:new AjxCallback(this, this._applyRequestHeaders)});
 }
which does nothing more than invoke this one time

Code: Select all

ZmMailMsg.requestHeaders["X-Mailer"] = "X-Mailer";
ZmMailMsgView.displayAdditionalHdrsInMsgView[X-Mailer"] = this.getMessage("XMailerZimlet_label_sent");
which displays the header in the MsgView area when the user clicks on a message. Later on, the zimlet allows the user to turn this feature on/off via a preference dialog. This is the area I would like to improve. They do the following:

Code: Select all

        if(this._reloadRequired) {
                window.onbeforeunload = null;
                var url = AjxUtil.formatUrl({});
                ZmZimbraMail.sendRedirect(url);
        }
which forces a refresh of the users browser for the purpose to start the zimlet initialization sequence again but this time through they make sure not to set additionalHdrsInMsgView headers by returning before setting up that callback I show above.

Is there a way of removing that header vs restarting this zimlet and all others? I was hoping to find a call to either update the requestHeaders or remove it completely without a browser refresh. I was looking inside zm-web-client/WebRoot/js/zimbraMail/mail/view for some ideas but could be in the wrong area. I am beginning to look at how zimbra is put together and thought these zimlets could be a great way to learn as I go. Stumped out of the gate. :-)

My plan B is trying it via onMsgView but I am curious if there is a better or simpler way.

Thanks for any clues.

Jim
Post Reply