Skip to content

Commit

Permalink
[Apps] Set offline status on error
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfreeman committed Jun 10, 2024
1 parent 42ec2b1 commit edcd4b6
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Flipper/Packages/Core/Sources/Applications/Applications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,8 @@ public class Applications: ObservableObject {

installed = []
statuses = [:]
for await var app in try await flipperApps.load() {
// TODO: Cache categories to show without internet connection
app.category = category(name: app.category.name)
installed.append(app)
setStatus(.checking, for: app)
for await app in try await flipperApps.load() {
await appendInstalled(app)
}

if installedStatus == .loading {
Expand All @@ -395,6 +392,18 @@ public class Applications: ObservableObject {
}
}

private func appendInstalled(_ app: Application) async {
// TODO: Cache categories to show without internet connection
var app = app
app.category = category(name: app.category.name)
installed.append(app)
if categories.isEmpty {
setStatus(await offlineStatus(for: app), for: app)
} else {
setStatus(.checking, for: app)
}
}

private func runUpdater(deviceInfo: DeviceInfo) async {
var checking: [Application] {
installed.filter { statuses[$0.id] == .checking }
Expand Down

0 comments on commit edcd4b6

Please sign in to comment.