Skip to content

Commit

Permalink
Load more documents than media
Browse files Browse the repository at this point in the history
  • Loading branch information
gasi-signal committed Apr 27, 2018
1 parent 6ee56b8 commit ac04f06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions js/views/conversation_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
10 changes: 6 additions & 4 deletions ts/backbone/Conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Message>;
}): Promise<Array<Message>> =>
fetchFromAttachmentsIndex({
name: 'hasVisualMediaAttachments',
conversationId,
WhisperMessageCollection,
count: DEFAULT_FETCH_COUNT,
count,
});

export const fetchFileAttachments = async ({
conversationId,
count,
WhisperMessageCollection,
}: {
conversationId: string;
count: number;
WhisperMessageCollection: BackboneCollection<Message>;
}): Promise<Array<Message>> =>
fetchFromAttachmentsIndex({
name: 'hasFileAttachments',
conversationId,
WhisperMessageCollection,
count: DEFAULT_FETCH_COUNT,
count,
});

const fetchFromAttachmentsIndex = async ({
Expand Down

0 comments on commit ac04f06

Please sign in to comment.