Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for 316 #360

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/upgrader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class Upgrader with WidgetsBindingObserver {
final response = await (iTunes
.lookupByBundleId(_packageInfo!.packageName, country: country));

if (response != null) {
if (response != null && response['resultCount'] > 0) {
Copy link
Owner

@larryaasen larryaasen Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this fix, thanks. However, there is more to this change than this. First, each place in the code where response is used is wrapped with try/catch, and in this case it was not. Secondly, the unit test mock response does not have resultCount so it would fail and should be updated.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another small note. The upgrader class does not know the internal details of the response. It just passes that to the ITunesSearchAPI class, so it would not be a good idea to access the internals of response inside _updateVersionInfo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long turn-around time. I took another look and have submitted a different way of solving the issue. In _decodeResults in ITunesSearchAPI the response may not contain any results. So instead of having other classes know about the internal, it seems like this is equivalent to returning null. This also works well since there are checks for whether the response is null or not.

_appStoreVersion = iTunes.version(response);
_appStoreListingURL = iTunes.trackViewUrl(response);
_releaseNotes ??= iTunes.releaseNotes(response);
Expand Down
Loading