Prevent nodes from collapsing when refreshing
This commit is contained in:
parent
3e46c06ba8
commit
3a8088033a
|
@ -224,7 +224,7 @@
|
|||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1130;
|
||||
LastUpgradeCheck = 1130;
|
||||
LastUpgradeCheck = 1140;
|
||||
ORGANIZATIONNAME = Shadowfacts;
|
||||
TargetAttributes = {
|
||||
D63CDEB923C837DC0012D658 = {
|
||||
|
@ -418,6 +418,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = MongoView/MongoView.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
|
@ -439,6 +440,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = MongoView/MongoView.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
import Foundation
|
||||
import MongoSwift
|
||||
|
||||
class Node {
|
||||
// Node needs to be an NSObject, since NSOutlineView uses NSObject.isEqual(_:) and NSObject.hash to determine item equality
|
||||
// which is necessary to prevent items from collapsing when refreshing the view
|
||||
class Node: NSObject {
|
||||
let key: Key?
|
||||
let value: BSON
|
||||
weak var parent: Node?
|
||||
|
@ -57,10 +59,22 @@ class Node {
|
|||
self.init(key: nil, value: .document(document))
|
||||
}
|
||||
}
|
||||
|
||||
override func isEqual(_ object: Any?) -> Bool {
|
||||
guard let object = object as? Node else { return false }
|
||||
return self.parent == object.parent && self.key == object.key
|
||||
}
|
||||
|
||||
override var hash: Int {
|
||||
var hasher = Hasher()
|
||||
hasher.combine(parent)
|
||||
hasher.combine(key)
|
||||
return hasher.finalize()
|
||||
}
|
||||
}
|
||||
|
||||
extension Node {
|
||||
enum Key {
|
||||
enum Key: Equatable, Hashable {
|
||||
case index(Int)
|
||||
case name(String)
|
||||
case objectId(ObjectId)
|
||||
|
|
Loading…
Reference in New Issue