mirror of https://github.com/M66B/FairEmail.git
Added folder last view time
This commit is contained in:
parent
82fde22604
commit
947ae77df3
File diff suppressed because it is too large
Load Diff
|
@ -68,7 +68,7 @@ import javax.mail.internet.InternetAddress;
|
|||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 290,
|
||||
version = 291,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
|
@ -2944,6 +2944,12 @@ public abstract class DB extends RoomDatabase {
|
|||
db.execSQL("UPDATE `folder` SET `count_unread` = 0 WHERE `type` = '" + EntityFolder.JUNK + "'");
|
||||
db.execSQL("UPDATE `folder` SET `count_unread` = 0 WHERE `type` = '" + EntityFolder.DRAFTS + "'");
|
||||
}
|
||||
}).addMigrations(new Migration(290, 291) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
logMigration(startVersion, endVersion);
|
||||
db.execSQL("ALTER TABLE `folder` ADD COLUMN `last_view` INTEGER");
|
||||
}
|
||||
}).addMigrations(new Migration(998, 999) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
|
|
|
@ -402,6 +402,12 @@ public interface DaoFolder {
|
|||
@Query("UPDATE folder SET last_sync_count = :last_sync_count WHERE id = :id AND NOT (last_sync_count IS :last_sync_count)")
|
||||
int setFolderLastSyncCount(long id, Integer last_sync_count);
|
||||
|
||||
@Query("UPDATE folder SET last_view = :last_view" +
|
||||
" WHERE (id = :folder" +
|
||||
" OR (type = :type AND type <> '" + EntityFolder.OUTBOX + "')" +
|
||||
" OR (account = :account AND :folder IS NULL AND :type IS NULL AND unified))")
|
||||
int setFolderLastView(Long account, Long folder, String type, long last_view);
|
||||
|
||||
@Query("UPDATE folder SET read_only = :read_only WHERE id = :id AND NOT (read_only IS :read_only)")
|
||||
int setFolderReadOnly(long id, boolean read_only);
|
||||
|
||||
|
|
|
@ -150,6 +150,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
|
|||
public Long last_sync;
|
||||
public Long last_sync_foreground;
|
||||
public Integer last_sync_count; // POP3
|
||||
public Long last_view;
|
||||
|
||||
static final String INBOX = "Inbox";
|
||||
static final String OUTBOX = "Outbox";
|
||||
|
|
|
@ -5351,35 +5351,50 @@ public class FragmentMessages extends FragmentBase
|
|||
|
||||
if (viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER) {
|
||||
boolean notify_clear = prefs.getBoolean("notify_clear", false);
|
||||
if (notify_clear) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("folder", folder);
|
||||
args.putString("type", type);
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected Void onExecute(Context context, Bundle args) {
|
||||
long folder = args.getLong("folder");
|
||||
String type = args.getString("type");
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("folder", folder);
|
||||
args.putString("type", type);
|
||||
args.putBoolean("notify_clear", notify_clear);
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected Void onExecute(Context context, Bundle args) {
|
||||
long folder = args.getLong("folder");
|
||||
String type = args.getString("type");
|
||||
boolean notify_clear = args.getBoolean("notify_clear");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
if (folder < 0) {
|
||||
List<EntityAccount> accounts = db.account().getSynchronizingAccounts(null);
|
||||
if (accounts != null)
|
||||
for (EntityAccount account : accounts)
|
||||
db.message().ignoreAll(account.id, null, type);
|
||||
} else
|
||||
db.message().ignoreAll(null, folder, type);
|
||||
for (EntityAccount account : accounts) {
|
||||
if (notify_clear)
|
||||
db.message().ignoreAll(account.id, null, type);
|
||||
db.folder().setFolderLastView(account.id, null, type, new Date().getTime());
|
||||
}
|
||||
} else {
|
||||
if (notify_clear)
|
||||
db.message().ignoreAll(null, folder, type);
|
||||
db.folder().setFolderLastView(null, folder, type, new Date().getTime());
|
||||
}
|
||||
|
||||
return null;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(this, args, "messages:ignore");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(this, args, "messages:ignore");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue