mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-16 13:01:38 +08:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
27327dbe12 | ||
![]() |
96a81cc36d | ||
![]() |
0aa063c584 | ||
![]() |
4d72d49fe4 | ||
![]() |
53d07406ef | ||
![]() |
d0804cfe15 | ||
![]() |
35939286d0 | ||
![]() |
f49ce30cef | ||
![]() |
e6cd25a2d8 | ||
![]() |
0cc96ee59c |
@@ -68,6 +68,9 @@ export default class App extends Component {
|
||||
});
|
||||
},
|
||||
});
|
||||
if (!hash) {
|
||||
return;
|
||||
}
|
||||
Alert.alert('提示', '下载完毕,是否重启应用?', [
|
||||
{
|
||||
text: '是',
|
||||
|
46
lib/main.js
46
lib/main.js
@@ -175,8 +175,8 @@ export async function downloadUpdate(options, eventListeners) {
|
||||
if (!options.update) {
|
||||
return;
|
||||
}
|
||||
if (rolledbackVersion === options.hash) {
|
||||
logger(`rolledback hash ${rolledbackVersion}, ignored`);
|
||||
if (rolledBackVersion === options.hash) {
|
||||
logger(`rolledback hash ${rolledBackVersion}, ignored`);
|
||||
return;
|
||||
}
|
||||
if (downloadedHash === options.hash) {
|
||||
@@ -218,19 +218,30 @@ export async function downloadUpdate(options, eventListeners) {
|
||||
originHash: currentVersion,
|
||||
});
|
||||
} catch (e) {
|
||||
logger(e.message);
|
||||
logger('diff error, try pdiff');
|
||||
logger(`diff error: ${e.message}, try pdiff`);
|
||||
try {
|
||||
await Pushy.downloadPatchFromPackage({
|
||||
updateUrl: options.pdiffUrl,
|
||||
hash: options.hash,
|
||||
});
|
||||
} catch (e) {
|
||||
progressHandler && progressHandler.remove();
|
||||
report(options.hash, 'error');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else if (options.pdiffUrl) {
|
||||
logger('downloading pdiff');
|
||||
try {
|
||||
await Pushy.downloadPatchFromPackage({
|
||||
updateUrl: options.pdiffUrl,
|
||||
hash: options.hash,
|
||||
});
|
||||
} catch (e) {
|
||||
progressHandler && progressHandler.remove();
|
||||
report(options.hash, 'error');
|
||||
throw e;
|
||||
}
|
||||
} else if (options.pdiffUrl) {
|
||||
logger('downloading pdiff');
|
||||
await Pushy.downloadPatchFromPackage({
|
||||
updateUrl: options.pdiffUrl,
|
||||
hash: options.hash,
|
||||
});
|
||||
}
|
||||
setLocalHashInfo(options.hash, {
|
||||
name: options.name,
|
||||
@@ -257,20 +268,23 @@ function assertHash(hash) {
|
||||
return;
|
||||
}
|
||||
readyHash = hash;
|
||||
return true;
|
||||
}
|
||||
|
||||
export function switchVersion(hash) {
|
||||
assertRelease();
|
||||
assertHash(hash);
|
||||
logger('switchVersion: ' + hash);
|
||||
Pushy.reloadUpdate({ hash });
|
||||
if (assertHash(hash)) {
|
||||
logger('switchVersion: ' + hash);
|
||||
Pushy.reloadUpdate({ hash });
|
||||
}
|
||||
}
|
||||
|
||||
export function switchVersionLater(hash) {
|
||||
assertRelease();
|
||||
assertHash(hash);
|
||||
logger('switchVersionLater: ' + hash);
|
||||
Pushy.setNeedUpdate({ hash });
|
||||
if (assertHash(hash)) {
|
||||
logger('switchVersionLater: ' + hash);
|
||||
Pushy.setNeedUpdate({ hash });
|
||||
}
|
||||
}
|
||||
|
||||
let marked = false;
|
||||
|
@@ -41,6 +41,9 @@ export function simpleUpdate(WrappedComponent) {
|
||||
doUpdate = async (info) => {
|
||||
try {
|
||||
const hash = await downloadUpdate(info);
|
||||
if (!hash) {
|
||||
return;
|
||||
}
|
||||
this.stateListener.remove();
|
||||
Alert.alert('提示', '下载完毕,是否立即更新?', [
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "7.1.0",
|
||||
"version": "7.3.3",
|
||||
"description": "react-native hot update",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
|
Reference in New Issue
Block a user