Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8d8a1d7
[WIP] Avatar cache invalidation
djorkaeffalexandre Jul 17, 2020
c10d857
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
djorkaeffalexandre Jul 20, 2020
ba0e3dd
[WIP] Avatar container
djorkaeffalexandre Jul 20, 2020
78f8198
[IMPROVEMENT] Avatar container
djorkaeffalexandre Jul 20, 2020
a053698
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
djorkaeffalexandre Jul 20, 2020
b64eb53
[CHORE] Improve code
djorkaeffalexandre Jul 20, 2020
ec82478
Merge develop
djorkaeffalexandre Jul 30, 2020
be8f178
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
djorkaeffalexandre Jul 31, 2020
7191240
Allow static image on Avatar
djorkaeffalexandre Jul 31, 2020
ff73068
Fix avatar changing while change username (#1583)
djorkaeffalexandre Jul 31, 2020
b8041fa
Add default props to properly update on Sidebar and ProfileView
djorkaeffalexandre Jul 31, 2020
b1c46e6
Fix subscribing on the wrong moment
djorkaeffalexandre Jul 31, 2020
9eaf2ae
Storyshots update
djorkaeffalexandre Jul 31, 2020
87eb1eb
Merge develop
djorkaeffalexandre Jul 31, 2020
9ce6eb1
RoomItem using Avatar Component
djorkaeffalexandre Jul 31, 2020
1649d3a
Merge develop
djorkaeffalexandre Jul 31, 2020
0bf5551
use iife to unsubscribe from user
djorkaeffalexandre Jul 31, 2020
441ad88
Use component on avatar container
djorkaeffalexandre Aug 4, 2020
0ae1114
RoomItem as a React.Component
djorkaeffalexandre Aug 4, 2020
c1ecd07
Move servers models to servers folder
djorkaeffalexandre Aug 4, 2020
6a81401
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
djorkaeffalexandre Aug 4, 2020
7caa0e0
Avatar -> AvatarContainer
djorkaeffalexandre Aug 5, 2020
739836e
Users indexed fields
djorkaeffalexandre Aug 5, 2020
c6ffbf7
Initialize author and check if u is present
djorkaeffalexandre Aug 5, 2020
df75c65
Not was found -> User not found (turn comments more relevant)
djorkaeffalexandre Aug 5, 2020
c0c61ea
RoomItemInner -> Wrapper
djorkaeffalexandre Aug 5, 2020
78b7767
Revert Avatar Touchable logic
djorkaeffalexandre Aug 5, 2020
19b12fd
Revert responsability of LeftButton on Tablet Mode
djorkaeffalexandre Aug 5, 2020
615c5c7
Prevent setState on constructor
djorkaeffalexandre Aug 5, 2020
95e49c8
Run avatarURL only when its not static
djorkaeffalexandre Aug 5, 2020
e39c08e
Add streams RC Version
djorkaeffalexandre Aug 5, 2020
ddb41ea
Move entire add user logic to result.success
djorkaeffalexandre Aug 5, 2020
94d7f09
Reorder init on RoomItem
djorkaeffalexandre Aug 5, 2020
92eac28
onPress as a class function
djorkaeffalexandre Aug 5, 2020
f63738b
Fix roomItem using same username
djorkaeffalexandre Aug 5, 2020
ef0a261
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
djorkaeffalexandre Aug 5, 2020
b4401d3
Merge branch 'develop' into fix.avatar-cache-invalidation
diegolmello Aug 5, 2020
f602fb4
Add avatar Stories
djorkaeffalexandre Aug 5, 2020
e34c49b
Merge branch 'fix.avatar-cache-invalidation' of https://github.com/Ro…
djorkaeffalexandre Aug 5, 2020
f72d272
Fix pick an image from gallery on ProfileView
djorkaeffalexandre Aug 5, 2020
8f88836
merge develop
djorkaeffalexandre Sep 25, 2020
2142fe7
Merge branch 'develop' into fix.avatar-cache-invalidation
djorkaeffalexandre Sep 25, 2020
d880f36
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
djorkaeffalexandre Sep 29, 2020
5471d17
get avatar etag on select users of create discussion
djorkaeffalexandre Sep 29, 2020
a412d58
Merge branch 'fix.avatar-cache-invalidation' of https://github.com/Ro…
djorkaeffalexandre Sep 29, 2020
4eb7cb2
invalidate ci cache
djorkaeffalexandre Sep 29, 2020
e5d3138
Merge branch 'develop' into fix.avatar-cache-invalidation
diegolmello Oct 28, 2020
2ffc269
Fix migration
diegolmello Oct 28, 2020
53794d6
Fix sidebar avatar not updating
diegolmello Oct 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions __tests__/__snapshots__/Storyshots.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4199,20 +4199,6 @@ exports[`Storyshots Message list message 1`] = `
}
}
>
<View
style={
Array [
Object {
"borderRadius": 4,
"height": 36,
"width": 36,
},
Object {
"marginTop": 4,
},
]
}
/>
<View
style={
Array [
Expand Down
87 changes: 0 additions & 87 deletions app/containers/Avatar.js

This file was deleted.

110 changes: 110 additions & 0 deletions app/containers/Avatar/Avatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import React from 'react';
import PropTypes from 'prop-types';
import FastImage from '@rocket.chat/react-native-fast-image';
import Touchable from 'react-native-platform-touchable';
import { settings as RocketChatSettings } from '@rocket.chat/sdk';

import { avatarURL } from '../../utils/avatar';
import Emoji from '../markdown/Emoji';

const Avatar = React.memo(({
text,
size,
server,
borderRadius,
style,
avatar,
type,
children,
user,
onPress,
emoji,
theme,
getCustomEmoji,
avatarETag,
isStatic
}) => {
if ((!text && !avatar) || !server) {
return null;
}

const avatarStyle = {
width: size,
height: size,
borderRadius
};

let image;
if (emoji) {
image = (
<Emoji
theme={theme}
baseUrl={server}
getCustomEmoji={getCustomEmoji}
isMessageContainsOnlyEmoji
literal={emoji}
/>
);
} else {
const uri = avatarURL({
Comment thread
djorkaeffalexandre marked this conversation as resolved.
Outdated
type,
text,
size,
user,
avatar,
server,
avatarETag
});

image = (
<FastImage
style={avatarStyle}
source={{
uri: isStatic ? avatar : uri,
headers: RocketChatSettings.customHeaders,
priority: FastImage.priority.high
}}
/>
);
}


return (
Comment thread
djorkaeffalexandre marked this conversation as resolved.
<Touchable style={[avatarStyle, style]} disabled={!onPress} onPress={onPress}>
<>
{image}
{children}
</>
</Touchable>
);
});

Avatar.propTypes = {
server: PropTypes.string,
style: PropTypes.any,
text: PropTypes.string,
avatar: PropTypes.string,
emoji: PropTypes.string,
size: PropTypes.number,
borderRadius: PropTypes.number,
type: PropTypes.string,
children: PropTypes.object,
user: PropTypes.shape({
id: PropTypes.string,
token: PropTypes.string
}),
theme: PropTypes.string,
onPress: PropTypes.func,
getCustomEmoji: PropTypes.func,
avatarETag: PropTypes.string,
isStatic: PropTypes.bool
};

Avatar.defaultProps = {
text: '',
size: 25,
type: 'd',
borderRadius: 4
};

export default Avatar;
59 changes: 59 additions & 0 deletions app/containers/Avatar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Q } from '@nozbe/watermelondb';

import database from '../../lib/database';
import { getUserSelector } from '../../selectors/login';
import Component from './Avatar';
Comment thread
djorkaeffalexandre marked this conversation as resolved.
Outdated

const Avatar = React.memo(({ type, text, ...props }) => {
const [avatarETag, setAvatarETag] = useState();

useEffect(() => {
let subscription;
(async() => {
Comment thread
djorkaeffalexandre marked this conversation as resolved.
Outdated
if (type === 'd') {
const db = database.active;
const usersCollection = db.collections.get('users');
try {
const [userRecord] = await usersCollection.query(Q.where('username', text)).fetch();
if (userRecord) {
const observable = userRecord.observe();
subscription = observable.subscribe((u) => {
setAvatarETag(u.avatarETag);
});
}
} catch {
// Do nothing
}
}
})();
return () => {
subscription?.unsubscribe?.();
};
}, []);

return (
<Component
text={text}
type={type}
avatarETag={avatarETag}
{...props}
/>
);
});
Avatar.propTypes = {
text: PropTypes.string,
type: PropTypes.string
};
Avatar.defaultProps = {
text: '',
type: 'd'
};

const mapStateToProps = state => ({
user: getUserSelector(state),
server: state.share.server || state.server.server
});
export default connect(mapStateToProps)(Avatar);
12 changes: 2 additions & 10 deletions app/containers/InAppNotification/NotifierComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { CustomIcon } from '../../lib/Icons';
import sharedStyles from '../../views/Styles';
import { themes } from '../../constants/colors';
import { useTheme } from '../../theme';
import { getUserSelector } from '../../selectors/login';
import { ROW_HEIGHT } from '../../presentation/RoomItem';
import { goRoom } from '../../utils/goRoom';
import Navigation from '../../lib/Navigation';
Expand Down Expand Up @@ -65,14 +64,11 @@ const styles = StyleSheet.create({

const hideNotification = () => Notifier.hideNotification();

const NotifierComponent = React.memo(({
baseUrl, user, notification, isMasterDetail
}) => {
const NotifierComponent = React.memo(({ notification, isMasterDetail }) => {
const { theme } = useTheme();
const insets = useSafeAreaInsets();
const { isLandscape } = useOrientation();

const { id: userId, token } = user;
const { text, payload } = notification;
const { type } = payload;
const name = type === 'd' ? payload.sender.username : payload.name;
Expand Down Expand Up @@ -115,7 +111,7 @@ const NotifierComponent = React.memo(({
background={Touchable.SelectableBackgroundBorderless()}
>
<>
<Avatar text={avatar} size={AVATAR_SIZE} type={type} baseUrl={baseUrl} style={styles.avatar} userId={userId} token={token} />
<Avatar text={avatar} size={AVATAR_SIZE} type={type} style={styles.avatar} />
<View style={styles.inner}>
<Text style={[styles.roomName, { color: themes[theme].titleText }]} numberOfLines={1}>{title}</Text>
<Text style={[styles.message, { color: themes[theme].titleText }]} numberOfLines={1}>{text}</Text>
Expand All @@ -134,15 +130,11 @@ const NotifierComponent = React.memo(({
});

NotifierComponent.propTypes = {
baseUrl: PropTypes.string,
user: PropTypes.object,
notification: PropTypes.object,
isMasterDetail: PropTypes.bool
};

const mapStateToProps = state => ({
user: getUserSelector(state),
baseUrl: state.server.server,
isMasterDetail: state.app.isMasterDetail
});

Expand Down
5 changes: 1 addition & 4 deletions app/containers/MessageBox/Mentions/MentionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const MentionItem = ({
item, trackingType, theme
}) => {
const context = useContext(MessageboxContext);
const { baseUrl, user, onPressMention } = context;
const { onPressMention } = context;

const defineTestID = (type) => {
switch (type) {
Expand All @@ -43,9 +43,6 @@ const MentionItem = ({
text={item.username || item.name}
size={30}
type={item.t}
baseUrl={baseUrl}
userId={user.id}
token={user.token}
/>
<Text style={[styles.mentionText, { color: themes[theme].titleText }]}>{ item.username || item.name || item }</Text>
</>
Expand Down
8 changes: 4 additions & 4 deletions app/containers/message/MessageAvatar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from 'react';
import PropTypes from 'prop-types';

import Avatar from '../Avatar';
import Avatar from '../Avatar/Avatar';
import styles from './styles';
import MessageContext from './Context';

Expand All @@ -22,11 +22,11 @@ const MessageAvatar = React.memo(({
borderRadius={small ? 2 : 4}
onPress={author._id === user.id ? undefined : () => navToRoomInfo(navParam)}
getCustomEmoji={getCustomEmoji}
user={user}
server={baseUrl}
avatarETag={author.avatarETag}
avatar={avatar}
emoji={emoji}
baseUrl={baseUrl}
userId={user.id}
token={user.token}
theme={theme}
/>
);
Expand Down
Loading