Last touched

pull/215/head
M66B 1 year ago
parent 1fad4ad80c
commit 04fe7b3743

File diff suppressed because it is too large Load Diff

@ -8540,6 +8540,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
same = false; same = false;
log("last_attempt changed " + prev.last_attempt + "/" + next.last_attempt, next.id); log("last_attempt changed " + prev.last_attempt + "/" + next.last_attempt, next.id);
} }
// last_touched
// accountPop // accountPop
if (!Objects.equals(prev.accountName, next.accountName)) { if (!Objects.equals(prev.accountName, next.accountName)) {

@ -68,7 +68,7 @@ import javax.mail.internet.InternetAddress;
// https://developer.android.com/topic/libraries/architecture/room.html // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 292, version = 293,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -2956,6 +2956,12 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion); logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `envelopeFrom` TEXT"); db.execSQL("ALTER TABLE `identity` ADD COLUMN `envelopeFrom` TEXT");
} }
}).addMigrations(new Migration(292, 293) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `last_touched` INTEGER");
}
}).addMigrations(new Migration(998, 999) { }).addMigrations(new Migration(998, 999) {
@Override @Override
public void migrate(@NonNull SupportSQLiteDatabase db) { public void migrate(@NonNull SupportSQLiteDatabase db) {

@ -105,7 +105,7 @@ public interface DaoMessage {
" WHEN 'size' = :sort1 THEN -SUM(message.total)" + " WHEN 'size' = :sort1 THEN -SUM(message.total)" +
" WHEN 'attachments' = :sort1 THEN -SUM(message.attachments)" + " WHEN 'attachments' = :sort1 THEN -SUM(message.attachments)" +
" WHEN 'snoozed' = :sort1 THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" + " WHEN 'snoozed' = :sort1 THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" +
" WHEN 'touched' = :sort1 THEN IFNULL(-message.last_attempt, 0)" + " WHEN 'touched' = :sort1 THEN IFNULL(-message.last_touched, 0)" +
" ELSE 0" + " ELSE 0" +
" END" + " END" +
", CASE" + ", CASE" +
@ -182,7 +182,7 @@ public interface DaoMessage {
" WHEN 'size' = :sort1 THEN -SUM(message.total)" + " WHEN 'size' = :sort1 THEN -SUM(message.total)" +
" WHEN 'attachments' = :sort1 THEN -SUM(message.attachments)" + " WHEN 'attachments' = :sort1 THEN -SUM(message.attachments)" +
" WHEN 'snoozed' = :sort1 THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" + " WHEN 'snoozed' = :sort1 THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" +
" WHEN 'touched' = :sort1 THEN IFNULL(-message.last_attempt, 0)" + " WHEN 'touched' = :sort1 THEN IFNULL(-message.last_touched, 0)" +
" ELSE 0" + " ELSE 0" +
" END" + " END" +
", CASE" + ", CASE" +
@ -379,10 +379,10 @@ public interface DaoMessage {
" AND (:size IS NULL OR total > :size)" + " AND (:size IS NULL OR total > :size)" +
" AND (:after IS NULL OR received > :after)" + " AND (:after IS NULL OR received > :after)" +
" AND (:before IS NULL OR received < :before)" + " AND (:before IS NULL OR received < :before)" +
" AND (:touched IS NULL OR last_attempt > :touched)" + " AND (:touched IS NULL OR last_touched > :touched)" +
" AND NOT message.folder IN (:exclude)" + " AND NOT message.folder IN (:exclude)" +
" GROUP BY message.id" + " GROUP BY message.id" +
" ORDER BY CASE WHEN :touched IS NULL THEN received ELSE last_attempt END DESC" + " ORDER BY CASE WHEN :touched IS NULL THEN received ELSE last_touched END DESC" +
" LIMIT :limit OFFSET :offset") " LIMIT :limit OFFSET :offset")
List<TupleMatch> matchMessages( List<TupleMatch> matchMessages(
Long account, Long folder, long[] exclude, String find, Long account, Long folder, long[] exclude, String find,
@ -925,6 +925,9 @@ public interface DaoMessage {
@Query("UPDATE message SET last_attempt = :last_attempt WHERE id = :id AND NOT (last_attempt IS :last_attempt)") @Query("UPDATE message SET last_attempt = :last_attempt WHERE id = :id AND NOT (last_attempt IS :last_attempt)")
int setMessageLastAttempt(long id, Long last_attempt); int setMessageLastAttempt(long id, Long last_attempt);
@Query("UPDATE message SET last_touched = :last_touched WHERE id = :id AND NOT (last_touched IS :last_touched)")
int setMessageLastTouched(long id, Long last_touched);
@Query("UPDATE message SET ui_ignored = 1" + @Query("UPDATE message SET ui_ignored = 1" +
" WHERE NOT ui_ignored" + " WHERE NOT ui_ignored" +
" AND account IN (" + " AND account IN (" +

@ -261,7 +261,8 @@ public class EntityMessage implements Serializable {
public Integer revisions; // compose public Integer revisions; // compose
public String warning; // persistent public String warning; // persistent
public String error; // volatile public String error; // volatile
public Long last_attempt; // send / last touched public Long last_attempt; // send
public Long last_touched;
static String generateMessageId() { static String generateMessageId() {
return generateMessageId("localhost"); return generateMessageId("localhost");

@ -7831,7 +7831,7 @@ public class FragmentMessages extends FragmentBase
} }
if (!EntityFolder.OUTBOX.equals(folder.type)) if (!EntityFolder.OUTBOX.equals(folder.type))
db.message().setMessageLastAttempt(message.id, new Date().getTime()); db.message().setMessageLastTouched(message.id, new Date().getTime());
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {

Loading…
Cancel
Save