Skip to content

Commit 48b9f7a

Browse files
committed
fix build time check
1 parent f941b93 commit 48b9f7a

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

android/src/main/java/cn/reactnative/modules/update/UpdateContext.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@ public UpdateContext(Context context) {
4444
String storedPackageVersion = this.sp.getString("packageVersion", null);
4545
String storedBuildTime = this.sp.getString("buildTime", null);
4646

47-
// If stored versions don't exist, write current versions first
48-
if (storedPackageVersion == null || storedBuildTime == null) {
49-
SharedPreferences.Editor editor = sp.edit();
47+
48+
SharedPreferences.Editor editor = this.sp.edit();
49+
if (storedPackageVersion == null) {
5050
editor.putString("packageVersion", packageVersion);
51-
editor.putString("buildTime", buildTime);
5251
editor.apply();
5352
storedPackageVersion = packageVersion;
53+
}
54+
55+
if (storedBuildTime == null) {
56+
editor.putString("buildTime", buildTime);
57+
editor.apply();
5458
storedBuildTime = buildTime;
5559
}
5660

@@ -65,10 +69,7 @@ public UpdateContext(Context context) {
6569
editor.clear();
6670
editor.putString("packageVersion", packageVersion);
6771
editor.putString("buildTime", buildTime);
68-
// Use commit() instead of apply() to ensure synchronous write completion
69-
// This prevents race condition where getBundleUrl() might read null values
70-
// if called before apply() completes
71-
editor.commit();
72+
editor.apply();
7273
}
7374
}
7475

ios/RCTPushy/RCTPushy.mm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ + (NSURL *)bundleURL
7878
NSString *storedBuildTime = [defaults stringForKey:paramBuildTime];
7979

8080
// If stored versions don't exist, write current versions first
81-
if (!storedPackageVersion && !storedBuildTime) {
81+
if (!storedPackageVersion) {
8282
[defaults setObject:curPackageVersion forKey:paramPackageVersion];
83-
[defaults setObject:curBuildTime forKey:paramBuildTime];
8483
storedPackageVersion = curPackageVersion;
84+
}
85+
86+
if (!storedBuildTime) {
87+
[defaults setObject:curBuildTime forKey:paramBuildTime];
8588
storedBuildTime = curBuildTime;
8689
}
8790

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update",
3-
"version": "10.36.0",
3+
"version": "10.36.1",
44
"description": "react-native hot update",
55
"main": "src/index",
66
"scripts": {

0 commit comments

Comments
 (0)