mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-12-14 09:12:34 +08:00
fix build time check
This commit is contained in:
@@ -44,13 +44,17 @@ public class UpdateContext {
|
||||
String storedPackageVersion = this.sp.getString("packageVersion", 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 = sp.edit();
|
||||
|
||||
SharedPreferences.Editor editor = this.sp.edit();
|
||||
if (storedPackageVersion == null) {
|
||||
editor.putString("packageVersion", packageVersion);
|
||||
editor.putString("buildTime", buildTime);
|
||||
editor.apply();
|
||||
storedPackageVersion = packageVersion;
|
||||
}
|
||||
|
||||
if (storedBuildTime == null) {
|
||||
editor.putString("buildTime", buildTime);
|
||||
editor.apply();
|
||||
storedBuildTime = buildTime;
|
||||
}
|
||||
|
||||
@@ -65,10 +69,7 @@ public class UpdateContext {
|
||||
editor.clear();
|
||||
editor.putString("packageVersion", packageVersion);
|
||||
editor.putString("buildTime", buildTime);
|
||||
// Use commit() instead of apply() to ensure synchronous write completion
|
||||
// This prevents race condition where getBundleUrl() might read null values
|
||||
// if called before apply() completes
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,10 +78,13 @@ RCT_EXPORT_MODULE(RCTPushy);
|
||||
NSString *storedBuildTime = [defaults stringForKey:paramBuildTime];
|
||||
|
||||
// If stored versions don't exist, write current versions first
|
||||
if (!storedPackageVersion && !storedBuildTime) {
|
||||
if (!storedPackageVersion) {
|
||||
[defaults setObject:curPackageVersion forKey:paramPackageVersion];
|
||||
[defaults setObject:curBuildTime forKey:paramBuildTime];
|
||||
storedPackageVersion = curPackageVersion;
|
||||
}
|
||||
|
||||
if (!storedBuildTime) {
|
||||
[defaults setObject:curBuildTime forKey:paramBuildTime];
|
||||
storedBuildTime = curBuildTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "10.36.0",
|
||||
"version": "10.36.1",
|
||||
"description": "react-native hot update",
|
||||
"main": "src/index",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user