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