Prevent invalidation of paged messages by folder updates

pull/156/head
M66B 6 years ago
parent 2784ea389c
commit 9d1be95154

File diff suppressed because it is too large Load Diff

@ -54,7 +54,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 85,
version = 86,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -66,6 +66,9 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
EntityAnswer.class,
EntityRule.class,
EntityLog.class
},
views = {
EntityFolderView.class
}
)
@ -852,6 +855,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("UPDATE attachment SET size = NULL WHERE size = 0");
}
})
.addMigrations(new Migration(85, 86) {
@Override
public void migrate(SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("CREATE VIEW `folderview` AS SELECT id, account, name, type, display, unified FROM folder");
}
})
.build();
}

@ -56,7 +56,7 @@ public interface DaoMessage {
" FROM message" +
" JOIN account ON account.id = message.account" +
" LEFT JOIN identity ON identity.id = message.identity" +
" JOIN folder ON folder.id = message.folder" +
" JOIN folderview AS folder ON folder.id = message.folder" +
" WHERE account.`synchronize`" +
" AND (NOT message.ui_hide OR :debug)" +
" AND (NOT :found OR ui_found = :found)" +
@ -102,8 +102,8 @@ public interface DaoMessage {
" FROM message" +
" JOIN account ON account.id = message.account" +
" LEFT JOIN identity ON identity.id = message.identity" +
" JOIN folder ON folder.id = message.folder" +
" JOIN folder f ON f.id = :folder" +
" JOIN folderview AS folder ON folder.id = message.folder" +
" JOIN folderview f ON f.id = :folder" +
" WHERE (message.account = f.account OR " + is_outbox + ")" +
" AND (NOT message.ui_hide OR :debug)" +
" AND (NOT :found OR ui_found = :found)" +
@ -144,7 +144,7 @@ public interface DaoMessage {
" FROM message" +
" JOIN account ON account.id = message.account" +
" LEFT JOIN identity ON identity.id = message.identity" +
" JOIN folder ON folder.id = message.folder" +
" JOIN folderview AS folder ON folder.id = message.folder" +
" WHERE message.account = :account" +
" AND message.thread = :thread" +
" AND (:id IS NULL OR message.id = :id)" +

@ -0,0 +1,39 @@
package eu.faircode.email;
/*
This file is part of FairEmail.
FairEmail is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FairEmail is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
Copyright 2018-2019 by Marcel Bokhorst (M66B)
*/
import androidx.annotation.NonNull;
import androidx.room.DatabaseView;
@DatabaseView(
viewName = "folderview",
value = "SELECT id, account, name, type, display, unified FROM folder")
public class EntityFolderView {
public Long id;
public Long account;
@NonNull
public String name;
@NonNull
public String type;
public String display;
@NonNull
public Boolean unified = false;
}
Loading…
Cancel
Save