From ac04f0648a724b7da5e29db033fdb0275ed846fc Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Wed, 25 Apr 2018 18:15:24 -0400 Subject: [PATCH] Load more documents than media --- js/views/conversation_view.js | 7 +++++++ ts/backbone/Conversation.ts | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index b00b430bb3..956a9ede16 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -577,14 +577,21 @@ // events up to its parent elements in the DOM. this.closeMenu(); + // We fetch more documents than media as they don’t 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 WhisperMessageCollection = Whisper.MessageCollection; const rawMedia = await Signal.Backbone.Conversation.fetchVisualMediaAttachments({ conversationId, + count: DEFAULT_MEDIA_FETCH_COUNT, WhisperMessageCollection, }); const documents = await Signal.Backbone.Conversation.fetchFileAttachments({ conversationId, + count: DEFAULT_DOCUMENTS_FETCH_COUNT, WhisperMessageCollection, }); diff --git a/ts/backbone/Conversation.ts b/ts/backbone/Conversation.ts index 09209410ac..bd868d9e04 100644 --- a/ts/backbone/Conversation.ts +++ b/ts/backbone/Conversation.ts @@ -8,34 +8,36 @@ import { deferredToPromise } from '../../js/modules/deferred_to_promise'; import { IndexableBoolean } from '../types/IndexedDB'; import { Message } from '../types/Message'; -const DEFAULT_FETCH_COUNT = 50; - export const fetchVisualMediaAttachments = async ({ conversationId, + count, WhisperMessageCollection, }: { conversationId: string; + count: number; WhisperMessageCollection: BackboneCollection; }): Promise> => fetchFromAttachmentsIndex({ name: 'hasVisualMediaAttachments', conversationId, WhisperMessageCollection, - count: DEFAULT_FETCH_COUNT, + count, }); export const fetchFileAttachments = async ({ conversationId, + count, WhisperMessageCollection, }: { conversationId: string; + count: number; WhisperMessageCollection: BackboneCollection; }): Promise> => fetchFromAttachmentsIndex({ name: 'hasFileAttachments', conversationId, WhisperMessageCollection, - count: DEFAULT_FETCH_COUNT, + count, }); const fetchFromAttachmentsIndex = async ({