Revert "Added operation view"

This reverts commit 1b2900d022.
This commit is contained in:
M66B 2020-11-27 19:09:14 +01:00
parent 15a020cd0a
commit 502de67f2b
4 changed files with 5 additions and 94 deletions

View File

@ -81,8 +81,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
views = {
TupleAccountView.class,
TupleIdentityView.class,
TupleFolderView.class,
TupleOperationView.class
TupleFolderView.class
}
)
@ -217,32 +216,6 @@ public abstract class DB extends RoomDatabase {
}
}
});
db.operation().liveOperationView().observeForever(new Observer<List<TupleOperationView>>() {
private List<TupleOperationView> last = null;
@Override
public void onChanged(List<TupleOperationView> operations) {
if (operations == null)
operations = new ArrayList<>();
boolean changed = false;
if (last == null || last.size() != operations.size())
changed = true;
else
for (int i = 0; i < operations.size(); i++)
if (!operations.get(i).equals(last.get(i))) {
changed = true;
last = operations;
}
if (changed) {
Log.i("Invalidating operation view");
last = operations;
db.getInvalidationTracker().notifyObserversByTableNames("folder");
}
}
});
}
public static synchronized DB getInstance(Context context) {
@ -261,7 +234,6 @@ public abstract class DB extends RoomDatabase {
mViewTables.get("account_view").clear();
mViewTables.get("identity_view").clear();
mViewTables.get("folder_view").clear();
mViewTables.get("operation_view").clear();
Log.i("Disabled view invalidation");
} catch (ReflectiveOperationException ex) {
@ -1778,13 +1750,6 @@ public abstract class DB extends RoomDatabase {
" (SELECT id FROM account" +
" WHERE host IN ('imap.arcor.de'))");
}
})
.addMigrations(new Migration(178, 179) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("CREATE VIEW IF NOT EXISTS `operation_view` AS " + TupleOperationView.query);
}
});
}

View File

@ -48,7 +48,7 @@ public interface DaoFolder {
" LEFT JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
" LEFT JOIN rule ON rule.folder = folder.id" +
" LEFT JOIN operation_view AS operation ON operation.folder = folder.id" +
" LEFT JOIN operation ON operation.folder = folder.id" +
" WHERE folder.account = :account AND account.synchronize" +
" GROUP BY folder.id")
List<TupleFolderEx> getFoldersEx(long account);
@ -87,7 +87,7 @@ public interface DaoFolder {
" JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id" +
" LEFT JOIN rule ON rule.folder = folder.id" +
" LEFT JOIN operation_view AS operation ON operation.folder = folder.id" +
" LEFT JOIN operation ON operation.folder = folder.id" +
" WHERE CASE WHEN :primary THEN account.`primary` ELSE" +
" CASE WHEN :account IS NULL" +
" THEN folder.unified AND account.synchronize" +
@ -110,7 +110,7 @@ public interface DaoFolder {
" JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
" LEFT JOIN rule ON rule.folder = folder.id" +
" LEFT JOIN operation_view AS operation ON operation.folder = folder.id" +
" LEFT JOIN operation ON operation.folder = folder.id" +
" WHERE account.`synchronize`" +
" AND ((:type IS NULL AND folder.unified) OR folder.type = :type)" +
" GROUP BY folder.id")
@ -148,7 +148,7 @@ public interface DaoFolder {
" LEFT JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
" LEFT JOIN rule ON rule.folder = folder.id" +
" LEFT JOIN operation_view AS operation ON operation.folder = folder.id" +
" LEFT JOIN operation ON operation.folder = folder.id" +
" WHERE folder.id = :id" +
" GROUP BY folder.id")
LiveData<TupleFolderEx> liveFolderEx(long id);

View File

@ -70,9 +70,6 @@ public interface DaoOperation {
" ORDER BY " + priority + ", id")
LiveData<List<TupleOperationEx>> liveOperations(long account);
@Query(TupleOperationView.query)
LiveData<List<TupleOperationView>> liveOperationView();
@Transaction
@Query("SELECT operation.*" +
" FROM operation" +

View File

@ -1,51 +0,0 @@
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-2020 by Marcel Bokhorst (M66B)
*/
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.room.DatabaseView;
import java.util.Objects;
@DatabaseView(
viewName = "operation_view",
value = TupleOperationView.query
)
public class TupleOperationView {
static final String query = "SELECT id, folder, state FROM operation";
@NonNull
public Long id;
@NonNull
public Long folder;
public String state;
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof TupleOperationView) {
TupleOperationView other = (TupleOperationView) obj;
return (this.id.equals(other.id) &&
this.folder.equals(other.folder) &&
Objects.equals(this.state, other.state));
} else
return false;
}
}