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
@@ -1099,11 +1099,7 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
T txn = unbox(transaction); T txn = unbox(transaction);
if (!db.containsContact(txn, c)) if (!db.containsContact(txn, c))
throw new NoSuchContactException(); throw new NoSuchContactException();
List<MessageId> visible = new ArrayList<>(acked.size()); db.lowerAckFlag(txn, c, acked);
for (MessageId m : acked) {
if (db.containsVisibleMessage(txn, c, m)) visible.add(m);
}
db.lowerAckFlag(txn, c, visible);
} }
@Override @Override
@@ -1396,14 +1396,7 @@ public class DatabaseComponentImplTest extends BrambleMockTestCase {
will(returnValue(txn)); will(returnValue(txn));
oneOf(database).containsContact(txn, contactId); oneOf(database).containsContact(txn, contactId);
will(returnValue(true)); will(returnValue(true));
// First message is still visible to the contact - flag lowered oneOf(database).lowerAckFlag(txn, contactId, acked);
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).commitTransaction(txn); oneOf(database).commitTransaction(txn);
}}); }});
DatabaseComponent db = createDatabaseComponent(database, eventBus, DatabaseComponent db = createDatabaseComponent(database, eventBus,