Always keep and synchronize flagged messages

pull/146/head
M66B 6 years ago
parent 36e6d34b54
commit b5c7cea122

File diff suppressed because it is too large Load Diff

@ -46,7 +46,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 12,
version = 13,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -220,6 +220,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("CREATE INDEX `index_operation_message` ON `operation` (`message`)");
}
})
.addMigrations(new Migration(12, 13) {
@Override
public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("CREATE INDEX `index_message_ui_flagged` ON `message` (`ui_flagged`)");
}
})
.build();
}

@ -300,20 +300,27 @@ public interface DaoMessage {
@Query("DELETE FROM message WHERE id = :id")
int deleteMessage(long id);
@Query("DELETE FROM message WHERE folder = :folder AND uid = :uid")
@Query("DELETE FROM message" +
" WHERE folder = :folder" +
" AND uid = :uid")
int deleteMessage(long folder, long uid);
@Query("DELETE FROM message WHERE folder = :folder AND NOT uid IS NULL")
@Query("DELETE FROM message" +
" WHERE folder = :folder" +
" AND NOT uid IS NULL")
int deleteLocalMessages(long folder);
@Query("DELETE FROM message WHERE folder = :folder AND seen")
@Query("DELETE FROM message" +
" WHERE folder = :folder" +
" AND seen")
int deleteSeenMessages(long folder);
@Query("DELETE FROM message" +
" WHERE folder = :folder" +
" AND received < :received" +
" AND NOT uid IS NULL" +
" AND (NOT ui_browsed OR :browsed)")
" AND (NOT ui_browsed OR :browsed)" +
" AND NOT ui_flagged")
int deleteMessagesBefore(long folder, long received, boolean browsed);
@Query("DELETE FROM message WHERE ui_found")

@ -74,6 +74,7 @@ import static androidx.room.ForeignKey.SET_NULL;
@Index(value = {"thread"}),
@Index(value = {"received"}),
@Index(value = {"ui_seen"}),
@Index(value = {"ui_flagged"}),
@Index(value = {"ui_hide"}),
@Index(value = {"ui_found"}),
@Index(value = {"ui_ignored"}),

@ -114,6 +114,8 @@ import javax.mail.event.StoreListener;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.search.ComparisonTerm;
import javax.mail.search.FlagTerm;
import javax.mail.search.OrTerm;
import javax.mail.search.ReceivedDateTerm;
import javax.net.ssl.SSLException;
@ -1881,7 +1883,12 @@ public class ServiceSynchronize extends LifecycleService {
// Reduce list of local uids
long search = SystemClock.elapsedRealtime();
Message[] imessages = ifolder.search(new ReceivedDateTerm(ComparisonTerm.GE, new Date(sync_time)));
Message[] imessages = ifolder.search(
new OrTerm(
new ReceivedDateTerm(ComparisonTerm.GE, new Date(sync_time)),
new FlagTerm(new Flags(Flags.Flag.FLAGGED), true)
)
);
Log.i(Helper.TAG, folder.name + " remote count=" + imessages.length +
" search=" + (SystemClock.elapsedRealtime() - search) + " ms");

Loading…
Cancel
Save