Small optimization

This commit is contained in:
M66B 2019-02-17 13:40:23 +00:00
parent 2a03e54952
commit e35c61e018
1 changed files with 10 additions and 7 deletions

View File

@ -1981,18 +1981,14 @@ public class ServiceSynchronize extends LifecycleService {
db.identity().setIdentityState(ident.id, "connected"); db.identity().setIdentityState(ident.id, "connected");
// Append replied/forwarded text
String body = Helper.readText(EntityMessage.getFile(this, message.id));
File refFile = EntityMessage.getRefFile(this, message.id);
if (refFile.exists())
body += Helper.readText(refFile);
// Send message // Send message
Address[] to = imessage.getAllRecipients(); Address[] to = imessage.getAllRecipients();
itransport.sendMessage(imessage, to); itransport.sendMessage(imessage, to);
EntityLog.log(this, "Sent via " + ident.host + "/" + ident.user + EntityLog.log(this, "Sent via " + ident.host + "/" + ident.user +
" to " + TextUtils.join(", ", to)); " to " + TextUtils.join(", ", to));
File refFile = EntityMessage.getRefFile(this, message.id);
try { try {
db.beginTransaction(); db.beginTransaction();
@ -2000,7 +1996,14 @@ public class ServiceSynchronize extends LifecycleService {
db.message().setMessageSeen(message.id, true); db.message().setMessageSeen(message.id, true);
db.message().setMessageUiSeen(message.id, true); db.message().setMessageUiSeen(message.id, true);
db.message().setMessageError(message.id, null); db.message().setMessageError(message.id, null);
Helper.writeText(EntityMessage.getFile(this, message.id), body);
// Append replied/forwarded text
StringBuilder sb = new StringBuilder();
sb.append(Helper.readText(EntityMessage.getFile(this, message.id)));
if (refFile.exists())
sb.append(Helper.readText(refFile));
Helper.writeText(EntityMessage.getFile(this, message.id), sb.toString());
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {