mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-12-15 01:22:34 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bff828e623 | ||
|
|
48b9f7ab07 |
@@ -44,13 +44,17 @@ public class UpdateContext {
|
|||||||
String storedPackageVersion = this.sp.getString("packageVersion", null);
|
String storedPackageVersion = this.sp.getString("packageVersion", null);
|
||||||
String storedBuildTime = this.sp.getString("buildTime", null);
|
String storedBuildTime = this.sp.getString("buildTime", null);
|
||||||
|
|
||||||
// If stored versions don't exist, write current versions first
|
|
||||||
if (storedPackageVersion == null || storedBuildTime == null) {
|
SharedPreferences.Editor editor = this.sp.edit();
|
||||||
SharedPreferences.Editor editor = sp.edit();
|
if (storedPackageVersion == null) {
|
||||||
editor.putString("packageVersion", packageVersion);
|
editor.putString("packageVersion", packageVersion);
|
||||||
editor.putString("buildTime", buildTime);
|
|
||||||
editor.apply();
|
editor.apply();
|
||||||
storedPackageVersion = packageVersion;
|
storedPackageVersion = packageVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (storedBuildTime == null) {
|
||||||
|
editor.putString("buildTime", buildTime);
|
||||||
|
editor.apply();
|
||||||
storedBuildTime = buildTime;
|
storedBuildTime = buildTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,15 +64,10 @@ public class UpdateContext {
|
|||||||
if (packageVersionChanged || buildTimeChanged) {
|
if (packageVersionChanged || buildTimeChanged) {
|
||||||
// Execute cleanUp before clearing SharedPreferences to avoid race condition
|
// Execute cleanUp before clearing SharedPreferences to avoid race condition
|
||||||
this.cleanUp();
|
this.cleanUp();
|
||||||
|
|
||||||
SharedPreferences.Editor editor = sp.edit();
|
|
||||||
editor.clear();
|
editor.clear();
|
||||||
editor.putString("packageVersion", packageVersion);
|
editor.putString("packageVersion", packageVersion);
|
||||||
editor.putString("buildTime", buildTime);
|
editor.putString("buildTime", buildTime);
|
||||||
// Use commit() instead of apply() to ensure synchronous write completion
|
editor.apply();
|
||||||
// This prevents race condition where getBundleUrl() might read null values
|
|
||||||
// if called before apply() completes
|
|
||||||
editor.commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,10 +78,13 @@ RCT_EXPORT_MODULE(RCTPushy);
|
|||||||
NSString *storedBuildTime = [defaults stringForKey:paramBuildTime];
|
NSString *storedBuildTime = [defaults stringForKey:paramBuildTime];
|
||||||
|
|
||||||
// If stored versions don't exist, write current versions first
|
// If stored versions don't exist, write current versions first
|
||||||
if (!storedPackageVersion && !storedBuildTime) {
|
if (!storedPackageVersion) {
|
||||||
[defaults setObject:curPackageVersion forKey:paramPackageVersion];
|
[defaults setObject:curPackageVersion forKey:paramPackageVersion];
|
||||||
[defaults setObject:curBuildTime forKey:paramBuildTime];
|
|
||||||
storedPackageVersion = curPackageVersion;
|
storedPackageVersion = curPackageVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!storedBuildTime) {
|
||||||
|
[defaults setObject:curBuildTime forKey:paramBuildTime];
|
||||||
storedBuildTime = curBuildTime;
|
storedBuildTime = curBuildTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update",
|
"name": "react-native-update",
|
||||||
"version": "10.36.0",
|
"version": "10.36.2",
|
||||||
"description": "react-native hot update",
|
"description": "react-native hot update",
|
||||||
"main": "src/index",
|
"main": "src/index",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user