Skip to content

Commit 070094d

Browse files
authored
Merge pull request #7 from Soomgo-Mobile/sync-8.3.0
Sync to upstream (react-native-code-push@master)
2 parents 7999637 + ad7dcae commit 070094d

File tree

13 files changed

+599
-346
lines changed

13 files changed

+599
-346
lines changed

.azurepipelines/test-rn-code-push.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
trigger:
2+
- master
3+
4+
pr:
5+
- master
6+
7+
variables:
8+
- name: api-level
9+
value: '27'
10+
11+
pool:
12+
vmImage: 'macOS-12'
13+
14+
stages:
15+
- stage: RunTests
16+
displayName: 'Run Android & IOS tests'
17+
jobs:
18+
- job: TestAndroid
19+
timeoutInMinutes: 120
20+
displayName: 'Test android'
21+
steps:
22+
23+
- script: |
24+
adb devices
25+
displayName: 'Start adb server'
26+
27+
- script: |
28+
$ANDROID_HOME/tools/bin/sdkmanager "system-images;android-$(api-level);google_apis;x86"
29+
displayName: 'Download system image'
30+
31+
- script: |
32+
$ANDROID_HOME/tools/bin/avdmanager create avd --force --name TestEmulator --abi google_apis/x86 --package 'system-images;android-$(api-level);google_apis;x86' --device "Nexus 6P"
33+
displayName: 'Creating Android emulator'
34+
35+
- script: |
36+
$ANDROID_HOME/emulator/emulator -avd TestEmulator -noaudio -no-window -no-snapshot-save -no-boot-anim -memory 6144 &
37+
displayName: 'Start Android emulator'
38+
39+
- script: |
40+
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done'
41+
displayName: 'Wait for emulator to boot'
42+
43+
- script: |
44+
adb shell settings put global window_animation_scale 0.0
45+
displayName: 'Disable animations and transitions'
46+
47+
- script: |
48+
adb shell settings put global transition_animation_scale 0.0
49+
displayName: 'Disable animations and transitions'
50+
51+
- script: |
52+
adb shell settings put global animator_duration_scale 0.0
53+
displayName: 'Disable animations and transitions'
54+
55+
56+
- task: JavaToolInstaller@0
57+
inputs:
58+
versionSpec: '11'
59+
jdkArchitectureOption: 'x64'
60+
jdkSourceOption: 'PreInstalled'
61+
displayName: 'Change Java version'
62+
63+
- script: |
64+
npm install
65+
displayName: 'Package Installation'
66+
67+
- script: |
68+
npm run build:tests && npm run test:setup:android
69+
displayName: 'Setup Android tests'
70+
71+
- script: |
72+
npm run test:fast:android
73+
displayName: 'Run Android test'
74+
75+
- job: TestIOS
76+
timeoutInMinutes: 120
77+
displayName: 'Test IOS'
78+
steps:
79+
80+
- script: |
81+
npm install
82+
displayName: 'Install dependencies'
83+
84+
- script: |
85+
npm run build:tests && npm run test:setup:ios
86+
displayName: 'Setup iOS tests'
87+
88+
- script: |
89+
npm run test:fast:ios
90+
displayName: 'Run tests'
91+
92+
93+
94+

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,7 @@ ipch/
188188
Ankh.NoLoad
189189

190190
# RN New Version App Generation
191-
Examples/testapp_rn
191+
Examples/testapp_rn
192+
193+
# Android debug build files (conflict ignoring #Visual Studio files)
194+
!android/app/src/debug/

CodePush.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -625,42 +625,41 @@ function codePushify(options = {}) {
625625
sharedCodePushOptions.setUpdateChecker(options.updateChecker);
626626
sharedCodePushOptions.setFallbackToAppCenter(options.fallbackToAppCenter);
627627

628-
var decorator = (RootComponent) => {
629-
const extended = class CodePushComponent extends React.Component {
628+
const decorator = (RootComponent) => {
629+
class CodePushComponent extends React.Component {
630+
constructor(props) {
631+
super(props);
632+
this.rootComponentRef = React.createRef();
633+
}
634+
630635
componentDidMount() {
631636
if (options.checkFrequency === CodePush.CheckFrequency.MANUAL) {
632637
CodePush.notifyAppReady();
633638
} else {
634-
let rootComponentInstance = this.refs.rootComponent;
639+
const rootComponentInstance = this.rootComponentRef.current;
635640

636641
let syncStatusCallback;
637642
if (rootComponentInstance && rootComponentInstance.codePushStatusDidChange) {
638-
syncStatusCallback = rootComponentInstance.codePushStatusDidChange;
639-
if (rootComponentInstance instanceof React.Component) {
640-
syncStatusCallback = syncStatusCallback.bind(rootComponentInstance);
641-
}
643+
syncStatusCallback = rootComponentInstance.codePushStatusDidChange.bind(rootComponentInstance);
642644
}
643645

644646
let downloadProgressCallback;
645647
if (rootComponentInstance && rootComponentInstance.codePushDownloadDidProgress) {
646-
downloadProgressCallback = rootComponentInstance.codePushDownloadDidProgress;
647-
if (rootComponentInstance instanceof React.Component) {
648-
downloadProgressCallback = downloadProgressCallback.bind(rootComponentInstance);
649-
}
648+
downloadProgressCallback = rootComponentInstance.codePushDownloadDidProgress.bind(rootComponentInstance);
650649
}
651650

652651
let handleBinaryVersionMismatchCallback;
653652
if (rootComponentInstance && rootComponentInstance.codePushOnBinaryVersionMismatch) {
654-
handleBinaryVersionMismatchCallback = rootComponentInstance.codePushOnBinaryVersionMismatch;
655-
if (rootComponentInstance instanceof React.Component) {
656-
handleBinaryVersionMismatchCallback = handleBinaryVersionMismatchCallback.bind(rootComponentInstance);
657-
}
653+
handleBinaryVersionMismatchCallback = rootComponentInstance.codePushOnBinaryVersionMismatch.bind(rootComponentInstance);
658654
}
659655

660656
CodePush.sync(options, syncStatusCallback, downloadProgressCallback, handleBinaryVersionMismatchCallback);
657+
661658
if (options.checkFrequency === CodePush.CheckFrequency.ON_APP_RESUME) {
662659
ReactNative.AppState.addEventListener("change", (newState) => {
663-
newState === "active" && CodePush.sync(options, syncStatusCallback, downloadProgressCallback);
660+
if (newState === "active") {
661+
CodePush.sync(options, syncStatusCallback, downloadProgressCallback);
662+
}
664663
});
665664
}
666665
}
@@ -669,17 +668,17 @@ function codePushify(options = {}) {
669668
render() {
670669
const props = {...this.props};
671670

672-
// we can set ref property on class components only (not stateless)
673-
// check it by render method
674-
if (RootComponent.prototype.render) {
675-
props.ref = "rootComponent";
671+
// We can set ref property on class components only (not stateless)
672+
// Check it by render method
673+
if (RootComponent.prototype && RootComponent.prototype.render) {
674+
props.ref = this.rootComponentRef;
676675
}
677676

678677
return <RootComponent {...props} />
679678
}
680679
}
681680

682-
return hoistStatics(extended, RootComponent);
681+
return hoistStatics(CodePushComponent, RootComponent);
683682
}
684683

685684
if (typeof options === "function") {

0 commit comments

Comments
 (0)