Skip to content

Commit

Permalink
WIP: performance opto
Browse files Browse the repository at this point in the history
  • Loading branch information
seavan committed Dec 15, 2016
1 parent 47a6e69 commit a937702
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 27 deletions.
10 changes: 7 additions & 3 deletions app/components/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { View, PanResponder, Navigator, AppState } from 'react-native';
import { reaction, action } from 'mobx';
import { reaction, action, spy } from 'mobx';
import { observer } from 'mobx-react/native';
import Login from './login/login';
import Signup from './signup/signup';
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class App extends Component {
console.error = console._errorOriginal;
}

!__DEV__ && global.ErrorUtils && global.ErrorUtils.setGlobalHandler((...args) => {
global.ErrorUtils && global.ErrorUtils.setGlobalHandler((...args) => {
console.error('App.js: unhandled error');
console.error(args);
});
Expand Down Expand Up @@ -92,7 +92,11 @@ export default class App extends Component {
if (appState !== 'active') {
icebear.socket.close();
} else {
icebear.socket.open();
// spy((event) => {
// console.log('app.js spy');
// console.log(event);
// });
setTimeout(() => icebear.socket.open(), 2000);
}
}

Expand Down
27 changes: 16 additions & 11 deletions app/components/files/file-progress.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React, { Component } from 'react';
import {
View,
Dimensions,
Animated
} from 'react-native';
import { observable, autorun, reaction } from 'mobx';
import { observer } from 'mobx-react/native';
import { vars } from '../../styles/styles';

@observer
const width = Dimensions.get('window').width;

export default class FileProgress extends Component {
@observable width = 0;
// @observable width = 0;
prevFile = null;

get hidden() {
Expand All @@ -27,27 +29,30 @@ export default class FileProgress extends Component {
if (file.uploading) {
max = file.progressMax | 1;
}
return (this.width * file.progress / max) | 0;
// console.log(`file-progress.js: ${file.progress}, ${file.progressMax}`);
return (width * file.progress / max);
}

progress = new Animated.Value(0);

layout(evt) {
this.width = evt.nativeEvent.layout.width;
// this.width = evt.nativeEvent.layout.width;
reaction(() => this.props.file, file => {
if (file !== this.prevFile) {
this.prevFile = file;
this.progress.setValue(this.value);
}
}, true);
autorun(() => {
if (this.hidden) return;
if (this.hidden) {
this.progress.setValue(0);
return;
}
const toValue = this.value;
const duration = 3000;
console.log(this.progress);
toValue < this.progress._toValue ?
this.progress.setValue(0) :
Animated.timing(this.progress, { toValue, duration }).start();
// console.log(`file-progress.js: ${toValue}`);
const duration = 100;
// this.progress.setValue(toValue);
Animated.timing(this.progress, { toValue, duration }).start();
});
}

Expand All @@ -58,7 +63,7 @@ export default class FileProgress extends Component {
marginTop: -height,
height,
backgroundColor: '#CFCFCF',
flex: 1
width
};
const pbProgress = {
height,
Expand Down
2 changes: 1 addition & 1 deletion app/components/helpers/imagepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default {
} else {
source = { uri: response.uri, isStatic: true };
}
console.log('imagepicker.js: ', source);
// console.log('imagepicker.js: ', source);
fileStore.upload(source.uri);
// console.log(`imagepicker.js: id ${file.id}`);
// console.log(`imagepicker.js: fileId ${file.fileId}`);
Expand Down
8 changes: 4 additions & 4 deletions app/components/layout/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ const state = observable({
},

@action hideKeyboard() {
if (state.focusedTextBox) {
state.focusedTextBox.blur();
state.focusedTextBox = null;
}
// if (state.focusedTextBox) {
// // state.focusedTextBox.blur();
// state.focusedTextBox = null;
// }
dismissKeyboard();
setTimeout(() => { state.pickerVisible = false; }, 0);
},
Expand Down
2 changes: 1 addition & 1 deletion app/components/main/main-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const mainState = observable({
const file = i || this.currentFile;
if (!file) return;
if (file.downloading || file.uploading) return;
file.download();
file.download().catch(e => console.error(e));
},

@action deleteFile(i) {
Expand Down
6 changes: 3 additions & 3 deletions ios/peeriomobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "export NODE_BINARY=node\n# ../node_modules/react-native/packager/react-native-xcode.sh\ncd $SRCROOT/..\nsource env.sh\n# clean up\nrm -f ios/main.jsbundle\nif [ \"$CONFIGURATION\" == \"Debug\" ]; then\n ./node_modules/.bin/react-native bundle --entry-file index.ios.js --bundle-output ios/main.jsbundle --assets-dest \"$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\" --platform ios --reset-cache\nfi\nif [ \"$CONFIGURATION\" == \"Release\" ]; then\n ./node_modules/.bin/react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --assets-dest \"$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\" --platform ios --reset-cache\nfi\n# check that command was successful\n\nif [ ! -f ios/main.jsbundle ]; then\n echo \"JS compilation failed. Please check the sources\"\n exit 1\nfi\n";
shellScript = "export NODE_BINARY=node\n\n# ../node_modules/react-native/packager/react-native-xcode.sh\ncd $SRCROOT/..\nsource env.sh\n# clean up\nrm -f ios/main.jsbundle\nif [ \"$CONFIGURATION\" == \"Debug\" ]; then\n ./node_modules/.bin/react-native bundle --entry-file index.ios.js --bundle-output ios/main.jsbundle --assets-dest \"$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\" --platform ios --reset-cache\nfi\nif [ \"$CONFIGURATION\" == \"Release\" ]; then\n ./node_modules/.bin/react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --assets-dest \"$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\" --platform ios --reset-cache\nfi\n# check that command was successful\n\nif [ ! -f ios/main.jsbundle ]; then\n echo \"JS compilation failed. Please check the sources\"\n exit 1\nfi\n";
};
02DB415B1DCD1DB000E04176 /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -1067,7 +1067,7 @@
CODE_SIGN_ENTITLEMENTS = peeriomobile/peeriomobile.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 149;
CURRENT_PROJECT_VERSION = 151;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 7L45B96YPK;
HEADER_SEARCH_PATHS = (
Expand Down Expand Up @@ -1120,7 +1120,7 @@
CODE_SIGN_ENTITLEMENTS = peeriomobile/peeriomobile.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 149;
CURRENT_PROJECT_VERSION = 151;
DEVELOPMENT_TEAM = 7L45B96YPK;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand Down
2 changes: 1 addition & 1 deletion ios/peeriomobile/Info-Expandoo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>149</string>
<string>151</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/peeriomobile/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>149</string>
<string>151</string>
<key>ITSAppUsesNonExemptEncryption</key>
<true/>
<key>ITSEncryptionExportComplianceCode</key>
Expand Down
3 changes: 1 addition & 2 deletions shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ global.WebSocket = function(url) {
};

// global.WebSocket = global.originalWebSocket;
const ws = new WebSocket('ws://localhost:8081')
console.log('shim.js binaryType: ', ws.binaryType);
// console.log('shim.js binaryType: ', ws.binaryType);
// console.log('shim.js: ', global.originalWebSocket);

0 comments on commit a937702

Please sign in to comment.