removed the avatarETagUser and search by username and text
This commit is contained in:
parent
34993dace2
commit
7e1dec41e9
|
@ -14,7 +14,6 @@ import { useTheme } from '../../theme';
|
|||
import styles from './styles';
|
||||
|
||||
interface IAvatarContainer extends IAvatar {
|
||||
isUserProfile?: boolean;
|
||||
handleEdit?: () => void;
|
||||
}
|
||||
|
||||
|
@ -31,23 +30,21 @@ const AvatarContainer = ({
|
|||
getCustomEmoji,
|
||||
isStatic,
|
||||
rid,
|
||||
handleEdit,
|
||||
isUserProfile
|
||||
handleEdit
|
||||
}: IAvatarContainer): React.ReactElement => {
|
||||
const subscription = useRef<Subscription>();
|
||||
const [avatarETag, setAvatarETag] = useState<string | undefined>('');
|
||||
const previousAvatarEtag = useRef<string | undefined>('');
|
||||
const { colors } = useTheme();
|
||||
|
||||
const isDirect = () => type === 'd';
|
||||
|
||||
const server = useSelector((state: IApplicationState) => state.share.server.server || state.server.server);
|
||||
const serverVersion = useSelector((state: IApplicationState) => state.share.server.version || state.server.version);
|
||||
const { id, token, avatarETagUser } = useSelector(
|
||||
const { id, token, username } = useSelector(
|
||||
(state: IApplicationState) => ({
|
||||
id: getUserSelector(state).id,
|
||||
token: getUserSelector(state).token,
|
||||
avatarETagUser: getUserSelector(state).avatarETag
|
||||
username: getUserSelector(state).username
|
||||
}),
|
||||
shallowEqual
|
||||
);
|
||||
|
@ -62,14 +59,21 @@ const AvatarContainer = ({
|
|||
true
|
||||
);
|
||||
|
||||
const unsubscribeQuery = () => {
|
||||
if (subscription?.current?.unsubscribe) {
|
||||
subscription.current.unsubscribe();
|
||||
}
|
||||
};
|
||||
|
||||
const init = async () => {
|
||||
unsubscribeQuery();
|
||||
const db = database.active;
|
||||
const usersCollection = db.get('users');
|
||||
const subsCollection = db.get('subscriptions');
|
||||
|
||||
let record;
|
||||
try {
|
||||
if (isDirect()) {
|
||||
if (isDirect() || username === text) {
|
||||
const [user] = await usersCollection.query(Q.where('username', text)).fetch();
|
||||
record = user;
|
||||
} else if (rid) {
|
||||
|
@ -88,19 +92,12 @@ const AvatarContainer = ({
|
|||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!avatarETag || avatarETag !== previousAvatarEtag.current) {
|
||||
if (!avatarETag) {
|
||||
init();
|
||||
}
|
||||
return () => {
|
||||
if (subscription?.current?.unsubscribe) {
|
||||
subscription.current.unsubscribe();
|
||||
}
|
||||
};
|
||||
}, [text, type, size, avatarETag, externalProviderUrl]);
|
||||
}, [text]); // testar se precisa do avatarETag
|
||||
|
||||
useEffect(() => {
|
||||
previousAvatarEtag.current = avatarETag;
|
||||
}, [avatarETag]);
|
||||
useEffect(() => () => unsubscribeQuery(), []);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -122,7 +119,7 @@ const AvatarContainer = ({
|
|||
rid={rid}
|
||||
blockUnauthenticatedAccess={blockUnauthenticatedAccess}
|
||||
externalProviderUrl={externalProviderUrl}
|
||||
avatarETag={isUserProfile ? avatarETagUser : avatarETag}
|
||||
avatarETag={avatarETag}
|
||||
serverVersion={serverVersion}
|
||||
/>
|
||||
{handleEdit ? (
|
||||
|
|
|
@ -18,19 +18,11 @@ const IconOrAvatar = ({
|
|||
teamMain,
|
||||
showLastMessage,
|
||||
displayMode,
|
||||
sourceType,
|
||||
isUserProfile
|
||||
sourceType
|
||||
}: IIconOrAvatar): React.ReactElement | null => {
|
||||
if (showAvatar) {
|
||||
return (
|
||||
<Avatar
|
||||
isUserProfile={isUserProfile}
|
||||
text={avatar}
|
||||
size={displayMode === DisplayMode.Condensed ? 36 : 48}
|
||||
type={type}
|
||||
style={styles.avatar}
|
||||
rid={rid}
|
||||
/>
|
||||
<Avatar text={avatar} size={displayMode === DisplayMode.Condensed ? 36 : 48} type={type} style={styles.avatar} rid={rid} />
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,8 +52,7 @@ const RoomItem = ({
|
|||
showAvatar,
|
||||
displayMode,
|
||||
sourceType,
|
||||
hideMentionStatus,
|
||||
isUserProfile
|
||||
hideMentionStatus
|
||||
}: IRoomItemProps) => (
|
||||
<Touchable
|
||||
onPress={onPress}
|
||||
|
@ -84,7 +83,6 @@ const RoomItem = ({
|
|||
showAvatar={showAvatar}
|
||||
showLastMessage={!!showLastMessage}
|
||||
sourceType={sourceType}
|
||||
isUserProfile={isUserProfile}
|
||||
>
|
||||
{showLastMessage && displayMode === DisplayMode.Expanded ? (
|
||||
<>
|
||||
|
|
|
@ -34,8 +34,7 @@ const RoomItemContainer = React.memo(
|
|||
getRoomTitle = () => 'title',
|
||||
getRoomAvatar = () => '',
|
||||
getIsRead = () => false,
|
||||
swipeEnabled = true,
|
||||
isUserProfile
|
||||
swipeEnabled = true
|
||||
}: IRoomItemContainerProps) => {
|
||||
const name = getRoomTitle(item);
|
||||
const testID = `rooms-list-view-item-${name}`;
|
||||
|
@ -128,7 +127,6 @@ const RoomItemContainer = React.memo(
|
|||
showAvatar={showAvatar}
|
||||
displayMode={displayMode}
|
||||
sourceType={item.source}
|
||||
isUserProfile={isUserProfile}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
|
|
@ -47,7 +47,6 @@ export interface IWrapperProps {
|
|||
teamMain: boolean;
|
||||
showAvatar: boolean;
|
||||
sourceType: IOmnichannelSource;
|
||||
isUserProfile: boolean;
|
||||
}
|
||||
|
||||
export interface ITypeIconProps {
|
||||
|
@ -117,7 +116,6 @@ export interface IRoomItemProps extends IBaseRoomItem {
|
|||
size?: number;
|
||||
sourceType: IOmnichannelSource;
|
||||
hideMentionStatus?: boolean;
|
||||
isUserProfile: boolean;
|
||||
}
|
||||
|
||||
export interface ILastMessageProps {
|
||||
|
@ -154,5 +152,4 @@ export interface IIconOrAvatar {
|
|||
teamMain: boolean;
|
||||
showLastMessage: boolean;
|
||||
sourceType: IOmnichannelSource;
|
||||
isUserProfile: boolean;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import React from 'react';
|
||||
import { Pressable, StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native';
|
||||
|
||||
import { useAppSelector } from '../lib/hooks';
|
||||
import { getUserSelector } from '../selectors/login';
|
||||
import Avatar from './Avatar';
|
||||
import { CustomIcon, TIconsName } from './CustomIcon';
|
||||
import sharedStyles from '../views/Styles';
|
||||
|
@ -45,12 +43,10 @@ interface IUserItem {
|
|||
style?: StyleProp<ViewStyle>;
|
||||
icon?: TIconsName | null;
|
||||
iconColor?: string;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
const UserItem = ({ name, username, onPress, testID, onLongPress, style, icon, iconColor, id }: IUserItem) => {
|
||||
const UserItem = ({ name, username, onPress, testID, onLongPress, style, icon, iconColor }: IUserItem) => {
|
||||
const { colors } = useTheme();
|
||||
const { userId } = useAppSelector(state => ({ userId: getUserSelector(state).id }));
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
|
@ -65,7 +61,7 @@ const UserItem = ({ name, username, onPress, testID, onLongPress, style, icon, i
|
|||
})}
|
||||
>
|
||||
<View style={[styles.container, styles.button, style]}>
|
||||
<Avatar text={username} size={30} style={styles.avatar} isUserProfile={userId === id} />
|
||||
<Avatar text={username} size={30} style={styles.avatar} />
|
||||
<View style={styles.textContainer}>
|
||||
<Text style={[styles.name, { color: colors.bodyText }]} numberOfLines={1}>
|
||||
{name}
|
||||
|
|
|
@ -20,7 +20,6 @@ const MessageAvatar = React.memo(({ isHeader, avatar, author, small, navToRoomIn
|
|||
size={small ? 20 : 36}
|
||||
borderRadius={small ? 2 : 4}
|
||||
onPress={author._id === user.id ? undefined : () => navToRoomInfo(navParam)}
|
||||
isUserProfile={author._id === user.id}
|
||||
getCustomEmoji={getCustomEmoji}
|
||||
avatar={avatar}
|
||||
emoji={emoji}
|
||||
|
|
|
@ -288,7 +288,7 @@ export default function subscribeRooms() {
|
|||
const [type, data] = ddpMessage.fields.args;
|
||||
const [, ev] = ddpMessage.fields.eventName.split('/');
|
||||
if (/userData/.test(ev)) {
|
||||
const [{ diff, unset }] = ddpMessage.fields.args;
|
||||
const [{ diff }] = ddpMessage.fields.args;
|
||||
if (diff?.statusLivechat) {
|
||||
store.dispatch(setUser({ statusLivechat: diff.statusLivechat }));
|
||||
}
|
||||
|
@ -298,12 +298,6 @@ export default function subscribeRooms() {
|
|||
if ((['settings.preferences.alsoSendThreadToChannel'] as any) in diff) {
|
||||
store.dispatch(setUser({ alsoSendThreadToChannel: diff['settings.preferences.alsoSendThreadToChannel'] }));
|
||||
}
|
||||
if (diff?.avatarETag) {
|
||||
store.dispatch(setUser({ avatarETag: diff.avatarETag }));
|
||||
}
|
||||
if (unset?.avatarETag) {
|
||||
store.dispatch(setUser({ avatarETag: '' }));
|
||||
}
|
||||
}
|
||||
if (/subscriptions/.test(ev)) {
|
||||
if (type === 'removed') {
|
||||
|
|
|
@ -152,7 +152,6 @@ const ChangeAvatarView = () => {
|
|||
avatar={avatar?.url}
|
||||
isStatic={avatar?.url}
|
||||
size={100}
|
||||
isUserProfile={fromUser}
|
||||
type={t}
|
||||
{...ridProps}
|
||||
/>
|
||||
|
|
|
@ -416,7 +416,6 @@ class ProfileView extends React.Component<IProfileViewProps, IProfileViewState>
|
|||
avatarETag={user.avatarETag}
|
||||
size={100}
|
||||
handleEdit={Accounts_AllowUserAvatarChange ? this.handleEditAvatar : undefined}
|
||||
isUserProfile
|
||||
/>
|
||||
</View>
|
||||
<FormTextInput
|
||||
|
|
|
@ -935,7 +935,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
|||
|
||||
const { item: currentItem } = this.state;
|
||||
const {
|
||||
user: { username, id: userId },
|
||||
user: { username },
|
||||
StoreLastMessage,
|
||||
useRealName,
|
||||
isMasterDetail,
|
||||
|
@ -945,7 +945,6 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
|||
} = this.props;
|
||||
const id = getUidDirectMessage(item);
|
||||
const swipeEnabled = this.isSwipeEnabled(item);
|
||||
const isUserProfile = id === userId;
|
||||
|
||||
return (
|
||||
<RoomItem
|
||||
|
@ -966,7 +965,6 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
|||
swipeEnabled={swipeEnabled}
|
||||
showAvatar={showAvatar}
|
||||
displayMode={displayMode}
|
||||
isUserProfile={isUserProfile}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -251,7 +251,7 @@ class Sidebar extends Component<ISidebarProps, ISidebarState> {
|
|||
>
|
||||
<TouchableWithoutFeedback onPress={this.onPressUser} testID='sidebar-close-drawer'>
|
||||
<View style={styles.header}>
|
||||
<Avatar text={user.username} style={styles.avatar} size={30} isUserProfile />
|
||||
<Avatar text={user.username} style={styles.avatar} size={30} />
|
||||
<View style={styles.headerTextContainer}>
|
||||
<View style={styles.headerUsername}>
|
||||
<Text numberOfLines={1} style={[styles.username, { color: themes[theme!].titleText }]}>
|
||||
|
|
Loading…
Reference in New Issue