Skip to content

Commit

Permalink
Fix refresh of drafts folder when saving a draft
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Jan 21, 2019
1 parent ca9f83e commit 9a8415c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -7,6 +7,7 @@ Enhancements
Bug fixes
- [web] fixed all-day event dates with different timezone
- [web] fixed display of Bcc header (#4642)
- [web] fixed refresh of drafts folder when saving a draft
- [core] ignore transparent events in time conflict validation (#4539)
- [core] fixed yearly recurrence calculator when starting from previous year

Expand Down
9 changes: 8 additions & 1 deletion SoObjects/Mailer/SOGoDraftObject.m
Expand Up @@ -874,6 +874,7 @@ - (void) fetchMailForEditing: (SOGoMailObject *) sourceMail
NSDictionary *h;
NSMutableArray *addresses;
NGImap4Envelope *sourceEnvelope;
SOGoUserDefaults *ud;
id priority, receipt;

[sourceMail fetchCoreInfos];
Expand Down Expand Up @@ -917,10 +918,12 @@ - (void) fetchMailForEditing: (SOGoMailObject *) sourceMail
if ([receipt isNotEmpty] && [receipt isKindOfClass: [NSString class]])
[info setObject: (NSString*)receipt forKey: @"Disposition-Notification-To"];

[self setHeaders: info];
ud = [[context activeUser] userDefaults];

[self setHeaders: info];
[self setText: [sourceMail contentForEditing]];
[self setIMAP4ID: [[sourceMail nameInContainer] intValue]];
[self setIsHTML: [[ud mailComposeMessageType] isEqualToString: @"html"]];
}

//
Expand All @@ -934,6 +937,7 @@ - (void) fetchMailForReplying: (SOGoMailObject *) sourceMail
NSMutableArray *addresses;
NSMutableDictionary *info;
NGImap4Envelope *sourceEnvelope;
SOGoUserDefaults *ud;

fromSentMailbox = [[sourceMail container] isKindOfClass: [SOGoSentFolder class]];
[sourceMail fetchCoreInfos];
Expand All @@ -955,8 +959,11 @@ - (void) fetchMailForReplying: (SOGoMailObject *) sourceMail
if ([addresses count])
[info setObject: [addresses objectAtIndex: 0] forKey: @"from"];

ud = [[context activeUser] userDefaults];

[self setText: [sourceMail contentForReply]];
[self setHeaders: info];
[self setIsHTML: [[ud mailComposeMessageType] isEqualToString: @"html"]];
[self setSourceURL: [sourceMail imap4URLString]];
[self setSourceFlag: @"Answered"];
[self setSourceIMAP4ID: [[sourceMail nameInContainer] intValue]];
Expand Down
8 changes: 5 additions & 3 deletions UI/MailerUI/UIxMailAccountActions.m
Expand Up @@ -106,6 +106,7 @@ - (WOResponse *) composeAction
NSDictionary *data;
NSString *accountName, *mailboxName, *messageName;
SOGoDraftsFolder *drafts;
SOGoUserDefaults *ud;
id mailTo;
BOOL save;

Expand Down Expand Up @@ -139,10 +140,11 @@ - (WOResponse *) composeAction
signature = [[self clientObject] signature];
if ([signature length])
{
nl = ([[[[context activeUser] userDefaults] mailComposeMessageType] isEqualToString: @"html"] ? @"<br/>" : @"\n");
ud = [[context activeUser] userDefaults];
[newDraftMessage setIsHTML: [[ud mailComposeMessageType] isEqualToString: @"html"]];
nl = ([newDraftMessage isHTML] ? @"<br/>" : @"\n");

[newDraftMessage
setText: [NSString stringWithFormat: @"%@%@-- %@%@", nl, nl, nl, signature]];
[newDraftMessage setText: [NSString stringWithFormat: @"%@%@-- %@%@", nl, nl, nl, signature]];
save = YES;
}
if (save)
Expand Down
4 changes: 3 additions & 1 deletion UI/MailerUI/UIxMailEditor.m
Expand Up @@ -756,6 +756,7 @@ - (BOOL) hasAttachments
co = [self clientObject];
[co fetchInfo];
[self loadInfo: [co headers]];
[self setIsHTML: [co isHTML]];
[self setText: [co text]];
[self setSourceUID: [co IMAP4ID]];
[self setSourceFolder: [co sourceFolder]];
Expand Down Expand Up @@ -793,7 +794,7 @@ - (WOResponse *) saveAction
SOGoDraftObject *co;

co = [self clientObject];
[self setIsHTML: [self isHTML]];
[co setIsHTML: isHTML];

result = [self _saveRequestInfo];
if (!result)
Expand All @@ -805,6 +806,7 @@ - (WOResponse *) saveAction
{
// Save new UID to plist
[self setSourceUID: [co IMAP4ID]];
[co setIsHTML: isHTML];
[co storeInfo];

// Prepare response
Expand Down
8 changes: 5 additions & 3 deletions UI/WebServerResources/js/Mailer/Mailbox.service.js
Expand Up @@ -434,9 +434,11 @@
}
}

Mailbox.$log.debug('Loading UIDs ' + uids.join(' '));
futureHeadersData = Mailbox.$$resource.post(this.id, 'headers', {uids: uids});
this.$unwrapHeaders(futureHeadersData);
if (uids.length) {
Mailbox.$log.debug('Loading UIDs ' + uids.join(' '));
futureHeadersData = Mailbox.$$resource.post(this.id, 'headers', {uids: uids});
this.$unwrapHeaders(futureHeadersData);
}
}
}
return loaded;
Expand Down
3 changes: 2 additions & 1 deletion UI/WebServerResources/js/Mailer/Message.service.js
Expand Up @@ -171,10 +171,11 @@
index = this.$mailbox.uidsMap[oldUID];
this.$mailbox.uidsMap[uid] = index;
delete this.$mailbox.uidsMap[oldUID];
this.$mailbox.$messages[index].uid = this.uid;

// Update messages list of mailbox
_.forEach(['from', 'to', 'subject'], function(attr) {
_this.$mailbox.$messages[index][attr] = _this[attr];
_this.$mailbox.$messages[index][attr] = _this.editable[attr];
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion UI/WebServerResources/js/Mailer/MessageEditorController.js
Expand Up @@ -128,7 +128,7 @@
// },
onSuccessItem: function(item, response, status, headers) {
vm.message.$setUID(response.uid);
vm.message.$reload({asDraft: false});
vm.message.$reload();
item.inlineUrl = response.lastAttachmentAttrs[0].url;
//console.debug(item); console.debug('success = ' + JSON.stringify(response, undefined, 2));
},
Expand Down

0 comments on commit 9a8415c

Please sign in to comment.