Skip to content

Commit

Permalink
Merge pull request #147 from kishikawakatsumi/fix
Browse files Browse the repository at this point in the history
Fixed a problem with sharing distinction during reloading.
  • Loading branch information
kishikawakatsumi authored Sep 22, 2024
2 parents e20c9e9 + cc75521 commit 8cb278a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Examples/FileBrowser/FileBrowser (macOS)/FileTransfer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ class FileUpload: FileTransfer {
NotificationCenter.default.post(
name: Self.didFinish,
object: self,
userInfo: [FileUploadUserInfoKey.path: destination]
userInfo: [
FileUploadUserInfoKey.share: client.share ?? "",
FileUploadUserInfoKey.path: destination,
]
)
}
} catch {
Expand All @@ -116,5 +119,6 @@ struct FileUploadUserInfoKey: Hashable, Equatable, RawRepresentable {
}

extension FileUploadUserInfoKey {
static let share = FileUploadUserInfoKey(rawValue: "share")
static let path = FileUploadUserInfoKey(rawValue: "path")
}
20 changes: 18 additions & 2 deletions Examples/FileBrowser/FileBrowser (macOS)/FilesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ class FilesViewController: NSViewController {
let dirTree = self.dirTree

tabGroupObserving?.invalidate()
tabGroupObserving = tabGroup.observe(\.selectedWindow) { (tabGroup, change) in
tabGroupObserving = tabGroup.observe(\.selectedWindow) { [weak self] (tabGroup, change) in
guard let self = self else { return }
if window == tabGroup.selectedWindow {
dirTree.update(outlineView)
self.updateItemCount()
}
}
}
Expand Down Expand Up @@ -185,10 +187,24 @@ class FilesViewController: NSViewController {
guard self == navigationController()?.topViewController else {
return
}
guard let share = userInfo[FileUploadUserInfoKey.share] as? String, share == self.share else {
return
}

let dirname = dirname(effectPath)
Task {
if let node = dirTree.node(ID(dirname)) {
guard outlineView.isItemExpanded(node) else {
return
}
} else {
guard dirname == path else {
return
}
}

Task { @MainActor in
await dirTree.reload(directory: dirname, outlineView)
updateItemCount()
}
}

Expand Down

0 comments on commit 8cb278a

Please sign in to comment.