mattermost-mobile/patches/react-native-reanimated+2.5.0.patch
Daniel Espino García d1322e84ce
[Gekidou] Add performance and code improvements around post_list (#6113)
* Add performance and code improvements around post_list

* Fix test

* Move observers from utils to queries

* remove Flipper on iOS to fix CI build

* Fix observePermissionForChannel for DM/GM

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2022-04-04 08:14:55 -04:00

141 lines
6.1 KiB
Diff

diff --git a/node_modules/react-native-reanimated/lib/reanimated2/jestUtils.js b/node_modules/react-native-reanimated/lib/reanimated2/jestUtils.js
index 5ae42ec..aae478e 100644
--- a/node_modules/react-native-reanimated/lib/reanimated2/jestUtils.js
+++ b/node_modules/react-native-reanimated/lib/reanimated2/jestUtils.js
@@ -154,6 +154,9 @@ export const setUpTests = (userConfig = {}) => {
return compareStyle(received, expectedStyle, config);
},
});
+ global.ReanimatedDataMock = {
+ now: () => currentTimestamp,
+ };
};
export const getAnimatedStyle = (received) => {
return getCurrentStyle(received);
diff --git a/node_modules/react-native-reanimated/react-native-reanimated.d.ts b/node_modules/react-native-reanimated/react-native-reanimated.d.ts
index a3aafb2..141f0cd 100644
--- a/node_modules/react-native-reanimated/react-native-reanimated.d.ts
+++ b/node_modules/react-native-reanimated/react-native-reanimated.d.ts
@@ -7,8 +7,6 @@ declare module 'react-native-reanimated' {
ReactNode,
Component,
RefObject,
- ComponentType,
- ComponentProps,
FunctionComponent,
} from 'react';
import {
@@ -31,7 +29,6 @@ declare module 'react-native-reanimated' {
NativeScrollEvent,
NativeSyntheticEvent,
ColorValue,
- OpaqueColorValue,
EasingFunction,
} from 'react-native';
import {
@@ -39,24 +36,24 @@ declare module 'react-native-reanimated' {
PanGestureHandlerGestureEvent,
} from 'react-native-gesture-handler';
- import('./src/reanimated2/globals');
+ import('./lib/reanimated2/globals');
export type TimingAnimation =
- import('./src/reanimated2/animation/index').TimingAnimation;
+ import('./lib/reanimated2/animation/index').TimingAnimation;
export type SpringAnimation =
- import('./src/reanimated2/animation/index').SpringAnimation;
+ import('./lib/reanimated2/animation/index').SpringAnimation;
export type DecayAnimation =
- import('./src/reanimated2/animation/index').DecayAnimation;
+ import('./lib/reanimated2/animation/index').DecayAnimation;
export type DelayAnimation =
- import('./src/reanimated2/animation/commonTypes').DelayAnimation;
+ import('./lib/reanimated2/animation/commonTypes').DelayAnimation;
export type RepeatAnimation =
- import('./src/reanimated2/animation/index').RepeatAnimation;
+ import('./lib/reanimated2/animation/index').RepeatAnimation;
export type SequenceAnimation =
- import('./src/reanimated2/animation/index').SequenceAnimation;
+ import('./lib/reanimated2/animation/index').SequenceAnimation;
export type StyleLayoutAnimation =
- import('./src/reanimated2/animation/index').StyleLayoutAnimation;
+ import('./lib/reanimated2/animation/index').StyleLayoutAnimation;
export type Animation<T> =
- import('./src/reanimated2/commonTypes').Animation<T>;
+ import('./lib/reanimated2/commonTypes').Animation<T>;
namespace Animated {
type Nullable<T> = T | null | undefined;
diff --git a/node_modules/react-native-reanimated/src/createAnimatedComponent.tsx b/node_modules/react-native-reanimated/src/createAnimatedComponent.tsx
index 6bead55..7ae12ba 100644
--- a/node_modules/react-native-reanimated/src/createAnimatedComponent.tsx
+++ b/node_modules/react-native-reanimated/src/createAnimatedComponent.tsx
@@ -161,7 +161,7 @@ interface ComponentRef extends Component {
getScrollableNode?: () => ComponentRef;
}
-interface InitialComponentProps extends Record<string, unknown> {
+export interface InitialComponentProps extends Record<string, unknown> {
ref?: Ref<Component>;
collapsable?: boolean;
}
@@ -195,6 +195,7 @@ export default function createAnimatedComponent(
_isFirstRender = true;
animatedStyle: { value: StyleProps } = { value: {} };
initialStyle = {};
+ _lastSentStyle?: StyleProps;
sv: SharedValue<null | Record<string, unknown>> | null;
_propsAnimated?: PropsAnimated;
_component: ComponentRef | null = null;
@@ -580,17 +581,24 @@ export default function createAnimatedComponent(
_filterNonAnimatedStyle(inputStyle: StyleProps) {
const style: StyleProps = {};
+ let changed = false;
for (const key in inputStyle) {
const value = inputStyle[key];
if (!hasAnimatedNodes(value)) {
style[key] = value;
+ changed = changed || style[key] !== this._lastSentStyle?.[key];
} else if (value instanceof AnimatedValue) {
// if any style in animated component is set directly to the `Value` we set those styles to the first value of `Value` node in order
// to avoid flash of default styles when `Value` is being asynchrounously sent via bridge and initialized in the native side.
style[key] = value._startingValue;
+ changed = changed || style[key] !== this._lastSentStyle?.[key]
}
}
- return style;
+ if (changed) {
+ return style;
+ } else {
+ return this._lastSentStyle;
+ }
}
_filterNonAnimatedProps(
@@ -617,9 +625,11 @@ export default function createAnimatedComponent(
return style;
}
});
+
props[key] = this._filterNonAnimatedStyle(
StyleSheet.flatten(processedStyle)
);
+ this._lastSentStyle = props[key]
} else if (key === 'animatedProps') {
const animatedProp = inputProps.animatedProps as Partial<
AnimatedComponentProps<AnimatedProps>
diff --git a/node_modules/react-native-reanimated/src/reanimated2/component/FlatList.tsx b/node_modules/react-native-reanimated/src/reanimated2/component/FlatList.tsx
index f02fc16..32bf952 100644
--- a/node_modules/react-native-reanimated/src/reanimated2/component/FlatList.tsx
+++ b/node_modules/react-native-reanimated/src/reanimated2/component/FlatList.tsx
@@ -23,7 +23,7 @@ const createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {
return cellRenderer;
};
-interface ReanimatedFlatlistProps<ItemT> extends FlatListProps<ItemT> {
+export interface ReanimatedFlatlistProps<ItemT> extends FlatListProps<ItemT> {
itemLayoutAnimation?: ILayoutAnimationBuilder;
}