Editing a mailing triggers two autosaves instead of one
When editing a mailing or an A/B mailing, any change to the content triggers an autosave after 5 seconds, as expected. But 5 seconds after the first autosave, another one gets triggered even if nothing was changed after the first save.
This is no big deal in most situations, but when saving a mailing is slow on the server side to a point it's longer than 5 seconds (because of overloading or contention at that moment), this actually makes things worse.
I debugged the JS code, and found out that it's because the autoSave controller stores a copy of the mailing before calling the server, and when the server replies the modified date of the mailing is updated by the
crmMailingMgr with the one coming from the server. As a result, the mailing object and "last seen" copy differ by the modified date, and the autoSave controller detects a change.
Not too sure what would be the best way to solve this as I'm not familiar at all with this part of the code. Maybe the
options.save promise of the autoSave should allow for a result when resolving, that would replace the lastSeen copy? But replacing lastSeen after the save may also be a risk of conflicting with any change that the user did?