Remove React Virtualized from <Timeline>

This commit is contained in:
Evan Hahn 2022-03-03 14:23:10 -06:00 committed by GitHub
parent 1eafe79905
commit 0c31ad25ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 798 additions and 2512 deletions

View file

@ -1,56 +0,0 @@
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { scrollToBottom } from '../util/scrollToBottom';
describe('scrollToBottom', () => {
let sandbox: HTMLDivElement;
// This test seems to be flaky on Windows CI, sometimes timing out. That doesn't really
// make sense because the test is synchronous, but this quick-and-dirty fix is
// probably better than a full investigation.
before(function thisNeeded() {
if (process.platform === 'win32') {
this.skip();
}
});
beforeEach(() => {
sandbox = document.createElement('div');
document.body.appendChild(sandbox);
});
afterEach(() => {
sandbox.remove();
});
it("sets the element's scrollTop to the element's scrollHeight", () => {
const el = document.createElement('div');
el.innerText = 'a'.repeat(50000);
Object.assign(el.style, {
height: '50px',
overflow: 'scroll',
whiteSpace: 'wrap',
width: '100px',
wordBreak: 'break-word',
});
sandbox.appendChild(el);
assert.strictEqual(
el.scrollTop,
0,
'Test is not set up correctly. Element is already scrolled'
);
assert.isAtLeast(
el.scrollHeight,
50,
'Test is not set up correctly. scrollHeight is too low'
);
scrollToBottom(el);
assert.isAtLeast(el.scrollTop, el.scrollHeight - 50);
});
});

View file

@ -0,0 +1,86 @@
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import {
getScrollBottom,
scrollToBottom,
setScrollBottom,
} from '../util/scrollUtil';
describe('scroll utilities', () => {
let sandbox: HTMLDivElement;
let el: HTMLDivElement;
// These tests to be flaky on Windows CI, sometimes timing out. That doesn't really
// make sense because the test is synchronous, but this quick-and-dirty fix is
// probably better than a full investigation.
before(function thisNeeded() {
if (process.platform === 'win32') {
this.skip();
}
});
beforeEach(() => {
sandbox = document.createElement('div');
document.body.appendChild(sandbox);
el = document.createElement('div');
el.innerText = 'a'.repeat(50000);
Object.assign(el.style, {
height: '50px',
overflow: 'scroll',
whiteSpace: 'wrap',
width: '100px',
wordBreak: 'break-word',
});
sandbox.appendChild(el);
assert.strictEqual(
el.scrollTop,
0,
'Test is not set up correctly. Element is already scrolled'
);
assert.isAtLeast(
el.scrollHeight,
50,
'Test is not set up correctly. scrollHeight is too low'
);
});
afterEach(() => {
sandbox.remove();
});
describe('getScrollBottom', () => {
it('gets the distance from the bottom', () => {
assert.strictEqual(
getScrollBottom(el),
el.scrollHeight - el.clientHeight
);
el.scrollTop = 999999;
assert.strictEqual(getScrollBottom(el), 0);
});
});
describe('setScrollBottom', () => {
it('sets the distance from the bottom', () => {
setScrollBottom(el, 12);
assert.strictEqual(getScrollBottom(el), 12);
setScrollBottom(el, 9999999);
assert.strictEqual(el.scrollTop, 0);
});
});
describe('scrollToBottom', () => {
it("sets the element's scrollTop to the element's scrollHeight", () => {
scrollToBottom(el);
assert.isAtLeast(el.scrollTop, el.scrollHeight - 50);
});
});
});

View file

@ -5,7 +5,6 @@ import { assert } from 'chai';
import * as sinon from 'sinon';
import { v4 as uuid } from 'uuid';
import { times } from 'lodash';
import { set } from 'lodash/fp';
import { reducer as rootReducer } from '../../../state/reducer';
import { noopAction } from '../../../state/ducks/noop';
import {
@ -55,9 +54,8 @@ const {
closeContactSpoofingReview,
closeMaximumGroupSizeModal,
closeRecommendedGroupSizeModal,
createGroup,
messageSizeChanged,
conversationStoppedByMissingVerification,
createGroup,
openConversationInternal,
repairNewestMessage,
repairOldestMessage,
@ -334,13 +332,11 @@ describe('both/state/ducks/conversations', () => {
function getDefaultConversationMessage(): ConversationMessageType {
return {
heightChangeMessageIds: [],
isLoadingMessages: false,
messageIds: [],
metrics: {
totalUnread: 0,
},
resetCounter: 0,
scrollToMessageCounter: 0,
};
}
@ -832,76 +828,6 @@ describe('both/state/ducks/conversations', () => {
});
});
describe('MESSAGE_SIZE_CHANGED', () => {
const stateWithActiveConversation = {
...getEmptyState(),
messagesByConversation: {
[conversationId]: {
heightChangeMessageIds: [],
isLoadingMessages: false,
isNearBottom: true,
messageIds: [messageId],
metrics: { totalUnread: 0 },
resetCounter: 0,
scrollToMessageCounter: 0,
},
},
messagesLookup: {
[messageId]: getDefaultMessage(messageId),
},
};
it('does nothing if no conversation is active', () => {
const state = getEmptyState();
assert.strictEqual(
reducer(state, messageSizeChanged('messageId', 'convoId')),
state
);
});
it('does nothing if a different conversation is active', () => {
assert.deepEqual(
reducer(
stateWithActiveConversation,
messageSizeChanged(messageId, 'another-conversation-guid')
),
stateWithActiveConversation
);
});
it('adds the message ID to the list of messages with changed heights', () => {
const result = reducer(
stateWithActiveConversation,
messageSizeChanged(messageId, conversationId)
);
assert.sameMembers(
result.messagesByConversation[conversationId]
?.heightChangeMessageIds || [],
[messageId]
);
});
it("doesn't add duplicates to the list of changed-heights messages", () => {
const state = set(
['messagesByConversation', conversationId, 'heightChangeMessageIds'],
[messageId],
stateWithActiveConversation
);
const result = reducer(
state,
messageSizeChanged(messageId, conversationId)
);
assert.sameMembers(
result.messagesByConversation[conversationId]
?.heightChangeMessageIds || [],
[messageId]
);
});
});
describe('CONVERSATION_STOPPED_BY_MISSING_VERIFICATION', () => {
it('adds to state, removing duplicates', () => {
const first = reducer(