Remove memo from RoomItem

This commit is contained in:
Diego Mello 2022-11-28 17:15:13 -03:00
parent 8ab84541f3
commit 71dc0b8f50
1 changed files with 93 additions and 116 deletions

View File

@ -1,5 +1,4 @@
import React, { useEffect } from 'react';
// import { Subscription } from 'rxjs';
import I18n from '../../i18n';
import { useAppSelector } from '../../lib/hooks';
@ -12,10 +11,7 @@ import { ROW_HEIGHT, ROW_HEIGHT_CONDENSED } from './styles';
export { ROW_HEIGHT, ROW_HEIGHT_CONDENSED };
// const attrs = ['width', 'isFocused', 'showLastMessage', 'autoJoin', 'showAvatar', 'displayMode'];
const RoomItemContainer = React.memo(
({
const RoomItemContainer = ({
item,
id,
onPress,
@ -35,7 +31,7 @@ const RoomItemContainer = React.memo(
getRoomAvatar = () => '',
getIsRead = () => false,
swipeEnabled = true
}: IRoomItemContainerProps) => {
}: IRoomItemContainerProps): React.ReactElement => {
const name = getRoomTitle(item);
const testID = `rooms-list-view-item-${name}`;
const avatar = getRoomAvatar(item);
@ -44,22 +40,6 @@ const RoomItemContainer = React.memo(
const alert = item.alert || item.tunread?.length;
const connected = useAppSelector(state => state.meteor.connected);
const userStatus = useAppSelector(state => state.activeUsers[id || '']?.status);
// const [_, forceUpdate] = useReducer(x => x + 1, 1);
// const roomSubscription = useRef<Subscription | null>(null);
// useEffect(() => {
// const init = () => {
// if (item?.observe) {
// const observable = item.observe();
// roomSubscription.current = observable?.subscribe?.(() => {
// if (_) forceUpdate();
// });
// }
// };
// init();
// return () => roomSubscription.current?.unsubscribe();
// }, []);
useEffect(() => {
const isDirect = !!(item.t === 'd' && id && !isGroupChat(item));
@ -129,8 +109,5 @@ const RoomItemContainer = React.memo(
sourceType={item.source}
/>
);
}
// (props, nextProps) => attrs.every(key => props[key] === nextProps[key])
);
};
export default RoomItemContainer;