mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 20:59:54 +01:00
Only consider the latest item for preloading.
This commit is contained in:
@@ -336,17 +336,19 @@ public class ConversationActivity extends BriarActivity
|
|||||||
new ArrayList<>(headers);
|
new ArrayList<>(headers);
|
||||||
sort(sorted, (a, b) ->
|
sort(sorted, (a, b) ->
|
||||||
Long.compare(b.getTimestamp(), a.getTimestamp()));
|
Long.compare(b.getTimestamp(), a.getTimestamp()));
|
||||||
// Eagerly load the text of the latest message to avoid jumping
|
if (!sorted.isEmpty()) {
|
||||||
for (ConversationMessageHeader h : sorted) {
|
// If the latest header is a private message, eagerly load
|
||||||
if (h instanceof PrivateMessageHeader) {
|
// its text so we can set the scroll position correctly
|
||||||
MessageId id = h.getId();
|
ConversationMessageHeader latest = sorted.get(0);
|
||||||
|
if (latest instanceof PrivateMessageHeader &&
|
||||||
|
((PrivateMessageHeader) latest).hasText()) {
|
||||||
|
MessageId id = latest.getId();
|
||||||
String text = textCache.get(id);
|
String text = textCache.get(id);
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
LOG.info("Eagerly loading text of latest message");
|
LOG.info("Eagerly loading text of latest message");
|
||||||
text = messagingManager.getMessageText(id);
|
text = messagingManager.getMessageText(id);
|
||||||
textCache.put(id, text);
|
textCache.put(id, text);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
displayMessages(revision, sorted);
|
displayMessages(revision, sorted);
|
||||||
|
|||||||
Reference in New Issue
Block a user