Reduce fetches when you open a conversation.
This commit is contained in:
parent
3c6bed90db
commit
93f37ad70f
5 changed files with 29 additions and 4 deletions
|
@ -97,6 +97,8 @@ class ConversationDataSource implements PagedDataSource<ConversationMessage> {
|
|||
|
||||
records = attachmentHelper.buildUpdatedModels(context, records);
|
||||
|
||||
stopwatch.split("attachment-models");
|
||||
|
||||
List<ConversationMessage> messages = Stream.of(records)
|
||||
.map(m -> ConversationMessageFactory.createWithUnresolvedData(context, m, mentionHelper.getMentions(m.getId())))
|
||||
.toList();
|
||||
|
|
|
@ -54,6 +54,14 @@ public abstract class Database {
|
|||
notifyVerboseConversationListeners(threadId);
|
||||
}
|
||||
|
||||
protected void notifyVerboseConversationListeners(Set<Long> threadIds) {
|
||||
ApplicationDependencies.getDatabaseObserver().notifyVerboseConversationListeners(threadIds);
|
||||
|
||||
for (long threadId : threadIds) {
|
||||
notifyVerboseConversationListeners(threadId);
|
||||
}
|
||||
}
|
||||
|
||||
protected void notifyVerboseConversationListeners(long threadId) {
|
||||
ApplicationDependencies.getDatabaseObserver().notifyVerboseConversationListeners(threadId);
|
||||
context.getContentResolver().notifyChange(DatabaseContentProviders.Conversation.getVerboseUriForThread(threadId), null);
|
||||
|
|
|
@ -112,6 +112,18 @@ public final class DatabaseObserver {
|
|||
application.getContentResolver().notifyChange(DatabaseContentProviders.Conversation.getVerboseUriForThread(threadId), null);
|
||||
}
|
||||
|
||||
public void notifyVerboseConversationListeners(Set<Long> threadIds) {
|
||||
executor.execute(() -> {
|
||||
for (long threadId : threadIds) {
|
||||
notifyMapped(verboseConversationObservers, threadId);
|
||||
}
|
||||
});
|
||||
|
||||
for (long threadId : threadIds) {
|
||||
application.getContentResolver().notifyChange(DatabaseContentProviders.Conversation.getVerboseUriForThread(threadId), null);
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyVerboseConversationListeners(long threadId) {
|
||||
executor.execute(() -> {
|
||||
notifyMapped(verboseConversationObservers, threadId);
|
||||
|
|
|
@ -886,10 +886,13 @@ public class SmsDatabase extends MessageDatabase {
|
|||
contentValues.put(READ, 1);
|
||||
}
|
||||
|
||||
db.update(TABLE_NAME, contentValues, ID_WHERE, SqlUtil.buildArgs(record.getId()));
|
||||
}
|
||||
SqlUtil.Query query = SqlUtil.buildTrueUpdateQuery(ID_WHERE, SqlUtil.buildArgs(record.getId()), contentValues);
|
||||
boolean updated = db.update(TABLE_NAME, contentValues, query.getWhere(), query.getWhereArgs()) > 0;
|
||||
|
||||
notifyConversationListeners(threadId);
|
||||
if (updated) {
|
||||
notifyConversationListeners(threadId);
|
||||
}
|
||||
}
|
||||
|
||||
return sameEraId;
|
||||
}
|
||||
|
|
|
@ -430,7 +430,7 @@ public class ThreadDatabase extends Database {
|
|||
db.endTransaction();
|
||||
}
|
||||
|
||||
notifyConversationListeners(threadIdToSinceTimestamp.keySet());
|
||||
notifyVerboseConversationListeners(threadIdToSinceTimestamp.keySet());
|
||||
notifyConversationListListeners();
|
||||
|
||||
if (needsSync) {
|
||||
|
|
Loading…
Add table
Reference in a new issue