Skip to content

Commit

Permalink
Ignore prereleases when checking for updates
Browse files Browse the repository at this point in the history
  • Loading branch information
opa334 committed Apr 30, 2024
1 parent 278fe3f commit 845c6f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Application/Dopamine/UI/DOUIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSArray *)getLatestReleases;
- (NSString*)getLaunchedReleaseTag;
- (NSString*)getLatestReleaseTag;
- (NSArray *)getUpdatesInRange: (NSString *)start end: (NSString *)end;
- (NSArray *)getUpdatesInRange:(NSString *)start end:(NSString *)end;
- (bool)launchedReleaseNeedsManualUpdate;
- (NSArray*)availablePackageManagers;
- (NSArray*)enabledPackageManagerKeys;
Expand Down
24 changes: 15 additions & 9 deletions Application/Dopamine/UI/DOUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ - (id)init

- (BOOL)isUpdateAvailable
{
NSArray *releases = [self getLatestReleases];
if (releases.count == 0)
return NO;

NSString *latestVersion = releases[0][@"tag_name"];
NSString *latestVersion = [self getLatestReleaseTag];
NSString *currentVersion = [self getLaunchedReleaseTag];
return [self numericalRepresentationForVersion:latestVersion] > [self numericalRepresentationForVersion:currentVersion];
}
Expand All @@ -55,7 +51,7 @@ - (long long)numericalRepresentationForVersion:(NSString*)version {
return numericalRepresentation;
}

- (NSArray *)getUpdatesInRange: (NSString *)start end: (NSString *)end
- (NSArray *)getUpdatesInRange:(NSString *)start end:(NSString *)end
{
NSArray *releases = [self getLatestReleases];
if (releases.count == 0)
Expand All @@ -66,6 +62,11 @@ - (NSArray *)getUpdatesInRange: (NSString *)start end: (NSString *)end
NSMutableArray *updates = [NSMutableArray new];
for (NSDictionary *release in releases) {
NSString *version = release[@"tag_name"];
NSNumber *prerelease = release[@"prerelease"];
if ([prerelease boolValue]) {
// Skip prereleases
continue;
}
long long numericalVersion = [self numericalRepresentationForVersion:version];
if (numericalVersion > startVersion && numericalVersion <= endVersion) {
[updates addObject:release];
Expand Down Expand Up @@ -121,9 +122,14 @@ - (bool)launchedReleaseNeedsManualUpdate
- (NSString*)getLatestReleaseTag
{
NSArray *releases = [self getLatestReleases];
if (releases.count == 0)
return nil;
return releases[0][@"tag_name"];
for (NSDictionary *release in releases) {
NSNumber *prerelease = release[@"prerelease"];
if ([prerelease boolValue]) {
continue;
}
return release[@"tag_name"];
}
return nil;
}

- (NSString*)getLaunchedReleaseTag
Expand Down

0 comments on commit 845c6f7

Please sign in to comment.