mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 11:28:41 +01:00
Simplification
This commit is contained in:
@@ -83,7 +83,9 @@ public interface DaoFolder {
|
||||
|
||||
@Query("SELECT folder.* FROM folder" +
|
||||
" JOIN account ON account.id = folder.account" +
|
||||
" WHERE `primary` AND type = '" + EntityFolder.DRAFTS + "'")
|
||||
" WHERE account.synchronize" +
|
||||
" AND account.`primary`" +
|
||||
" AND folder.type = '" + EntityFolder.DRAFTS + "'")
|
||||
LiveData<EntityFolder> livePrimaryDrafts();
|
||||
|
||||
@Query("SELECT folder.*" +
|
||||
|
||||
@@ -48,7 +48,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
public class FragmentSetup extends FragmentBase {
|
||||
@@ -272,7 +271,6 @@ public class FragmentSetup extends FragmentBase {
|
||||
|
||||
db.account().liveSynchronizingAccounts().observe(getViewLifecycleOwner(), new Observer<List<EntityAccount>>() {
|
||||
private boolean done = false;
|
||||
private LiveData<EntityFolder> livePrimaryDrafts = null;
|
||||
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityAccount> accounts) {
|
||||
@@ -286,18 +284,13 @@ public class FragmentSetup extends FragmentBase {
|
||||
|
||||
btnIdentity.setEnabled(done);
|
||||
btnInbox.setEnabled(done);
|
||||
}
|
||||
});
|
||||
|
||||
if (livePrimaryDrafts == null)
|
||||
livePrimaryDrafts = db.folder().livePrimaryDrafts();
|
||||
else
|
||||
livePrimaryDrafts.removeObservers(getViewLifecycleOwner());
|
||||
|
||||
livePrimaryDrafts.observe(getViewLifecycleOwner(), new Observer<EntityFolder>() {
|
||||
@Override
|
||||
public void onChanged(EntityFolder drafts) {
|
||||
tvNoPrimaryDrafts.setVisibility(done && drafts == null ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
db.folder().livePrimaryDrafts().observe(getViewLifecycleOwner(), new Observer<EntityFolder>() {
|
||||
@Override
|
||||
public void onChanged(EntityFolder draft) {
|
||||
tvNoPrimaryDrafts.setVisibility(draft == null ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user