Sync folder on edit

This commit is contained in:
M66B 2018-12-01 10:23:46 +01:00
parent 1a8ae5a5f1
commit 675df46367
1 changed files with 14 additions and 2 deletions

View File

@ -21,6 +21,7 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@ -45,6 +46,7 @@ import javax.mail.Session;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
public class FragmentFolder extends FragmentEx { public class FragmentFolder extends FragmentEx {
private ViewGroup view; private ViewGroup view;
@ -132,12 +134,14 @@ public class FragmentFolder extends FragmentEx {
if (keep_days < sync_days) if (keep_days < sync_days)
keep_days = sync_days; keep_days = sync_days;
EntityFolder folder = null;
IMAPStore istore = null; IMAPStore istore = null;
DB db = DB.getInstance(getContext()); DB db = DB.getInstance(getContext());
try { try {
db.beginTransaction(); db.beginTransaction();
EntityFolder folder = db.folder().getFolder(id); folder = db.folder().getFolder(id);
if (folder == null || !folder.name.equals(name)) { if (folder == null || !folder.name.equals(name)) {
EntityAccount account = db.account().getAccount(folder == null ? aid : folder.account); EntityAccount account = db.account().getAccount(folder == null ? aid : folder.account);
@ -206,7 +210,15 @@ public class FragmentFolder extends FragmentEx {
istore.close(); istore.close();
} }
ServiceSynchronize.reload(getContext(), "save folder"); if (folder == null || !folder.name.equals(name))
ServiceSynchronize.reload(getContext(), "save folder");
else {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ServiceSynchronize.ACTION_SYNCHRONIZE_FOLDER)
.setType("account/" + folder.account)
.putExtra("folder", folder.id));
}
return null; return null;
} }