Implement several caching improvements for the Story Viewer.

This commit is contained in:
Alex Hart
2022-07-05 12:38:35 -03:00
parent 8f85b58612
commit 32312da384
25 changed files with 603 additions and 116 deletions

View File

@@ -189,10 +189,10 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns
public abstract boolean isStory(long messageId);
public abstract @NonNull Reader getOutgoingStoriesTo(@NonNull RecipientId recipientId);
public abstract @NonNull Reader getAllOutgoingStories(boolean reverse);
public abstract @NonNull Reader getAllOutgoingStories(boolean reverse, int limit);
public abstract @NonNull Reader getAllOutgoingStoriesAt(long sentTimestamp);
public abstract @NonNull List<StoryResult> getOrderedStoryRecipientsAndIds();
public abstract @NonNull Reader getAllStoriesFor(@NonNull RecipientId recipientId);
public abstract @NonNull Reader getAllStoriesFor(@NonNull RecipientId recipientId, int limit);
public abstract @NonNull MessageId getStoryId(@NonNull RecipientId authorId, long sentTimestamp) throws NoSuchMessageException;
public abstract int getNumberOfStoryReplies(long parentStoryId);
public abstract @NonNull List<RecipientId> getUnreadStoryThreadRecipientIds();

View File

@@ -620,10 +620,10 @@ public class MmsDatabase extends MessageDatabase {
}
@Override
public @NonNull MessageDatabase.Reader getAllOutgoingStories(boolean reverse) {
public @NonNull MessageDatabase.Reader getAllOutgoingStories(boolean reverse, int limit) {
String where = IS_STORY_CLAUSE + " AND (" + getOutgoingTypeClause() + ")";
return new Reader(rawQuery(where, null, reverse, -1L));
return new Reader(rawQuery(where, null, reverse, limit));
}
@Override
@@ -636,11 +636,11 @@ public class MmsDatabase extends MessageDatabase {
}
@Override
public @NonNull MessageDatabase.Reader getAllStoriesFor(@NonNull RecipientId recipientId) {
public @NonNull MessageDatabase.Reader getAllStoriesFor(@NonNull RecipientId recipientId, int limit) {
long threadId = SignalDatabase.threads().getThreadIdIfExistsFor(recipientId);
String where = IS_STORY_CLAUSE + " AND " + THREAD_ID_WHERE;
String[] whereArgs = SqlUtil.buildArgs(threadId);
Cursor cursor = rawQuery(where, whereArgs, false, -1L);
Cursor cursor = rawQuery(where, whereArgs, false, limit);
return new Reader(cursor);
}

View File

@@ -1403,7 +1403,7 @@ public class SmsDatabase extends MessageDatabase {
}
@Override
public @NonNull MessageDatabase.Reader getAllOutgoingStories(boolean reverse) {
public @NonNull MessageDatabase.Reader getAllOutgoingStories(boolean reverse, int limit) {
throw new UnsupportedOperationException();
}
@@ -1418,7 +1418,7 @@ public class SmsDatabase extends MessageDatabase {
}
@Override
public @NonNull MessageDatabase.Reader getAllStoriesFor(@NonNull RecipientId recipientId) {
public @NonNull MessageDatabase.Reader getAllStoriesFor(@NonNull RecipientId recipientId, int limit) {
throw new UnsupportedOperationException();
}