Prevent unhide on sync

pull/163/head
M66B 5 years ago
parent d4905b86e1
commit 6668cab3e5

File diff suppressed because it is too large Load Diff

@ -2266,7 +2266,9 @@ class Core {
" keywords=" + TextUtils.join(" ", keywords));
}
if (message.ui_hide && message.ui_snoozed == null &&
if (message.ui_hide &&
message.ui_snoozed == null &&
(message.ui_busy == null || message.ui_busy < new Date().getTime()) &&
db.operation().getOperationCount(folder.id, message.id) == 0) {
update = true;
message.ui_hide = false;

@ -57,7 +57,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 109,
version = 110,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1070,6 +1070,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `account` ADD COLUMN `ignore_size` INTEGER NOT NULL DEFAULT 0");
}
})
.addMigrations(new Migration(109, 110) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `ui_busy` INTEGER");
}
})
.build();
}

@ -428,6 +428,9 @@ public interface DaoMessage {
@Query("UPDATE message SET ui_ignored = :ui_ignored WHERE id = :id")
int setMessageUiIgnored(long id, boolean ui_ignored);
@Query("UPDATE message SET ui_busy = :busy WHERE id = :id")
int setMessageUiBusy(long id, Long busy);
@Query("UPDATE message SET received = :sent, sent = :sent WHERE id = :id")
int setMessageSent(long id, Long sent);

@ -158,6 +158,7 @@ public class EntityMessage implements Serializable {
public Boolean ui_ignored = false;
@NonNull
public Boolean ui_browsed = false;
public Long ui_busy;
public Long ui_snoozed;
public Integer color;
public Integer revision; // compose

@ -1634,6 +1634,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
args.putLong("id", message.id);
args.putBoolean("thread", viewType != AdapterMessage.ViewType.THREAD);
args.putLong("target", target);
args.putLong("busy", new Date().getTime() + UNDO_TIMEOUT * 2);
new SimpleTask<ArrayList<MessageTarget>>() {
@Override
@ -1641,6 +1642,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
long id = args.getLong("id");
boolean thread = args.getBoolean("thread");
long tid = args.getLong("target");
long busy = args.getLong("busy");
ArrayList<MessageTarget> result = new ArrayList<>();
@ -1662,6 +1664,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
message.account, message.thread, threading && thread ? null : id, message.folder);
for (EntityMessage threaded : messages) {
result.add(new MessageTarget(threaded, account, target));
db.message().setMessageUiBusy(threaded.id, busy);
db.message().setMessageUiHide(threaded.id, true);
// Prevent new message notification on undo
db.message().setMessageUiIgnored(threaded.id, true);
@ -3532,6 +3535,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
ArrayList<MessageTarget> result = args.getParcelableArrayList("result");
for (MessageTarget target : result) {
Log.i("Move undo id=" + target.id);
db.message().setMessageUiBusy(target.id, null);
db.message().setMessageUiHide(target.id, false);
}
@ -3580,6 +3584,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
continue;
Log.i("Move id=" + id + " target=" + target.folder.name);
db.message().setMessageUiBusy(target.id, null);
EntityOperation.queue(context, message, EntityOperation.MOVE, target.folder.id);
}

Loading…
Cancel
Save