Skip to content

Commit

Permalink
Merge branch 'develop' into profile
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/containers/Sidebar.js
#	app/containers/routes/AuthRoutes.js
#	app/i18n/locales/en.js
#	app/views/ProfileView/index.js
#	app/views/SettingsView/index.js
  • Loading branch information
diegolmello committed Jun 8, 2018
2 parents 175d86a + da3679d commit 3cdb73f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
6 changes: 3 additions & 3 deletions __tests__/__snapshots__/RoomItem.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ exports[`render unread +999 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/name",
"uri": "/avatar/name?random=0",
}
}
style={
Expand Down Expand Up @@ -880,7 +880,7 @@ exports[`render unread 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/name",
"uri": "/avatar/name?random=0",
}
}
style={
Expand Down Expand Up @@ -1142,7 +1142,7 @@ exports[`renders correctly 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/name",
"uri": "/avatar/name?random=0",
}
}
style={
Expand Down
30 changes: 15 additions & 15 deletions __tests__/__snapshots__/Storyshots.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ exports[`Storyshots Avatar avatar 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/test",
"uri": "/avatar/test?random=0",
}
}
style={
Expand Down Expand Up @@ -146,7 +146,7 @@ exports[`Storyshots Avatar avatar 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/aa",
"uri": "/avatar/aa?random=0",
}
}
style={
Expand Down Expand Up @@ -225,7 +225,7 @@ exports[`Storyshots Avatar avatar 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/bb",
"uri": "/avatar/bb?random=0",
}
}
style={
Expand Down Expand Up @@ -304,7 +304,7 @@ exports[`Storyshots Avatar avatar 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/test",
"uri": "/avatar/test?random=0",
}
}
style={
Expand Down Expand Up @@ -425,7 +425,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/rocket.cat",
"uri": "/avatar/rocket.cat?random=0",
}
}
style={
Expand Down Expand Up @@ -659,7 +659,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/rocket.cat",
"uri": "/avatar/rocket.cat?random=0",
}
}
style={
Expand Down Expand Up @@ -897,7 +897,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/rocket.cat",
"uri": "/avatar/rocket.cat?random=0",
}
}
style={
Expand Down Expand Up @@ -1154,7 +1154,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries",
"uri": "/avatar/Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries?random=0",
}
}
style={
Expand Down Expand Up @@ -1415,7 +1415,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries",
"uri": "/avatar/Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries?random=0",
}
}
style={
Expand Down Expand Up @@ -1672,7 +1672,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries",
"uri": "/avatar/Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries?random=0",
}
}
style={
Expand Down Expand Up @@ -1929,7 +1929,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries",
"uri": "/avatar/Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries?random=0",
}
}
style={
Expand Down Expand Up @@ -2186,7 +2186,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries",
"uri": "/avatar/Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries?random=0",
}
}
style={
Expand Down Expand Up @@ -2443,7 +2443,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/W",
"uri": "/avatar/W?random=0",
}
}
style={
Expand Down Expand Up @@ -2677,7 +2677,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/WW",
"uri": "/avatar/WW?random=0",
}
}
style={
Expand Down Expand Up @@ -2911,7 +2911,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/",
"uri": "/avatar/?random=0",
}
}
style={
Expand Down
20 changes: 18 additions & 2 deletions app/containers/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class Avatar extends React.PureComponent {
componentDidMount() {
const { text, type } = this.props;
if (type === 'd') {
this.users = database.objects('users').filtered('username = $0', text);
this.users = this.userQuery(text);
this.users.addListener(this.update);
this.update();
}
Expand All @@ -58,7 +58,7 @@ export default class Avatar extends React.PureComponent {
if (this.users) {
this.users.removeAllListeners();
}
this.users = database.objects('users').filtered('username = $0', nextProps.text);
this.users = this.userQuery(nextProps.text);
this.users.addListener(this.update);
this.update();
}
Expand All @@ -74,6 +74,22 @@ export default class Avatar extends React.PureComponent {
return (this.state.user && this.state.user.avatarVersion) || 0;
}

/** FIXME: Workaround
* While we don't have containers/components structure, this is breaking tests.
* In that case, avatar would be a component, it would receive an `avatarVersion` param
* and we would have a avatar container in charge of making queries.
* Also, it would make possible to write unit tests like these.
*/
userQuery = (username) => {
if (database && database.databases && database.databases.activeDB) {
return database.objects('users').filtered('username = $0', username);
}
return {
addListener: () => {},
removeAllListeners: () => {}
};
}

update = () => {
if (this.users.length) {
this.setState({ user: this.users[0] });
Expand Down
3 changes: 0 additions & 3 deletions app/views/SettingsView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ export default class SettingsView extends LoggedView {
languages: [{
label: 'English',
value: 'en'
}, {
label: 'Português do Brasil',
value: 'pt-BR'
}],
saving: false
};
Expand Down

0 comments on commit 3cdb73f

Please sign in to comment.