Update local contacts after account creation only

This is to prevent double counts after importing settings
pull/153/head
M66B 6 years ago
parent b99d7dd4eb
commit 8a0ac170c6

@ -985,7 +985,8 @@ class Core {
db.beginTransaction(); db.beginTransaction();
EntityMessage message = synchronizeMessage( EntityMessage message = synchronizeMessage(
context, context,
folder, ifolder, (IMAPMessage) isub[j], account, folder,
ifolder, (IMAPMessage) isub[j],
false, false,
rules); rules);
ids[from + j] = message.id; ids[from + j] = message.id;
@ -1075,7 +1076,8 @@ class Core {
static EntityMessage synchronizeMessage( static EntityMessage synchronizeMessage(
Context context, Context context,
EntityFolder folder, IMAPFolder ifolder, IMAPMessage imessage, EntityAccount account, EntityFolder folder,
IMAPFolder ifolder, IMAPMessage imessage,
boolean browsed, boolean browsed,
List<EntityRule> rules) throws MessagingException, IOException { List<EntityRule> rules) throws MessagingException, IOException {
long uid = ifolder.getUID(imessage); long uid = ifolder.getUID(imessage);
@ -1239,7 +1241,8 @@ class Core {
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);
} }
if (!EntityFolder.ARCHIVE.equals(folder.type) && if (message.received > account.created &&
!EntityFolder.ARCHIVE.equals(folder.type) &&
!EntityFolder.TRASH.equals(folder.type) && !EntityFolder.TRASH.equals(folder.type) &&
!EntityFolder.JUNK.equals(folder.type)) { !EntityFolder.JUNK.equals(folder.type)) {
int type = (folder.isOutgoing() ? EntityContact.TYPE_TO : EntityContact.TYPE_FROM); int type = (folder.isOutgoing() ? EntityContact.TYPE_TO : EntityContact.TYPE_FROM);

@ -668,7 +668,8 @@ public class ServiceSynchronize extends LifecycleService {
db.beginTransaction(); db.beginTransaction();
message = Core.synchronizeMessage( message = Core.synchronizeMessage(
ServiceSynchronize.this, ServiceSynchronize.this,
folder, (IMAPFolder) ifolder, (IMAPMessage) imessage, account, folder,
(IMAPFolder) ifolder, (IMAPMessage) imessage,
false, false,
db.rule().getEnabledRules(folder.id)); db.rule().getEnabledRules(folder.id));
db.setTransactionSuccessful(); db.setTransactionSuccessful();
@ -757,7 +758,8 @@ public class ServiceSynchronize extends LifecycleService {
db.beginTransaction(); db.beginTransaction();
message = Core.synchronizeMessage( message = Core.synchronizeMessage(
ServiceSynchronize.this, ServiceSynchronize.this,
folder, (IMAPFolder) ifolder, (IMAPMessage) e.getMessage(), account, folder,
(IMAPFolder) ifolder, (IMAPMessage) e.getMessage(),
false, false,
db.rule().getEnabledRules(folder.id)); db.rule().getEnabledRules(folder.id));
db.setTransactionSuccessful(); db.setTransactionSuccessful();

@ -151,9 +151,11 @@ public class ViewModelBrowse extends ViewModel {
final EntityFolder folder = db.folder().getBrowsableFolder(state.fid, state.search != null); final EntityFolder folder = db.folder().getBrowsableFolder(state.fid, state.search != null);
if (folder == null) if (folder == null)
return local; return local;
EntityAccount account = db.account().getAccount(folder.account);
if (account == null)
return local;
if (state.imessages == null) { if (state.imessages == null) {
EntityAccount account = db.account().getAccount(folder.account);
try { try {
// Check connectivity // Check connectivity
@ -323,7 +325,8 @@ public class ViewModelBrowse extends ViewModel {
EntityMessage message = db.message().getMessageByUid(folder.id, uid); EntityMessage message = db.message().getMessageByUid(folder.id, uid);
if (message == null) { if (message == null) {
message = Core.synchronizeMessage(state.context, message = Core.synchronizeMessage(state.context,
folder, state.ifolder, (IMAPMessage) isub[j], account, folder,
state.ifolder, (IMAPMessage) isub[j],
true, true,
new ArrayList<EntityRule>()); new ArrayList<EntityRule>());
remote++; remote++;

Loading…
Cancel
Save