Upgrade Reselect to 4.1.2
Co-authored-by: Fedor Indutnyy <indutny@signal.org>
This commit is contained in:
parent
066a23a6a9
commit
4490d9f2d0
5 changed files with 24 additions and 35 deletions
|
@ -152,7 +152,7 @@
|
||||||
"redux-promise-middleware": "6.1.0",
|
"redux-promise-middleware": "6.1.0",
|
||||||
"redux-thunk": "2.3.0",
|
"redux-thunk": "2.3.0",
|
||||||
"redux-ts-utils": "3.2.2",
|
"redux-ts-utils": "3.2.2",
|
||||||
"reselect": "4.0.0",
|
"reselect": "4.1.2",
|
||||||
"rimraf": "2.6.2",
|
"rimraf": "2.6.2",
|
||||||
"ringrtc": "https://github.com/signalapp/signal-ringrtc-node.git#011bdd9a71982a7bbf333bf3641dbd722c8c7bf1",
|
"ringrtc": "https://github.com/signalapp/signal-ringrtc-node.git#011bdd9a71982a7bbf333bf3641dbd722c8c7bf1",
|
||||||
"rotating-file-stream": "2.1.5",
|
"rotating-file-stream": "2.1.5",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2019-2021 Signal Messenger, LLC
|
// Copyright 2019-2021 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// 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 classNames from 'classnames';
|
||||||
import type { CSSProperties, ReactChild, ReactNode, RefObject } from 'react';
|
import type { CSSProperties, ReactChild, ReactNode, RefObject } from 'react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
@ -226,7 +226,7 @@ type StateType = {
|
||||||
const getActions = createSelector(
|
const getActions = createSelector(
|
||||||
// It is expensive to pick so many properties out of the `props` object so we
|
// 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.
|
// use `createSelector` to memoize them by the last seen `props` object.
|
||||||
identity,
|
(props: PropsType) => props,
|
||||||
|
|
||||||
(props: PropsType): PropsActionsType => {
|
(props: PropsType): PropsActionsType => {
|
||||||
const unsafe = pick(props, [
|
const unsafe = pick(props, [
|
||||||
|
|
|
@ -241,11 +241,7 @@ export const getAttachmentsForMessage = createSelectorCreator(memoizeByRoot)(
|
||||||
|
|
||||||
({ sticker }: MessageWithUIFieldsType) => sticker,
|
({ sticker }: MessageWithUIFieldsType) => sticker,
|
||||||
({ attachments }: MessageWithUIFieldsType) => attachments,
|
({ attachments }: MessageWithUIFieldsType) => attachments,
|
||||||
(
|
(_, sticker, attachments = []): Array<AttachmentType> => {
|
||||||
_: MessageWithUIFieldsType,
|
|
||||||
sticker: MessageWithUIFieldsType['sticker'],
|
|
||||||
attachments: MessageWithUIFieldsType['attachments'] = []
|
|
||||||
): Array<AttachmentType> => {
|
|
||||||
if (sticker && sticker.data) {
|
if (sticker && sticker.data) {
|
||||||
const { data } = sticker;
|
const { data } = sticker;
|
||||||
|
|
||||||
|
@ -298,7 +294,7 @@ export const processBodyRanges = createSelectorCreator(memoizeByRoot, isEqual)(
|
||||||
})
|
})
|
||||||
.sort((a, b) => b.start - a.start);
|
.sort((a, b) => b.start - a.start);
|
||||||
},
|
},
|
||||||
(_: MessageWithUIFieldsType, ranges?: BodyRangesType) => ranges
|
(_, ranges): undefined | BodyRangesType => ranges
|
||||||
);
|
);
|
||||||
|
|
||||||
const getAuthorForMessage = createSelectorCreator(memoizeByRoot)(
|
const getAuthorForMessage = createSelectorCreator(memoizeByRoot)(
|
||||||
|
@ -307,10 +303,7 @@ const getAuthorForMessage = createSelectorCreator(memoizeByRoot)(
|
||||||
|
|
||||||
getContact,
|
getContact,
|
||||||
|
|
||||||
(
|
(_, convo: ConversationType): PropsData['author'] => {
|
||||||
_: MessageWithUIFieldsType,
|
|
||||||
convo: ConversationType
|
|
||||||
): PropsData['author'] => {
|
|
||||||
const {
|
const {
|
||||||
acceptedMessageRequest,
|
acceptedMessageRequest,
|
||||||
avatarPath,
|
avatarPath,
|
||||||
|
@ -348,25 +341,15 @@ const getAuthorForMessage = createSelectorCreator(memoizeByRoot)(
|
||||||
const getCachedAuthorForMessage = createSelectorCreator(memoizeByRoot, isEqual)(
|
const getCachedAuthorForMessage = createSelectorCreator(memoizeByRoot, isEqual)(
|
||||||
// `memoizeByRoot` requirement
|
// `memoizeByRoot` requirement
|
||||||
identity,
|
identity,
|
||||||
|
|
||||||
getAuthorForMessage,
|
getAuthorForMessage,
|
||||||
|
(_, author): PropsData['author'] => author
|
||||||
(
|
|
||||||
_: MessageWithUIFieldsType,
|
|
||||||
author: PropsData['author']
|
|
||||||
): PropsData['author'] => author
|
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getPreviewsForMessage = createSelectorCreator(memoizeByRoot)(
|
export const getPreviewsForMessage = createSelectorCreator(memoizeByRoot)(
|
||||||
// `memoizeByRoot` requirement
|
// `memoizeByRoot` requirement
|
||||||
identity,
|
identity,
|
||||||
|
|
||||||
({ preview }: MessageWithUIFieldsType) => preview,
|
({ preview }: MessageWithUIFieldsType) => preview,
|
||||||
|
(_, previews = []): Array<LinkPreviewType> => {
|
||||||
(
|
|
||||||
_: MessageWithUIFieldsType,
|
|
||||||
previews: MessageWithUIFieldsType['preview'] = []
|
|
||||||
): Array<LinkPreviewType> => {
|
|
||||||
return previews.map(preview => ({
|
return previews.map(preview => ({
|
||||||
...preview,
|
...preview,
|
||||||
isStickerPack: isStickerPack(preview.url),
|
isStickerPack: isStickerPack(preview.url),
|
||||||
|
@ -435,7 +418,7 @@ export const getReactionsForMessage = createSelectorCreator(
|
||||||
return [...formattedReactions];
|
return [...formattedReactions];
|
||||||
},
|
},
|
||||||
|
|
||||||
(_: MessageWithUIFieldsType, reactions: PropsData['reactions']) => reactions
|
(_, reactions): PropsData['reactions'] => reactions
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getPropsForQuote = createSelectorCreator(memoizeByRoot, isEqual)(
|
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<
|
export type GetPropsForMessageOptions = Pick<
|
||||||
|
@ -642,7 +625,12 @@ const getShallowPropsForMessage = createSelectorCreator(memoizeByRoot, isEqual)(
|
||||||
(_: unknown, props: ShallowPropsType) => props
|
(_: unknown, props: ShallowPropsType) => props
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getPropsForMessage = createSelectorCreator(memoizeByRoot)(
|
export const getPropsForMessage: (
|
||||||
|
message: MessageWithUIFieldsType,
|
||||||
|
options: GetPropsForMessageOptions
|
||||||
|
) => Omit<PropsForMessage, 'renderingContext'> = createSelectorCreator(
|
||||||
|
memoizeByRoot
|
||||||
|
)(
|
||||||
// `memoizeByRoot` requirement
|
// `memoizeByRoot` requirement
|
||||||
identity,
|
identity,
|
||||||
|
|
||||||
|
@ -654,7 +642,7 @@ export const getPropsForMessage = createSelectorCreator(memoizeByRoot)(
|
||||||
getPropsForQuote,
|
getPropsForQuote,
|
||||||
getShallowPropsForMessage,
|
getShallowPropsForMessage,
|
||||||
(
|
(
|
||||||
_: unknown,
|
_,
|
||||||
attachments: Array<AttachmentType>,
|
attachments: Array<AttachmentType>,
|
||||||
bodyRanges: BodyRangesType | undefined,
|
bodyRanges: BodyRangesType | undefined,
|
||||||
author: PropsData['author'],
|
author: PropsData['author'],
|
||||||
|
@ -680,7 +668,8 @@ export const getBubblePropsForMessage = createSelectorCreator(memoizeByRoot)(
|
||||||
identity,
|
identity,
|
||||||
|
|
||||||
getPropsForMessage,
|
getPropsForMessage,
|
||||||
(_: unknown, data: ReturnType<typeof getPropsForMessage>) => ({
|
|
||||||
|
(_, data): TimelineItemType => ({
|
||||||
type: 'message' as const,
|
type: 'message' as const,
|
||||||
data,
|
data,
|
||||||
})
|
})
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { strictAssert } from './assert';
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export function memoizeByRoot<F extends Function>(
|
export function memoizeByRoot<F extends Function>(
|
||||||
fn: F,
|
fn: F,
|
||||||
equalityCheck?: <T>(a: T, b: T, index: number) => boolean
|
equalityCheck?: <T>(a: T, b: T) => boolean
|
||||||
): F {
|
): F {
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
const cache = new WeakMap<object, Function>();
|
const cache = new WeakMap<object, Function>();
|
||||||
|
|
|
@ -15803,10 +15803,10 @@ requizzle@^0.2.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
lodash "^4.17.14"
|
lodash "^4.17.14"
|
||||||
|
|
||||||
reselect@4.0.0:
|
reselect@4.1.2:
|
||||||
version "4.0.0"
|
version "4.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.0.0.tgz#f2529830e5d3d0e021408b246a206ef4ea4437f7"
|
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.1.2.tgz#7bf642992d143d4f3b0f2dca8aa52018808a1d51"
|
||||||
integrity sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==
|
integrity sha512-wg60ebcPOtxcptIUfrr7Jt3h4BR86cCW3R7y4qt65lnNb4yz4QgrXcbSioVsIOYguyz42+XTHIyJ5TEruzkFgQ==
|
||||||
|
|
||||||
reserved-words@^0.1.2:
|
reserved-words@^0.1.2:
|
||||||
version "0.1.2"
|
version "0.1.2"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue