Simplify answered

pull/162/head
M66B 5 years ago
parent 2f9b6a555e
commit 4ef10cd7d0

@ -471,7 +471,7 @@ class Core {
if (message.answered.equals(answered)) if (message.answered.equals(answered))
return; return;
// This will be fixed when synchronizing the message // This will be fixed when moving the message
if (message.uid == null) if (message.uid == null)
return; return;
@ -546,6 +546,7 @@ class Core {
Properties props = MessageHelper.getSessionProperties(); Properties props = MessageHelper.getSessionProperties();
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);
Flags flags = ifolder.getPermanentFlags();
// Get raw message // Get raw message
MimeMessage imessage; MimeMessage imessage;
@ -568,7 +569,7 @@ class Core {
} }
// Handle auto read // Handle auto read
if (ifolder.getPermanentFlags().contains(Flags.Flag.SEEN)) { if (flags.contains(Flags.Flag.SEEN)) {
if (autoread && !imessage.isSet(Flags.Flag.SEEN)) { if (autoread && !imessage.isSet(Flags.Flag.SEEN)) {
Log.i(folder.name + " autoread"); Log.i(folder.name + " autoread");
imessage.setFlag(Flags.Flag.SEEN, true); imessage.setFlag(Flags.Flag.SEEN, true);
@ -576,7 +577,7 @@ class Core {
} }
// Handle draft // Handle draft
if (ifolder.getPermanentFlags().contains(Flags.Flag.DRAFT)) if (flags.contains(Flags.Flag.DRAFT))
imessage.setFlag(Flags.Flag.DRAFT, EntityFolder.DRAFTS.equals(folder.type)); imessage.setFlag(Flags.Flag.DRAFT, EntityFolder.DRAFTS.equals(folder.type));
// Add message // Add message
@ -655,6 +656,7 @@ class Core {
// Get arguments // Get arguments
long id = jargs.getLong(0); long id = jargs.getLong(0);
boolean autoread = jargs.optBoolean(1, false); boolean autoread = jargs.optBoolean(1, false);
Flags flags = ifolder.getPermanentFlags();
// Get source message // Get source message
Message imessage = ifolder.getMessageByUID(message.uid); Message imessage = ifolder.getMessageByUID(message.uid);
@ -686,18 +688,24 @@ class Core {
file.delete(); file.delete();
// Auto read // Auto read
if (autoread) if (autoread && flags.contains(Flags.Flag.SEEN))
icopy.setFlag(Flags.Flag.SEEN, true); icopy.setFlag(Flags.Flag.SEEN, true);
if (message.ui_answered && flags.contains(Flags.Flag.ANSWERED))
icopy.setFlag(Flags.Flag.ANSWERED, true);
// Set drafts flag // Set drafts flag
icopy.setFlag(Flags.Flag.DRAFT, EntityFolder.DRAFTS.equals(target.type)); icopy.setFlag(Flags.Flag.DRAFT, EntityFolder.DRAFTS.equals(target.type));
itarget.appendMessages(new Message[]{icopy}); itarget.appendMessages(new Message[]{icopy});
} else { } else {
// Auto read // Auto read
if (autoread && ifolder.getPermanentFlags().contains(Flags.Flag.SEEN)) if (autoread && flags.contains(Flags.Flag.SEEN))
imessage.setFlag(Flags.Flag.SEEN, true); imessage.setFlag(Flags.Flag.SEEN, true);
if (message.ui_answered && flags.contains(Flags.Flag.ANSWERED))
imessage.setFlag(Flags.Flag.ANSWERED, true);
ifolder.copyMessages(new Message[]{imessage}, itarget); ifolder.copyMessages(new Message[]{imessage}, itarget);
} }
@ -1407,10 +1415,11 @@ class Core {
Log.i(folder.name + " local count=" + uids.size()); Log.i(folder.name + " local count=" + uids.size());
// Reduce list of local uids // Reduce list of local uids
Flags flags = ifolder.getPermanentFlags();
SearchTerm searchTerm = new ReceivedDateTerm(ComparisonTerm.GE, new Date(sync_time)); SearchTerm searchTerm = new ReceivedDateTerm(ComparisonTerm.GE, new Date(sync_time));
if (sync_unseen && ifolder.getPermanentFlags().contains(Flags.Flag.SEEN)) if (sync_unseen && flags.contains(Flags.Flag.SEEN))
searchTerm = new OrTerm(searchTerm, new FlagTerm(new Flags(Flags.Flag.SEEN), false)); searchTerm = new OrTerm(searchTerm, new FlagTerm(new Flags(Flags.Flag.SEEN), false));
if (sync_flagged && ifolder.getPermanentFlags().contains(Flags.Flag.FLAGGED)) if (sync_flagged && flags.contains(Flags.Flag.FLAGGED))
searchTerm = new OrTerm(searchTerm, new FlagTerm(new Flags(Flags.Flag.FLAGGED), true)); searchTerm = new OrTerm(searchTerm, new FlagTerm(new Flags(Flags.Flag.FLAGGED), true));
long search = SystemClock.elapsedRealtime(); long search = SystemClock.elapsedRealtime();
@ -1922,13 +1931,7 @@ class Core {
Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " seen=" + seen); Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " seen=" + seen);
} }
if ((!message.answered.equals(answered) || !message.ui_answered.equals(message.answered)) && if ((!message.answered.equals(answered) || !message.ui_answered.equals(message.answered))) {
db.operation().getOperationCount(folder.id, message.id, EntityOperation.ANSWERED) == 0) {
if (!answered && message.ui_answered && ifolder.getPermanentFlags().contains(Flags.Flag.ANSWERED)) {
// This can happen when the answered operation was skipped because the message was moving
answered = true;
imessage.setFlag(Flags.Flag.ANSWERED, answered);
}
update = true; update = true;
message.answered = answered; message.answered = answered;
message.ui_answered = answered; message.ui_answered = answered;

@ -155,7 +155,6 @@ public class ServiceSend extends ServiceBase {
break; break;
case EntityOperation.ANSWERED: case EntityOperation.ANSWERED:
// This will be fixed when synchronizing the message
break; break;
default: default:

Loading…
Cancel
Save