Explicitly found

pull/146/head
M66B 6 years ago
parent abfefdcb5f
commit 4d103816b9

@ -266,7 +266,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
try { try {
db.beginTransaction(); db.beginTransaction();
for (Long mid : db.message().getMessageByFolder(id)) { for (Long mid : db.message().getMessageByFolder(id, false)) {
EntityMessage message = db.message().getMessage(mid); EntityMessage message = db.message().getMessage(mid);
db.message().setMessageUiHide(message.id, true); db.message().setMessageUiHide(message.id, true);
EntityOperation.queue(db, message, EntityOperation.DELETE); EntityOperation.queue(db, message, EntityOperation.DELETE);

@ -598,6 +598,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("account", message.account); args.putLong("account", message.account);
args.putString("thread", message.thread); args.putString("thread", message.thread);
args.putBoolean("found", message.ui_found);
args.putBoolean("seen", seen); args.putBoolean("seen", seen);
new SimpleTask<Void>() { new SimpleTask<Void>() {
@ -605,13 +606,14 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
protected Void onLoad(Context context, Bundle args) throws Throwable { protected Void onLoad(Context context, Bundle args) throws Throwable {
long account = args.getLong("account"); long account = args.getLong("account");
String thread = args.getString("thread"); String thread = args.getString("thread");
boolean found = args.getBoolean("found");
boolean seen = args.getBoolean("seen"); boolean seen = args.getBoolean("seen");
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();
List<EntityMessage> messages = db.message().getMessageByThread(account, thread); List<EntityMessage> messages = db.message().getMessageByThread(account, thread, found);
for (EntityMessage message : messages) { for (EntityMessage message : messages) {
db.message().setMessageUiSeen(message.id, seen); db.message().setMessageUiSeen(message.id, seen);
db.message().setMessageUiIgnored(message.id, true); db.message().setMessageUiIgnored(message.id, true);
@ -679,8 +681,8 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
try { try {
db.beginTransaction(); db.beginTransaction();
List<EntityMessage> messages = List<EntityMessage> messages = db.message().getMessageByThread(
db.message().getMessageByThread(message.account, message.thread); message.account, message.thread, message.ui_found);
for (EntityMessage threaded : messages) { for (EntityMessage threaded : messages) {
db.message().setMessageUiHide(threaded.id, true); db.message().setMessageUiHide(threaded.id, true);
EntityOperation.queue(db, threaded, EntityOperation.MOVE, target); EntityOperation.queue(db, threaded, EntityOperation.MOVE, target);

@ -151,16 +151,16 @@ public interface DaoMessage {
@Query("SELECT id" + @Query("SELECT id" +
" FROM message" + " FROM message" +
" WHERE folder = :folder" + " WHERE folder = :folder" +
" AND NOT ui_found" + " AND ui_found = :found" +
" ORDER BY message.received DESC, message.sent DESC") " ORDER BY message.received DESC, message.sent DESC")
List<Long> getMessageByFolder(long folder); List<Long> getMessageByFolder(long folder, boolean found);
@Query("SELECT *" + @Query("SELECT *" +
" FROM message" + " FROM message" +
" WHERE account = :account" + " WHERE account = :account" +
" AND thread = :thread" + " AND thread = :thread" +
" AND NOT ui_found") " AND ui_found = :found")
List<EntityMessage> getMessageByThread(long account, String thread); List<EntityMessage> getMessageByThread(long account, String thread, boolean found);
@Query("SELECT message.* FROM message" + @Query("SELECT message.* FROM message" +
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +
@ -172,8 +172,9 @@ public interface DaoMessage {
@Query("SELECT * FROM message" + @Query("SELECT * FROM message" +
" WHERE folder = :folder" + " WHERE folder = :folder" +
" AND ui_seen") " AND ui_seen" +
List<EntityMessage> getMessageSeen(long folder); " AND ui_found = :found")
List<EntityMessage> getMessageSeen(long folder, boolean found);
@Query("SELECT id FROM message" + @Query("SELECT id FROM message" +
" WHERE content" + " WHERE content" +

@ -475,8 +475,8 @@ public class FragmentMessages extends FragmentEx {
result.target = target; result.target = target;
if (thread) { if (thread) {
List<EntityMessage> messages = List<EntityMessage> messages = db.message().getMessageByThread(
db.message().getMessageByThread(message.account, message.thread); message.account, message.thread, message.ui_found);
for (EntityMessage threaded : messages) { for (EntityMessage threaded : messages) {
if (!threaded.ui_hide && threaded.folder.equals(message.folder)) if (!threaded.ui_hide && threaded.folder.equals(message.folder))
result.ids.add(threaded.id); result.ids.add(threaded.id);
@ -612,8 +612,8 @@ public class FragmentMessages extends FragmentEx {
for (long id : ids) { for (long id : ids) {
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
List<EntityMessage> messages = List<EntityMessage> messages = db.message().getMessageByThread(
db.message().getMessageByThread(message.account, message.thread); message.account, message.thread, message.ui_found);
for (EntityMessage threaded : messages) { for (EntityMessage threaded : messages) {
if (threaded.folder.equals(message.folder)) { if (threaded.folder.equals(message.folder)) {
db.message().setMessageUiHide(threaded.id, true); db.message().setMessageUiHide(threaded.id, true);
@ -1047,7 +1047,7 @@ public class FragmentMessages extends FragmentEx {
try { try {
db.beginTransaction(); db.beginTransaction();
for (EntityMessage message : db.message().getMessageSeen(outbox)) { for (EntityMessage message : db.message().getMessageSeen(outbox, false)) {
EntityIdentity identity = db.identity().getIdentity(message.identity); EntityIdentity identity = db.identity().getIdentity(message.identity);
EntityFolder sent = db.folder().getFolderByType(identity.account, EntityFolder.SENT); EntityFolder sent = db.folder().getFolderByType(identity.account, EntityFolder.SENT);
if (sent != null) { if (sent != null) {
@ -1313,6 +1313,7 @@ public class FragmentMessages extends FragmentEx {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("account", account); args.putLong("account", account);
args.putString("thread", thread); args.putString("thread", thread);
args.putBoolean("found", found);
args.putString("folderType", folderType); args.putString("folderType", folderType);
new SimpleTask<MessageTarget>() { new SimpleTask<MessageTarget>() {
@ -1320,6 +1321,7 @@ public class FragmentMessages extends FragmentEx {
protected MessageTarget onLoad(Context context, Bundle args) { protected MessageTarget onLoad(Context context, Bundle args) {
long account = args.getLong("account"); long account = args.getLong("account");
String thread = args.getString("thread"); String thread = args.getString("thread");
boolean found = args.getBoolean("found");
String folderType = args.getString("folderType"); String folderType = args.getString("folderType");
MessageTarget result = new MessageTarget(); MessageTarget result = new MessageTarget();
@ -1330,7 +1332,7 @@ public class FragmentMessages extends FragmentEx {
result.target = db.folder().getFolderByType(account, folderType); result.target = db.folder().getFolderByType(account, folderType);
List<EntityMessage> messages = db.message().getMessageByThread(account, thread); List<EntityMessage> messages = db.message().getMessageByThread(account, thread, found);
for (EntityMessage message : messages) for (EntityMessage message : messages)
if (message.uid != null && !result.target.id.equals(message.folder)) { if (message.uid != null && !result.target.id.equals(message.folder)) {
result.ids.add(message.id); result.ids.add(message.id);

@ -88,7 +88,7 @@ public class ViewModelBrowse extends ViewModel {
db.beginTransaction(); db.beginTransaction();
if (state.messages == null) if (state.messages == null)
state.messages = db.message().getMessageByFolder(state.fid); state.messages = db.message().getMessageByFolder(state.fid, false);
int matched = 0; int matched = 0;
for (int i = state.local; i < state.messages.size() && matched < state.pageSize; i++) { for (int i = state.local; i < state.messages.size() && matched < state.pageSize; i++) {

Loading…
Cancel
Save