Skip to content

Commit

Permalink
fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzhao committed Dec 11, 2019
1 parent e72e6b2 commit c873f37
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
26 changes: 19 additions & 7 deletions lib/CodePushHandler.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/CodePushHandler.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 19 additions & 7 deletions lib/CodePushHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ const decorator = (options?:IProps)=> (WrappedComponent) => {
let localPackage: LocalPackage;
try {
localPackage = await updateInfo.download((progress) => {
console.log('codePushHandler:', progress);
if (this.props.isDebugMode) {
console.log('codePushHandler:', progress);
}
this.setState({
progress: progress.receivedBytes / progress.totalBytes
});
Expand All @@ -198,23 +200,33 @@ const decorator = (options?:IProps)=> (WrappedComponent) => {
}
}
if (localPackage) {
console.log('下载成功!');
if (this.props.isDebugMode) {
console.log('下载成功!');
}
//只能这里关闭,后面因为app会自动重启,会失效,导致modal关闭不了
try {
//暂停半分钟之后应用
await localPackage.install(updateInfo.isSilent ? codePush.InstallMode.ON_NEXT_SUSPEND : codePush.InstallMode.ON_NEXT_RESTART, 30);
console.log('安装成功!');
if (this.props.isDebugMode) {
console.log('安装成功!');
}
await codePush.notifyAppReady();
this.setState({
modalVisible: false
});

if (!updateInfo.isSilent) {
Alert.alert('提示', this.props.successAlertInfo, [{
text: '确定',
onPress: () => {
codePush.restartApp();
this.setState({
modalVisible: false
},()=>{
codePush.restartApp();
});
}
}], { cancelable: false });
} else {
this.setState({
modalVisible: false
});
}
// this.setState({modalVisible: false},()=>{
// codePush.restartApp();
Expand Down

0 comments on commit c873f37

Please sign in to comment.