Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ jobs:
cd android

echo -e "" > ./gradle.properties
echo -e "android.enableAapt2=false" >> ./gradle.properties

if [[ $KEYSTORE ]]; then
echo $KEYSTORE_BASE64 | base64 --decode > ./app/$KEYSTORE
Expand Down
6 changes: 3 additions & 3 deletions __tests__/__snapshots__/RoomItem.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ exports[`render unread +999 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/name?random=0",
"uri": "/avatar/name",
}
}
style={
Expand Down Expand Up @@ -835,7 +835,7 @@ exports[`render unread 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/name?random=0",
"uri": "/avatar/name",
}
}
style={
Expand Down Expand Up @@ -1085,7 +1085,7 @@ exports[`renders correctly 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/name?random=0",
"uri": "/avatar/name",
}
}
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 @@ -62,7 +62,7 @@ exports[`Storyshots Avatar avatar 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/test?random=0",
"uri": "/avatar/test",
}
}
style={
Expand Down Expand Up @@ -136,7 +136,7 @@ exports[`Storyshots Avatar avatar 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/aa?random=0",
"uri": "/avatar/aa",
}
}
style={
Expand Down Expand Up @@ -210,7 +210,7 @@ exports[`Storyshots Avatar avatar 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/bb?random=0",
"uri": "/avatar/bb",
}
}
style={
Expand Down Expand Up @@ -284,7 +284,7 @@ exports[`Storyshots Avatar avatar 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/test?random=0",
"uri": "/avatar/test",
}
}
style={
Expand Down Expand Up @@ -393,7 +393,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/rocket.cat?random=0",
"uri": "/avatar/rocket.cat",
}
}
style={
Expand Down Expand Up @@ -615,7 +615,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/rocket.cat?random=0",
"uri": "/avatar/rocket.cat",
}
}
style={
Expand Down Expand Up @@ -841,7 +841,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/rocket.cat?random=0",
"uri": "/avatar/rocket.cat",
}
}
style={
Expand Down Expand Up @@ -1086,7 +1086,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?random=0",
"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",
}
}
style={
Expand Down Expand Up @@ -1335,7 +1335,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?random=0",
"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",
}
}
style={
Expand Down Expand Up @@ -1580,7 +1580,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?random=0",
"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",
}
}
style={
Expand Down Expand Up @@ -1825,7 +1825,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?random=0",
"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",
}
}
style={
Expand Down Expand Up @@ -2070,7 +2070,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?random=0",
"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",
}
}
style={
Expand Down Expand Up @@ -2315,7 +2315,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/W?random=0",
"uri": "/avatar/W",
}
}
style={
Expand Down Expand Up @@ -2537,7 +2537,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/WW?random=0",
"uri": "/avatar/WW",
}
}
style={
Expand Down Expand Up @@ -2759,7 +2759,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
source={
Object {
"priority": "high",
"uri": "/avatar/?random=0",
"uri": "/avatar/",
}
}
style={
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
buildToolsVersion "27.0.3"

defaultConfig {
applicationId "chat.rocket.reactnative"
minSdkVersion 16
targetSdkVersion 23
targetSdkVersion 27
versionCode VERSIONCODE as Integer
versionName "1"
ndk {
Expand Down
5 changes: 4 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:3.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -16,6 +18,7 @@ allprojects {
repositories {
mavenLocal()
jcenter()
google()
maven {
url 'https://maven.google.com'
}
Expand Down
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.enableAapt2=false
android.useDeprecatedNdk=true
VERSIONCODE=999999999
3 changes: 2 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
# distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
86 changes: 43 additions & 43 deletions app/containers/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { connect } from 'react-redux';
import { StyleSheet, Text, View, ViewPropTypes } from 'react-native';
import FastImage from 'react-native-fast-image';
import avatarInitialsAndColor from '../utils/avatarInitialsAndColor';
import database from '../lib/realm';

const styles = StyleSheet.create({
iconContainer: {
Expand Down Expand Up @@ -42,59 +41,60 @@ export default class Avatar extends React.PureComponent {
borderRadius: 2,
forceInitials: false
};
state = { showInitials: true, user: {} };
state = { showInitials: true };

componentDidMount() {
const { text, type } = this.props;
if (type === 'd') {
this.users = this.userQuery(text);
this.users.addListener(this.update);
this.update();
}
}
// componentDidMount() {
// const { text, type } = this.props;
// if (type === 'd') {
// this.users = this.userQuery(text);
// this.users.addListener(this.update);
// this.update();
// }
// }

componentWillReceiveProps(nextProps) {
if (nextProps.text !== this.props.text && nextProps.type === 'd') {
if (this.users) {
this.users.removeAllListeners();
}
this.users = this.userQuery(nextProps.text);
this.users.addListener(this.update);
this.update();
}
}
// componentWillReceiveProps(nextProps) {
// if (nextProps.text !== this.props.text && nextProps.type === 'd') {
// if (this.users) {
// this.users.removeAllListeners();
// }
// this.users = this.userQuery(nextProps.text);
// this.users.addListener(this.update);
// this.update();
// }
// }

componentWillUnmount() {
if (this.users) {
this.users.removeAllListeners();
}
}
// componentWillUnmount() {
// if (this.users) {
// this.users.removeAllListeners();
// }
// }

get avatarVersion() {
return (this.state.user && this.state.user.avatarVersion) || 0;
}
// get avatarVersion() {
// // return (this.state.user && this.state.user.avatarVersion) || 0;
// return 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: () => {}
};
}
// 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] });
}
}
// update = () => {
// if (this.users.length) {
// this.setState({ user: this.users[0] });
// }
// }

render() {
const {
Expand Down Expand Up @@ -123,7 +123,7 @@ export default class Avatar extends React.PureComponent {
let image;

if (type === 'd' && !forceInitials) {
const uri = avatar || `${ baseUrl }/avatar/${ text }?random=${ this.avatarVersion }`;
const uri = avatar || `${ baseUrl }/avatar/${ text }`;
image = uri ? (
<FastImage
style={[styles.avatar, avatarStyle]}
Expand Down
2 changes: 1 addition & 1 deletion app/containers/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class Routes extends React.Component {
}

componentWillUnmount() {
Linking.removeAllListeners();
Linking.removeEventListener('url', this.handleOpenURL);
}

handleOpenURL({ url }) {
Expand Down
9 changes: 7 additions & 2 deletions app/lib/ddp.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,13 @@ export default class Socket extends EventEmitter {
}, 5000);
this.connection = new WebSocket(`${ this.url }/websocket`, null);

this.connection.onopen = () => {
this.connection.onopen = async() => {
this.emit('open');
resolve();
this.ddp.emit('open');
return this._login && this.login(this._login);
if (this._login) {
return this.login(this._login).catch(e => console.warn(e));
}
};
this.connection.onclose = debounce((e) => {
this.emit('disconnected', e);
Expand Down Expand Up @@ -260,6 +262,9 @@ export default class Socket extends EventEmitter {
msg: 'method', method, params
}).then(data => data.result || data.subs).catch((err) => {
log('DDP call Error', err);
if (err && /you've been logged out by the server/i.test(err.reason)) {
return this.emit('forbidden');
}
return Promise.reject(err);
});
}
Expand Down
Loading