Upgrade Reselect to 4.1.2

Co-authored-by: Fedor Indutnyy <indutny@signal.org>
This commit is contained in:
Evan Hahn 2021-11-12 16:37:44 -06:00 committed by GitHub
parent 066a23a6a9
commit 4490d9f2d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 35 deletions

View File

@ -152,7 +152,7 @@
"redux-promise-middleware": "6.1.0",
"redux-thunk": "2.3.0",
"redux-ts-utils": "3.2.2",
"reselect": "4.0.0",
"reselect": "4.1.2",
"rimraf": "2.6.2",
"ringrtc": "https://github.com/signalapp/signal-ringrtc-node.git#011bdd9a71982a7bbf333bf3641dbd722c8c7bf1",
"rotating-file-stream": "2.1.5",

View File

@ -1,7 +1,7 @@
// Copyright 2019-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { debounce, get, isNumber, pick, identity } from 'lodash';
import { debounce, get, isNumber, pick } from 'lodash';
import classNames from 'classnames';
import type { CSSProperties, ReactChild, ReactNode, RefObject } from 'react';
import React from 'react';
@ -226,7 +226,7 @@ type StateType = {
const getActions = createSelector(
// It is expensive to pick so many properties out of the `props` object so we
// use `createSelector` to memoize them by the last seen `props` object.
identity,
(props: PropsType) => props,
(props: PropsType): PropsActionsType => {
const unsafe = pick(props, [

View File

@ -241,11 +241,7 @@ export const getAttachmentsForMessage = createSelectorCreator(memoizeByRoot)(
({ sticker }: MessageWithUIFieldsType) => sticker,
({ attachments }: MessageWithUIFieldsType) => attachments,
(
_: MessageWithUIFieldsType,
sticker: MessageWithUIFieldsType['sticker'],
attachments: MessageWithUIFieldsType['attachments'] = []
): Array<AttachmentType> => {
(_, sticker, attachments = []): Array<AttachmentType> => {
if (sticker && sticker.data) {
const { data } = sticker;
@ -298,7 +294,7 @@ export const processBodyRanges = createSelectorCreator(memoizeByRoot, isEqual)(
})
.sort((a, b) => b.start - a.start);
},
(_: MessageWithUIFieldsType, ranges?: BodyRangesType) => ranges
(_, ranges): undefined | BodyRangesType => ranges
);
const getAuthorForMessage = createSelectorCreator(memoizeByRoot)(
@ -307,10 +303,7 @@ const getAuthorForMessage = createSelectorCreator(memoizeByRoot)(
getContact,
(
_: MessageWithUIFieldsType,
convo: ConversationType
): PropsData['author'] => {
(_, convo: ConversationType): PropsData['author'] => {
const {
acceptedMessageRequest,
avatarPath,
@ -348,25 +341,15 @@ const getAuthorForMessage = createSelectorCreator(memoizeByRoot)(
const getCachedAuthorForMessage = createSelectorCreator(memoizeByRoot, isEqual)(
// `memoizeByRoot` requirement
identity,
getAuthorForMessage,
(
_: MessageWithUIFieldsType,
author: PropsData['author']
): PropsData['author'] => author
(_, author): PropsData['author'] => author
);
export const getPreviewsForMessage = createSelectorCreator(memoizeByRoot)(
// `memoizeByRoot` requirement
identity,
({ preview }: MessageWithUIFieldsType) => preview,
(
_: MessageWithUIFieldsType,
previews: MessageWithUIFieldsType['preview'] = []
): Array<LinkPreviewType> => {
(_, previews = []): Array<LinkPreviewType> => {
return previews.map(preview => ({
...preview,
isStickerPack: isStickerPack(preview.url),
@ -435,7 +418,7 @@ export const getReactionsForMessage = createSelectorCreator(
return [...formattedReactions];
},
(_: MessageWithUIFieldsType, reactions: PropsData['reactions']) => reactions
(_, reactions): PropsData['reactions'] => reactions
);
export const getPropsForQuote = createSelectorCreator(memoizeByRoot, isEqual)(
@ -504,7 +487,7 @@ export const getPropsForQuote = createSelectorCreator(memoizeByRoot, isEqual)(
};
},
(_: unknown, quote: PropsData['quote']) => quote
(_, quote): PropsData['quote'] => quote
);
export type GetPropsForMessageOptions = Pick<
@ -642,7 +625,12 @@ const getShallowPropsForMessage = createSelectorCreator(memoizeByRoot, isEqual)(
(_: unknown, props: ShallowPropsType) => props
);
export const getPropsForMessage = createSelectorCreator(memoizeByRoot)(
export const getPropsForMessage: (
message: MessageWithUIFieldsType,
options: GetPropsForMessageOptions
) => Omit<PropsForMessage, 'renderingContext'> = createSelectorCreator(
memoizeByRoot
)(
// `memoizeByRoot` requirement
identity,
@ -654,7 +642,7 @@ export const getPropsForMessage = createSelectorCreator(memoizeByRoot)(
getPropsForQuote,
getShallowPropsForMessage,
(
_: unknown,
_,
attachments: Array<AttachmentType>,
bodyRanges: BodyRangesType | undefined,
author: PropsData['author'],
@ -680,7 +668,8 @@ export const getBubblePropsForMessage = createSelectorCreator(memoizeByRoot)(
identity,
getPropsForMessage,
(_: unknown, data: ReturnType<typeof getPropsForMessage>) => ({
(_, data): TimelineItemType => ({
type: 'message' as const,
data,
})

View File

@ -20,7 +20,7 @@ import { strictAssert } from './assert';
// eslint-disable-next-line @typescript-eslint/ban-types
export function memoizeByRoot<F extends Function>(
fn: F,
equalityCheck?: <T>(a: T, b: T, index: number) => boolean
equalityCheck?: <T>(a: T, b: T) => boolean
): F {
// eslint-disable-next-line @typescript-eslint/ban-types
const cache = new WeakMap<object, Function>();

View File

@ -15803,10 +15803,10 @@ requizzle@^0.2.2:
dependencies:
lodash "^4.17.14"
reselect@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.0.0.tgz#f2529830e5d3d0e021408b246a206ef4ea4437f7"
integrity sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==
reselect@4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.1.2.tgz#7bf642992d143d4f3b0f2dca8aa52018808a1d51"
integrity sha512-wg60ebcPOtxcptIUfrr7Jt3h4BR86cCW3R7y4qt65lnNb4yz4QgrXcbSioVsIOYguyz42+XTHIyJ5TEruzkFgQ==
reserved-words@^0.1.2:
version "0.1.2"