Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 9cef711

Browse files
committed
Adding new description prefix option
1 parent 4968fe6 commit 9cef711

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

CodePush.ios.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ function notifyApplicationReady() {
107107
*/
108108
function sync(options = {}) {
109109
var syncOptions = {
110+
descriptionPrefix: " Description: ",
111+
appendReleaseDescription: false,
112+
110113
ignoreFailedUpdates: true,
111114

112115
mandatoryContinueButtonLabel: "Continue",
@@ -119,7 +122,6 @@ function sync(options = {}) {
119122
rollbackTimeout: 0,
120123

121124
updateTitle: "Update available",
122-
useReleaseDescription: false,
123125

124126
...options
125127
};
@@ -128,7 +130,7 @@ function sync(options = {}) {
128130
checkForUpdate()
129131
.then((remotePackage) => {
130132
if (!remotePackage || (remotePackage.failedApply && syncOptions.ignoreFailedUpdates)) {
131-
resolve(CodePush.SyncStatus.NO_UPDATE_AVAILABLE);
133+
resolve(CodePush.SyncStatus.UP_TO_DATE);
132134
}
133135
else {
134136
var message = null;
@@ -138,9 +140,11 @@ function sync(options = {}) {
138140
onPress: () => {
139141
remotePackage.download()
140142
.then((localPackage) => {
141-
resolve(CodePush.SyncStatus.UPDATE_DOWNLOADED);
142-
localPackage.apply(syncOptions.rollbackTimeout);
143-
}, reject);
143+
resolve(CodePush.SyncStatus.UPDATE_APPLIED)
144+
return localPackage.apply(syncOptions.rollbackTimeout);
145+
})
146+
.catch(reject)
147+
.done();
144148
}
145149
}
146150
];
@@ -162,13 +166,15 @@ function sync(options = {}) {
162166

163167
// If the update has a description, and the developer
164168
// explicitly chose to display it, then set that as the message
165-
if (syncOptions.useReleaseDescription && remotePackage.description) {
166-
message = remotePackage.description;
169+
if (syncOptions.appendReleaseDescription && remotePackage.description) {
170+
message += `${syncOptions.descriptionPrefix} ${remotePackage.description}`;
167171
}
168172

169173
AlertIOS.alert(syncOptions.updateTitle, message, dialogButtons);
170174
}
171-
}, reject);
175+
})
176+
.catch(reject)
177+
.done();
172178
});
173179
};
174180

@@ -180,9 +186,9 @@ var CodePush = {
180186
setUpTestDependencies: setUpTestDependencies,
181187
sync: sync,
182188
SyncStatus: {
183-
NO_UPDATE_AVAILABLE: 0, // The running app is up-to-date
189+
UP_TO_DATE: 0, // The running app is up-to-date
184190
UPDATE_IGNORED: 1, // The app had an optional update and the end-user chose to ignore it
185-
UPDATE_DOWNLOADED: 2 // The app had an optional/mandatory update that was successfully downloaded and is about to be applied
191+
UPDATE_APPLIED: 2 // The app had an optional/mandatory update that was successfully downloaded and is about to be applied
186192
}
187193
};
188194

0 commit comments

Comments
 (0)