You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
getLatest throws an error if no new version exists. To distinguish between a "real" error only the message can be used. So this is what I currently do:
try {
newVersionBundle = await CapacitorUpdater.getLatest();
} catch (e) {
// bail out if no new version is available
if (e.message === 'No new version available') {
return;
}
me.sendUpdateFailMetric(`Retrieving the new version info failed: ${e.message}`);
return;
}
But checking against a message string that might change any time if very fragile.
Preferred Solution
The preferred solution would be another function like checkForUpdates that returns true if a new update is available. Or that the errors returned by getLatest will have a status code which I can check against.
The text was updated successfully, but these errors were encountered:
getLatest implies that simply the latest update is retrieved and not that it is checked against the current version. Making it clearer in the docs that this method uses the installed version to check if a new version is available will be a huge help.
Also I think the error codes would not be needed if the promise would simly not reject. The promise should only reject if something failed, that no new version is available is no reason to reject the promise. To indicate that no new version is available a flag noNewVersion could be used.
I you dont agree an error code would also be sufficient.
Note this is a breaking change from older versions. It used to allow you to return just a "message" key from the server and would mark it as no updates required if no url/version key.
Feature Request
Description
getLatest throws an error if no new version exists. To distinguish between a "real" error only the message can be used. So this is what I currently do:
But checking against a message string that might change any time if very fragile.
Preferred Solution
The preferred solution would be another function like
checkForUpdates
that returns true if a new update is available. Or that the errors returned bygetLatest
will have a status code which I can check against.The text was updated successfully, but these errors were encountered: