Skip to content

Commit

Permalink
Change the update log acquisition logic
Browse files Browse the repository at this point in the history
  • Loading branch information
wwg135 authored Aug 16, 2023
1 parent 3003941 commit 0eb16fd
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions Dopamine/Dopamine/UI/Views/JailbreakView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,15 @@ struct JailbreakView: View {
}
}
}
if checkForUpdates {
Task {
do {
Task {
do {
try await allUpdatelog()

if checkForUpdates {
try await checkForUpdates()
} catch {
Logger.log(error, type: .error, isStatus: false)
}
} catch {
Logger.log(error, type: .error, isStatus: false)
}
}
}
Expand Down Expand Up @@ -566,19 +568,32 @@ struct JailbreakView: View {
guard let releasesJSON = try JSONSerialization.jsonObject(with: releasesData, options: []) as? [[String: Any]] else {
return
}


//updateAvailable is not true
if let latest = releasesJSON.first(where: { $0["name"] as? String != "1.0.5" }) {
if let latestName = latest["tag_name"] as? String,
let latestVersion = latest["name"] as? String,
latestName != currentAppVersion && latestVersion != "1.0.5" {
updateAvailable = true
}
}

if checkForUpdates {
updateChangelog = createUserOrientedChangelog(deltaChangelog: getDeltaChangelog(json: releasesJSON), environmentMismatch: false)
}

func allUpdatelog() async throws {
let owner = "wwg135"
let repo = "Dopamine"

// Get the releases
let releasesURL = URL(string: "https://api.github.com/repos/\(owner)/\(repo)/releases")!
let releasesRequest = URLRequest(url: releasesURL)
let (releasesData, _) = try await URLSession.shared.data(for: releasesRequest)
guard let releasesJSON = try JSONSerialization.jsonObject(with: releasesData, options: []) as? [[String: Any]] else {
return
}

//get the updateChangelog
updateChangelog = createUserOrientedChangelog(deltaChangelog: getDeltaChangelog(json: releasesJSON), environmentMismatch: false)

if isInstalledEnvironmentVersionMismatching() {
mismatchChangelog = createUserOrientedChangelog(deltaChangelog: getDeltaChangelog(json: releasesJSON), environmentMismatch: true)
}
Expand Down

0 comments on commit 0eb16fd

Please sign in to comment.