react-native-update 10.14.0 → 10.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -430,6 +430,9 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
430
430
|
if (sub.getName().charAt(0) == '.') {
|
|
431
431
|
continue;
|
|
432
432
|
}
|
|
433
|
+
if (isFileUpdatedWithinDays(sub, 7)) {
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
433
436
|
if (sub.isFile()) {
|
|
434
437
|
sub.delete();
|
|
435
438
|
} else {
|
|
@@ -441,6 +444,13 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
441
444
|
}
|
|
442
445
|
}
|
|
443
446
|
|
|
447
|
+
private boolean isFileUpdatedWithinDays(File file, int days) {
|
|
448
|
+
long currentTime = System.currentTimeMillis();
|
|
449
|
+
long lastModified = file.lastModified();
|
|
450
|
+
long daysInMillis = days * 24 * 60 * 60 * 1000L;
|
|
451
|
+
return (currentTime - lastModified) < daysInMillis;
|
|
452
|
+
}
|
|
453
|
+
|
|
444
454
|
@Override
|
|
445
455
|
protected Void doInBackground(DownloadTaskParams... params) {
|
|
446
456
|
int taskType = params[0].type;
|
package/ios/RCTPushy/RCTPushy.mm
CHANGED
|
@@ -536,7 +536,15 @@ RCT_EXPORT_METHOD(markSuccess:(RCTPromiseResolveBlock)resolve
|
|
|
536
536
|
|
|
537
537
|
for(NSString *fileName in list) {
|
|
538
538
|
if (![fileName isEqualToString:curVersion]) {
|
|
539
|
-
|
|
539
|
+
NSString *filePath = [downloadDir stringByAppendingPathComponent:fileName];
|
|
540
|
+
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&error];
|
|
541
|
+
if (error) {
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
NSDate *modificationDate = [attributes fileModificationDate];
|
|
545
|
+
if ([[NSDate date] timeIntervalSinceDate:modificationDate] > 7 * 24 * 60 * 60) {
|
|
546
|
+
[_fileManager removeFile:filePath completionHandler:nil];
|
|
547
|
+
}
|
|
540
548
|
}
|
|
541
549
|
}
|
|
542
550
|
}
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
packageVersion,
|
|
12
12
|
rolledBackVersion,
|
|
13
13
|
setLocalHashInfo,
|
|
14
|
+
isFirstTime,
|
|
14
15
|
isRolledBack,
|
|
15
16
|
} from './core';
|
|
16
17
|
|
|
@@ -118,7 +119,7 @@ export class Pushy {
|
|
|
118
119
|
return true;
|
|
119
120
|
};
|
|
120
121
|
markSuccess = () => {
|
|
121
|
-
if (this.marked || __DEV__) {
|
|
122
|
+
if (this.marked || __DEV__ || !isFirstTime) {
|
|
122
123
|
return;
|
|
123
124
|
}
|
|
124
125
|
this.marked = true;
|
|
@@ -186,6 +187,7 @@ export class Pushy {
|
|
|
186
187
|
...extra,
|
|
187
188
|
};
|
|
188
189
|
if (__DEV__) {
|
|
190
|
+
// @ts-ignore
|
|
189
191
|
delete fetchBody.buildTime;
|
|
190
192
|
}
|
|
191
193
|
const body = JSON.stringify(fetchBody);
|
package/src/core.ts
CHANGED
|
@@ -21,14 +21,14 @@ const PushyConstants = isTurboModuleEnabled
|
|
|
21
21
|
? PushyModule.getConstants()
|
|
22
22
|
: PushyModule;
|
|
23
23
|
|
|
24
|
-
export const downloadRootDir = PushyConstants.downloadRootDir;
|
|
25
|
-
export const packageVersion = PushyConstants.packageVersion;
|
|
26
|
-
export const currentVersion = PushyConstants.currentVersion;
|
|
27
|
-
export const isFirstTime = PushyConstants.isFirstTime;
|
|
28
|
-
export const rolledBackVersion = PushyConstants.rolledBackVersion;
|
|
29
|
-
export const isRolledBack = typeof rolledBackVersion === 'string';
|
|
24
|
+
export const downloadRootDir: string = PushyConstants.downloadRootDir;
|
|
25
|
+
export const packageVersion: string = PushyConstants.packageVersion;
|
|
26
|
+
export const currentVersion: string = PushyConstants.currentVersion;
|
|
27
|
+
export const isFirstTime: boolean = PushyConstants.isFirstTime;
|
|
28
|
+
export const rolledBackVersion: string = PushyConstants.rolledBackVersion;
|
|
29
|
+
export const isRolledBack: boolean = typeof rolledBackVersion === 'string';
|
|
30
30
|
|
|
31
|
-
export const buildTime = PushyConstants.buildTime;
|
|
31
|
+
export const buildTime: string = PushyConstants.buildTime;
|
|
32
32
|
let uuid = PushyConstants.uuid;
|
|
33
33
|
|
|
34
34
|
if (Platform.OS === 'android' && !PushyConstants.isUsingBundleUrl) {
|
package/src/provider.tsx
CHANGED
|
@@ -13,12 +13,7 @@ import {
|
|
|
13
13
|
Linking,
|
|
14
14
|
} from 'react-native';
|
|
15
15
|
import { Pushy } from './client';
|
|
16
|
-
import {
|
|
17
|
-
currentVersion,
|
|
18
|
-
isFirstTime,
|
|
19
|
-
packageVersion,
|
|
20
|
-
getCurrentVersionInfo,
|
|
21
|
-
} from './core';
|
|
16
|
+
import { currentVersion, packageVersion, getCurrentVersionInfo } from './core';
|
|
22
17
|
import { CheckResult, ProgressData, PushyTestPayload } from './type';
|
|
23
18
|
import { PushyContext } from './context';
|
|
24
19
|
import { URL } from 'react-native-url-polyfill';
|
|
@@ -167,7 +162,7 @@ export const PushyProvider = ({
|
|
|
167
162
|
if (!info) {
|
|
168
163
|
return;
|
|
169
164
|
}
|
|
170
|
-
const rollout = info.config?.rollout;
|
|
165
|
+
const rollout = info.config?.rollout?.[packageVersion];
|
|
171
166
|
if (rollout) {
|
|
172
167
|
if (!isInRollout(rollout)) {
|
|
173
168
|
log(`not in ${rollout}% rollout, ignored`);
|
|
@@ -246,7 +241,7 @@ export const PushyProvider = ({
|
|
|
246
241
|
return;
|
|
247
242
|
}
|
|
248
243
|
const { checkStrategy, dismissErrorAfter, autoMarkSuccess } = options;
|
|
249
|
-
if (
|
|
244
|
+
if (autoMarkSuccess) {
|
|
250
245
|
markSuccess();
|
|
251
246
|
}
|
|
252
247
|
if (checkStrategy === 'both' || checkStrategy === 'onAppResume') {
|
package/src/type.ts
CHANGED
|
@@ -8,7 +8,9 @@ export interface CheckResult {
|
|
|
8
8
|
description?: string;
|
|
9
9
|
metaInfo?: string;
|
|
10
10
|
config?: {
|
|
11
|
-
rollout?:
|
|
11
|
+
rollout?: {
|
|
12
|
+
[packageVersion: string]: number;
|
|
13
|
+
};
|
|
12
14
|
[key: string]: any;
|
|
13
15
|
};
|
|
14
16
|
pdiff?: string;
|
|
@@ -47,7 +49,7 @@ export interface EventData {
|
|
|
47
49
|
uuid: string;
|
|
48
50
|
};
|
|
49
51
|
packageVersion: string;
|
|
50
|
-
buildTime:
|
|
52
|
+
buildTime: string;
|
|
51
53
|
message?: string;
|
|
52
54
|
rolledBackVersion?: string;
|
|
53
55
|
newVersion?: string;
|