Load more documents than media

This commit is contained in:
Daniel Gasienica 2018-04-25 18:15:24 -04:00
parent 6ee56b8445
commit ac04f0648a
2 changed files with 13 additions and 4 deletions

View file

@ -577,14 +577,21 @@
// events up to its parent elements in the DOM. // events up to its parent elements in the DOM.
this.closeMenu(); this.closeMenu();
// We fetch more documents than media as they dont require to be loaded
// into memory right away. Revisit this once we have infinite scrolling:
const DEFAULT_MEDIA_FETCH_COUNT = 50;
const DEFAULT_DOCUMENTS_FETCH_COUNT = 150;
const conversationId = this.model.get('id'); const conversationId = this.model.get('id');
const WhisperMessageCollection = Whisper.MessageCollection; const WhisperMessageCollection = Whisper.MessageCollection;
const rawMedia = await Signal.Backbone.Conversation.fetchVisualMediaAttachments({ const rawMedia = await Signal.Backbone.Conversation.fetchVisualMediaAttachments({
conversationId, conversationId,
count: DEFAULT_MEDIA_FETCH_COUNT,
WhisperMessageCollection, WhisperMessageCollection,
}); });
const documents = await Signal.Backbone.Conversation.fetchFileAttachments({ const documents = await Signal.Backbone.Conversation.fetchFileAttachments({
conversationId, conversationId,
count: DEFAULT_DOCUMENTS_FETCH_COUNT,
WhisperMessageCollection, WhisperMessageCollection,
}); });

View file

@ -8,34 +8,36 @@ import { deferredToPromise } from '../../js/modules/deferred_to_promise';
import { IndexableBoolean } from '../types/IndexedDB'; import { IndexableBoolean } from '../types/IndexedDB';
import { Message } from '../types/Message'; import { Message } from '../types/Message';
const DEFAULT_FETCH_COUNT = 50;
export const fetchVisualMediaAttachments = async ({ export const fetchVisualMediaAttachments = async ({
conversationId, conversationId,
count,
WhisperMessageCollection, WhisperMessageCollection,
}: { }: {
conversationId: string; conversationId: string;
count: number;
WhisperMessageCollection: BackboneCollection<Message>; WhisperMessageCollection: BackboneCollection<Message>;
}): Promise<Array<Message>> => }): Promise<Array<Message>> =>
fetchFromAttachmentsIndex({ fetchFromAttachmentsIndex({
name: 'hasVisualMediaAttachments', name: 'hasVisualMediaAttachments',
conversationId, conversationId,
WhisperMessageCollection, WhisperMessageCollection,
count: DEFAULT_FETCH_COUNT, count,
}); });
export const fetchFileAttachments = async ({ export const fetchFileAttachments = async ({
conversationId, conversationId,
count,
WhisperMessageCollection, WhisperMessageCollection,
}: { }: {
conversationId: string; conversationId: string;
count: number;
WhisperMessageCollection: BackboneCollection<Message>; WhisperMessageCollection: BackboneCollection<Message>;
}): Promise<Array<Message>> => }): Promise<Array<Message>> =>
fetchFromAttachmentsIndex({ fetchFromAttachmentsIndex({
name: 'hasFileAttachments', name: 'hasFileAttachments',
conversationId, conversationId,
WhisperMessageCollection, WhisperMessageCollection,
count: DEFAULT_FETCH_COUNT, count,
}); });
const fetchFromAttachmentsIndex = async ({ const fetchFromAttachmentsIndex = async ({