Skip to content

Commit

Permalink
git: Fixes progress notification bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bummoblizard committed Jan 22, 2024
1 parent 79e3278 commit 12940a8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CodeApp/Containers/SourceControlContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ struct SourceControlContainer: View {
App.loadFolder(url: dirURL)
}, primaryTitle: "common.open_folder", source: repo)
} catch {
progress.cancel()
let error = error as NSError
if error.code == LibGit2ErrorClass._GIT_ERROR_HTTP {
App.notificationManager.postActionNotification(
Expand Down
12 changes: 8 additions & 4 deletions CodeApp/Managers/FileSystem/Local/LocalGitServiceProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,20 @@ class LocalGitServiceProvider: GitServiceProvider {
let checkoutProgressBlock: CheckoutProgressBlock = { (message, current, total) in
DispatchQueue.main.async {
progress?.localizedDescription = "Updating files"
progress?.totalUnitCount = Int64(total)
progress?.fileOperationKind = .copying
progress?.completedUnitCount = Int64(current)
progress?.totalUnitCount = Int64(total)
}
}
let fetchProgressBlock: FetchProgressBlock = { current, total in
DispatchQueue.main.async {
progress?.localizedDescription = "Receiving objects"
progress?.fileOperationKind = .downloading
progress?.totalUnitCount = Int64(total)
progress?.completedUnitCount = Int64(current)
progress?.fileOperationKind = .receiving
if current != total {
// Avoid triggering isFinished
progress?.completedUnitCount = Int64(current)
progress?.totalUnitCount = Int64(total)
}
}
}
if let credentials = try? self.credentialsHelper.credentialsForRemoteURL(url: from) {
Expand Down
2 changes: 1 addition & 1 deletion CodeApp/Views/NotificationCentreView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private struct NotificationItemWtihProgress: View {
}
}
.onReceive(timer) { _ in
if data.progress!.isFinished {
if data.progress!.isCancelled || data.progress!.isFinished {
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
withAnimation {
isRemoved = true
Expand Down

0 comments on commit 12940a8

Please sign in to comment.