Skip to content

Commit

Permalink
Allow refreshing unified system folders
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Jul 22, 2019
1 parent ed92a99 commit 9589824
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions app/src/main/java/eu/faircode/email/DaoFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ public interface DaoFolder {
@Query("SELECT folder.* FROM folder" +
" JOIN account ON account.id = folder.account" +
" WHERE account.synchronize" +
" AND folder.synchronize AND unified")
List<EntityFolder> getFoldersSynchronizingUnified();
" AND folder.synchronize" +
" AND ((:type IS NULL AND folder.unified) OR folder.type = :type)")
List<EntityFolder> getFoldersSynchronizingUnified(String type);

@Query("SELECT folder.* FROM folder" +
" JOIN account ON account.id = folder.account" +
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/eu/faircode/email/FragmentFolders.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ protected Void onExecute(Context context, Bundle args) {

if (aid < 0) {
// Unified inbox
List<EntityFolder> folders = db.folder().getFoldersSynchronizingUnified();
List<EntityFolder> folders = db.folder().getFoldersSynchronizingUnified(null);
for (EntityFolder folder : folders) {
EntityOperation.sync(context, folder.id, true);

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/eu/faircode/email/FragmentMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,6 @@ public void onSelectionChanged() {
swipeRefresh.setOnChildScrollUpCallback(new SwipeRefreshLayout.OnChildScrollUpCallback() {
@Override
public boolean canChildScrollUp(@NonNull SwipeRefreshLayout parent, @Nullable View child) {
if (type != null)
return true;
if (viewType != AdapterMessage.ViewType.UNIFIED && viewType != AdapterMessage.ViewType.FOLDER)
return true;
if (!prefs.getBoolean("pull", true))
Expand Down Expand Up @@ -988,6 +986,7 @@ private void scrollToVisibleItem(LinearLayoutManager llm, boolean bottom) {
private void onSwipeRefresh() {
Bundle args = new Bundle();
args.putLong("folder", folder);
args.putString("type", type);

new SimpleTask<Void>() {
@Override
Expand All @@ -998,6 +997,7 @@ protected void onPreExecute(Bundle args) {
@Override
protected Void onExecute(Context context, Bundle args) {
long fid = args.getLong("folder");
String type = args.getString("type");

if (!ConnectionHelper.getNetworkState(context).isSuitable())
throw new IllegalStateException(context.getString(R.string.title_no_internet));
Expand All @@ -1010,7 +1010,7 @@ protected Void onExecute(Context context, Bundle args) {

List<EntityFolder> folders = new ArrayList<>();
if (fid < 0)
folders.addAll(db.folder().getFoldersSynchronizingUnified());
folders.addAll(db.folder().getFoldersSynchronizingUnified(type));
else {
EntityFolder folder = db.folder().getFolder(fid);
if (folder != null)
Expand Down

0 comments on commit 9589824

Please sign in to comment.