Fixed message reading

This commit is contained in:
Kai S. K. Engelbart 2020-02-03 06:57:19 +01:00
parent 123e51c8d5
commit 664717140d

View File

@ -45,15 +45,18 @@ public class Chat implements Serializable {
public void appendMessage(Message message) { model.add(message); }
/**
* Sets the status of all chat messages to {@code READ} starting from the bottom
* and stopping once a read message is found.
*
* Sets the status of all chat messages received from the recipient to
* {@code READ} starting from the bottom and stopping once a read message is
* found.
*
* @since Envoy v0.3-alpha
*/
public void read() {
for (int i = model.size() - 1; i >= 0; --i)
if (model.get(i).getStatus() == MessageStatus.READ) break;
else model.get(i).setStatus(MessageStatus.READ);
if (model.get(i).getSenderId() == recipient.getId()) {
if (model.get(i).getStatus() == MessageStatus.READ) break;
else model.get(i).setStatus(MessageStatus.READ);
}
}
/**