Fix insertion of oldest message

This commit is contained in:
Kai S. K. Engelbart 2020-07-01 08:58:02 +02:00
parent b380efc38f
commit e5ddf32b4a
No known key found for this signature in database
GPG Key ID: 0A48559CA32CB48F

View File

@ -101,12 +101,12 @@ public final class Chat implements Serializable {
* @since Envoy Client v0.1-beta
*/
public void insert(Message message) {
if (messages.isEmpty()) messages.add(message);
else for (int i = messages.size() - 1; i >= 0; --i)
for (int i = messages.size() - 1; i >= 0; --i)
if (message.getCreationDate().isAfter(messages.get(i).getCreationDate())) {
messages.add(i + 1, message);
break;
return;
}
messages.add(0, message);
}
/**