Virtualize Messages List - only render what's visible

This commit is contained in:
Scott Nonnenberg 2019-05-31 15:42:01 -07:00
parent a976cfe6b6
commit 5ebd8bc690
73 changed files with 4717 additions and 2745 deletions

View file

@ -22,31 +22,28 @@
Whisper.ConversationStack = Whisper.View.extend({
className: 'conversation-stack',
lastConversation: null,
open(conversation) {
open(conversation, messageId) {
const id = `conversation-${conversation.cid}`;
if (id !== this.el.firstChild.id) {
this.$el
.first()
.find('video, audio')
.each(function pauseMedia() {
this.pause();
});
let $el = this.$(`#${id}`);
if ($el === null || $el.length === 0) {
const view = new Whisper.ConversationView({
model: conversation,
window: this.model.window,
});
// eslint-disable-next-line prefer-destructuring
$el = view.$el;
if (id !== this.el.lastChild.id) {
const view = new Whisper.ConversationView({
model: conversation,
window: this.model.window,
});
view.$el.appendTo(this.el);
if (this.lastConversation) {
this.lastConversation.trigger(
'unload',
'opened another conversation'
);
}
$el.prependTo(this.el);
this.lastConversation = conversation;
conversation.trigger('opened', messageId);
} else if (messageId) {
conversation.trigger('scroll-to-message', messageId);
}
conversation.trigger('opened');
if (this.lastConversation) {
this.lastConversation.trigger('backgrounded');
}
this.lastConversation = conversation;
// Make sure poppers are positioned properly
window.dispatchEvent(new Event('resize'));
},
@ -122,11 +119,10 @@
},
setupLeftPane() {
this.leftPaneView = new Whisper.ReactWrapperView({
JSX: Signal.State.Roots.createLeftPane(window.reduxStore),
className: 'left-pane-wrapper',
JSX: Signal.State.Roots.createLeftPane(window.reduxStore),
});
// Finally, add it to the DOM
this.$('.left-pane-placeholder').append(this.leftPaneView.el);
},
startConnectionListener() {
@ -194,7 +190,7 @@
openConversationExternal(id, messageId);
}
this.conversation_stack.open(conversation);
this.conversation_stack.open(conversation, messageId);
this.focusConversation();
},
closeRecording(e) {