Skip to content

Commit 445083f

Browse files
committed
✨ Small fixes
1 parent 9e16fbf commit 445083f

6 files changed

Lines changed: 27 additions & 23 deletions

File tree

Loop/Config.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
// Created by Kai Azim on 2023-08-09.
66
//
77

8-
VERSION = 1.3.0
9-
BUILD_NUMBER = 1533
8+
VERSION = 0.0.0
9+
BUILD_NUMBER = 0

Loop/Settings Window/Loop/AboutConfiguration.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ struct AboutConfigurationView: View {
240240
LuminareSection {
241241
Button {
242242
Task {
243-
// Pass force=true to bypass the guard check
244-
await updater.fetchLatestInfo(force: true)
243+
await updater.fetchLatestInfo(bypassUpdatesEnabled: true)
245244

246245
switch updater.updateState {
247246
case .available:

Loop/Updater/UpdateChecker.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ actor UpdateChecker {
2020
.ignoresCase()
2121

2222
func checkForUpdate(
23-
bundleId: String,
2423
currentVersion: String,
2524
currentBuild: Int = 0,
2625
channel: UpdateChannel
2726
) async throws -> UpdateManifest? {
28-
log.info("Checking for updates: \(bundleId) v\(currentVersion) build \(currentBuild) [\(channel.rawValue)]")
27+
log.info("Checking for updates: \(currentVersion) build \(currentBuild) [\(channel.rawValue)]")
2928

3029
let endpoint = URL(string: channel.githubReleasesEndpoint)!
3130
var candidateRelease: GitHubRelease?
@@ -84,7 +83,7 @@ actor UpdateChecker {
8483
}
8584

8685
// Extract checksum from asset digest (format: "sha256:checksum")
87-
let zipChecksum = asset.digest?.replacingOccurrences(of: "sha256:", with: "") ?? ""
86+
let zipChecksum = asset.digest?.replacing(/sha256:/, with: "") ?? ""
8887
log.debug("Asset digest: \(asset.digest ?? "none"), extracted checksum: \(zipChecksum)")
8988

9089
let compatibility = extractCompatibilityRequirements(from: release.body)
@@ -113,7 +112,7 @@ actor UpdateChecker {
113112
// Verify system requirements before returning the manifest
114113
try verifySystemRequirements(manifest: manifest)
115114

116-
log.info("Found update: v\(manifest.version) (build \(manifest.buildNumber))")
115+
log.info("Found update: \(manifest.version) (\(manifest.buildNumber))")
117116
return manifest
118117
}
119118

Loop/Updater/Updater.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ final class Updater: ObservableObject {
8888
if !NSApp.isActive, NSApp.windows.allSatisfy({ !$0.isVisible }) {
8989
log.info("Automatic updates enabled, installing update...")
9090
Task {
91-
try await installUpdate()
91+
try await downloadAndInstallUpdate()
92+
await relaunchAfterUpdate()
9293
}
9394
}
9495

@@ -173,7 +174,7 @@ final class Updater: ObservableObject {
173174
}
174175

175176
// Pulls the latest release information from GitHub and updates the app state accordingly.
176-
func fetchLatestInfo(force: Bool = false) async {
177+
func fetchLatestInfo(bypassUpdatesEnabled: Bool = false) async {
177178
// Don't run update checks while actively downloading
178179
if downloader.isDownloading == true {
179180
return
@@ -194,8 +195,9 @@ final class Updater: ObservableObject {
194195
}
195196

196197
// Early return if updates are disabled and not forcing
197-
guard updatesEnabled || force else {
198+
guard updatesEnabled || bypassUpdatesEnabled else {
198199
updateState = .unavailable
200+
log.warn("Updates are disabled. Not fetching latest info.")
199201
return
200202
}
201203

@@ -210,7 +212,6 @@ final class Updater: ObservableObject {
210212
let currentBuild = Bundle.main.appBuild ?? 0
211213

212214
if let manifest = try await updateChecker.checkForUpdate(
213-
bundleId: Bundle.main.bundleIdentifier ?? "com.MrKai77.Loop",
214215
currentVersion: currentVersion,
215216
currentBuild: currentBuild,
216217
channel: channel
@@ -257,7 +258,7 @@ final class Updater: ObservableObject {
257258
}
258259

259260
// Downloads the update from GitHub and installs it
260-
func installUpdate() async throws {
261+
func downloadAndInstallUpdate() async throws {
261262
guard let manifest = updateManifest else {
262263
progressBar = 0
263264
return
@@ -293,9 +294,12 @@ final class Updater: ObservableObject {
293294
}
294295
}
295296

296-
func relaunchAfterUpdate() {
297-
Task {
298-
await installer.restartApplication()
297+
func relaunchAfterUpdate() async {
298+
guard installState == .readyToRestart else {
299+
log.error("Cannot restart as the install state is \(installState)")
300+
return
299301
}
302+
303+
await installer.restartApplication()
300304
}
301305
}

Loop/Updater/Views/UpdateView.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ struct UpdateView: View {
182182
Updater.shared.dismissWindow()
183183
} label: {
184184
Text(updater.installState.isFailure ? "Try again later" : "Remind me later")
185+
.contentTransition(.numericText())
185186
.padding(.trailing, 4)
186187
.luminarePopover(attachedTo: .topTrailing, hidden: updater.installState.errorDescription == nil) {
187188
HStack(spacing: 4) {
@@ -197,15 +198,16 @@ struct UpdateView: View {
197198
.padding(12)
198199
}
199200
}
201+
.disabled(updater.installState == .installing || updater.installState == .readyToRestart)
200202

201203
Button(role: updater.installState.isFailure ? .destructive : nil) {
202-
if updater.installState == .readyToRestart {
203-
Updater.shared.relaunchAfterUpdate()
204-
return
205-
}
206-
207204
Task {
208-
try? await Updater.shared.installUpdate()
205+
if updater.installState == .readyToRestart {
206+
await Updater.shared.relaunchAfterUpdate()
207+
return
208+
}
209+
210+
try await Updater.shared.downloadAndInstallUpdate()
209211
}
210212
} label: {
211213
ZStack {

Loop/Updater/Views/VersionDisplay.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct VersionDisplay {
3939
let buildString = if let build { "(\(build))" } else { "" }
4040

4141
let baseVersion = version
42-
.replacingOccurrences(of: devBuildEmoji, with: "")
42+
.replacing(devBuildEmoji, with: "")
4343
.trimmingCharacters(in: .whitespaces)
4444

4545
let shortDisplay: String = if shouldTreatAsPrerelease {

0 commit comments

Comments
 (0)