Skip to content

Commit

Permalink
kram-profile - re-enable mergeFiles if option held
Browse files Browse the repository at this point in the history
Instead of wiping the list, this combines the lists into one.  Useful for opening or drag/drop multiple archives.
  • Loading branch information
alecazam committed Mar 17, 2024
1 parent b536046 commit c7ba9f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
7 changes: 6 additions & 1 deletion kram-profile/kram-profile/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum FileType {
case Unknown
}

class File: Identifiable, /*Hashable, */ Equatable, Comparable
class File: Identifiable, Hashable, Equatable, Comparable
{
// TODO: archive url relative to archive so not unqique if multiple archives dropped
// but currently all lookup is by url, and not url + archive. Just make sure to
Expand Down Expand Up @@ -69,6 +69,11 @@ class File: Identifiable, /*Hashable, */ Equatable, Comparable
return lhs.id < rhs.id
}

// Hashable
public func hash(into hasher: inout Hasher) {
hasher.combine(id)
}

// call this when the file is loaded
public func setLoadStamp() {
loadStamp = modStamp
Expand Down
16 changes: 8 additions & 8 deletions kram-profile/kram-profile/kram_profileApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1678,16 +1678,16 @@ struct kram_profileApp: App {
// for now wipe the old list
if filesNew.count > 0 {
// turning this off for now, File must impl Hashable
// let mergeFiles = false
//
// if mergeFiles {
// fileSearcher.files = Array(Set(fileSearcher.files + filesNew))
// }
// else
//{
let mergeFiles = NSEvent.modifierFlags.contains(.option);

if mergeFiles {
fileSearcher.files = Array(Set(fileSearcher.files + filesNew))
}
else
{
// reset the list
fileSearcher.files = filesNew
//}
}

fileSearcher.updateFilesSorted()

Expand Down

0 comments on commit c7ba9f5

Please sign in to comment.