Don't check whether messages are visible before lowering ack flag.

This check excludes messages that aren't shared, including incoming private messages. The check isn't necessary because lowerAckFlag() ignores messages for which no status row exists for the contact.
This commit is contained in:
akwizgran
2022-08-05 14:11:23 +01:00
parent 217a6dbf1c
commit 15d29f6189
2 changed files with 2 additions and 13 deletions

View File

@@ -1099,11 +1099,7 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
T txn = unbox(transaction);
if (!db.containsContact(txn, c))
throw new NoSuchContactException();
List<MessageId> visible = new ArrayList<>(acked.size());
for (MessageId m : acked) {
if (db.containsVisibleMessage(txn, c, m)) visible.add(m);
}
db.lowerAckFlag(txn, c, visible);
db.lowerAckFlag(txn, c, acked);
}
@Override

View File

@@ -1396,14 +1396,7 @@ public class DatabaseComponentImplTest extends BrambleMockTestCase {
will(returnValue(txn));
oneOf(database).containsContact(txn, contactId);
will(returnValue(true));
// First message is still visible to the contact - flag lowered
oneOf(database).containsVisibleMessage(txn, contactId, messageId);
will(returnValue(true));
// Second message is no longer visible - flag not lowered
oneOf(database).containsVisibleMessage(txn, contactId, messageId1);
will(returnValue(false));
oneOf(database)
.lowerAckFlag(txn, contactId, singletonList(messageId));
oneOf(database).lowerAckFlag(txn, contactId, acked);
oneOf(database).commitTransaction(txn);
}});
DatabaseComponent db = createDatabaseComponent(database, eventBus,