Fixed a broken equality check

pull/894/head
Morgan Pretty 1 year ago
parent 33a3a42392
commit bd09db86fd

@ -19,7 +19,11 @@ public extension SessionCell {
} }
public func hash(into hasher: inout Hasher) {} public func hash(into hasher: inout Hasher) {}
public static func == (lhs: SessionCell.Accessory, rhs: SessionCell.Accessory) -> Bool { false } fileprivate func isEqual(to other: SessionCell.Accessory) -> Bool { return false }
public static func == (lhs: SessionCell.Accessory, rhs: SessionCell.Accessory) -> Bool {
return lhs.isEqual(to: rhs)
}
} }
} }
@ -207,13 +211,15 @@ public extension SessionCell.AccessoryConfig {
accessibility.hash(into: &hasher) accessibility.hash(into: &hasher)
} }
public static func == (lhs: Icon, rhs: Icon) -> Bool { override fileprivate func isEqual(to other: SessionCell.Accessory) -> Bool {
guard let rhs: Icon = other as? Icon else { return false }
return ( return (
lhs.image == rhs.image && image == rhs.image &&
lhs.iconSize == rhs.iconSize && iconSize == rhs.iconSize &&
lhs.customTint == rhs.customTint && customTint == rhs.customTint &&
lhs.shouldFill == rhs.shouldFill && shouldFill == rhs.shouldFill &&
lhs.accessibility == rhs.accessibility accessibility == rhs.accessibility
) )
} }
} }
@ -252,12 +258,14 @@ public extension SessionCell.AccessoryConfig {
accessibility.hash(into: &hasher) accessibility.hash(into: &hasher)
} }
public static func == (lhs: IconAsync, rhs: IconAsync) -> Bool { override fileprivate func isEqual(to other: SessionCell.Accessory) -> Bool {
guard let rhs: IconAsync = other as? IconAsync else { return false }
return ( return (
lhs.iconSize == rhs.iconSize && iconSize == rhs.iconSize &&
lhs.customTint == rhs.customTint && customTint == rhs.customTint &&
lhs.shouldFill == rhs.shouldFill && shouldFill == rhs.shouldFill &&
lhs.accessibility == rhs.accessibility accessibility == rhs.accessibility
) )
} }
} }
@ -289,11 +297,13 @@ public extension SessionCell.AccessoryConfig {
accessibility.hash(into: &hasher) accessibility.hash(into: &hasher)
} }
public static func == (lhs: Toggle, rhs: Toggle) -> Bool { override fileprivate func isEqual(to other: SessionCell.Accessory) -> Bool {
guard let rhs: Toggle = other as? Toggle else { return false }
return ( return (
lhs.value == rhs.value && value == rhs.value &&
lhs.oldValue == rhs.oldValue && oldValue == rhs.oldValue &&
lhs.accessibility == rhs.accessibility accessibility == rhs.accessibility
) )
} }
} }
@ -319,10 +329,12 @@ public extension SessionCell.AccessoryConfig {
accessibility.hash(into: &hasher) accessibility.hash(into: &hasher)
} }
public static func == (lhs: DropDown, rhs: DropDown) -> Bool { override fileprivate func isEqual(to other: SessionCell.Accessory) -> Bool {
guard let rhs: DropDown = other as? DropDown else { return false }
return ( return (
lhs.dynamicString() == rhs.dynamicString() && dynamicString() == rhs.dynamicString() &&
lhs.accessibility == rhs.accessibility accessibility == rhs.accessibility
) )
} }
} }
@ -380,12 +392,14 @@ public extension SessionCell.AccessoryConfig {
accessibility.hash(into: &hasher) accessibility.hash(into: &hasher)
} }
public static func == (lhs: Radio, rhs: Radio) -> Bool { override fileprivate func isEqual(to other: SessionCell.Accessory) -> Bool {
guard let rhs: Radio = other as? Radio else { return false }
return ( return (
lhs.size == rhs.size && size == rhs.size &&
lhs.initialIsSelected == rhs.initialIsSelected && initialIsSelected == rhs.initialIsSelected &&
lhs.wasSavedSelection == rhs.wasSavedSelection && wasSavedSelection == rhs.wasSavedSelection &&
lhs.accessibility == rhs.accessibility accessibility == rhs.accessibility
) )
} }
} }
@ -411,10 +425,14 @@ public extension SessionCell.AccessoryConfig {
accessibility.hash(into: &hasher) accessibility.hash(into: &hasher)
} }
public static func == (lhs: HighlightingBackgroundLabel, rhs: HighlightingBackgroundLabel) -> Bool { override fileprivate func isEqual(to other: SessionCell.Accessory) -> Bool {
guard let rhs: HighlightingBackgroundLabel = other as? HighlightingBackgroundLabel else {
return false
}
return ( return (
lhs.title == rhs.title && title == rhs.title &&
lhs.accessibility == rhs.accessibility accessibility == rhs.accessibility
) )
} }
} }
@ -468,17 +486,19 @@ public extension SessionCell.AccessoryConfig {
accessibility.hash(into: &hasher) accessibility.hash(into: &hasher)
} }
public static func == (lhs: DisplayPicture, rhs: DisplayPicture) -> Bool { override fileprivate func isEqual(to other: SessionCell.Accessory) -> Bool {
guard let rhs: DisplayPicture = other as? DisplayPicture else { return false }
return ( return (
lhs.id == rhs.id && id == rhs.id &&
lhs.size == rhs.size && size == rhs.size &&
lhs.threadVariant == rhs.threadVariant && threadVariant == rhs.threadVariant &&
lhs.displayPictureFilename == rhs.displayPictureFilename && displayPictureFilename == rhs.displayPictureFilename &&
lhs.profile == rhs.profile && profile == rhs.profile &&
lhs.profileIcon == rhs.profileIcon && profileIcon == rhs.profileIcon &&
lhs.additionalProfile == rhs.additionalProfile && additionalProfile == rhs.additionalProfile &&
lhs.additionalProfileIcon == rhs.additionalProfileIcon && additionalProfileIcon == rhs.additionalProfileIcon &&
lhs.accessibility == rhs.accessibility accessibility == rhs.accessibility
) )
} }
} }
@ -505,10 +525,11 @@ public extension SessionCell.AccessoryConfig {
accessibility.hash(into: &hasher) accessibility.hash(into: &hasher)
} }
public static func == (lhs: Search, rhs: Search) -> Bool { override fileprivate func isEqual(to other: SessionCell.Accessory) -> Bool {
return ( return (
lhs.placeholder == rhs.placeholder && other is Search &&
lhs.accessibility == rhs.accessibility placeholder == (other as? Search)?.placeholder &&
accessibility == (other as? Search)?.accessibility
) )
} }
} }
@ -539,11 +560,12 @@ public extension SessionCell.AccessoryConfig {
accessibility.hash(into: &hasher) accessibility.hash(into: &hasher)
} }
public static func == (lhs: Button, rhs: Button) -> Bool { override fileprivate func isEqual(to other: SessionCell.Accessory) -> Bool {
return ( return (
lhs.style == rhs.style && other is Button &&
lhs.title == rhs.title && style == (other as? Button)?.style &&
lhs.accessibility == rhs.accessibility title == (other as? Button)?.title &&
accessibility == (other as? Button)?.accessibility
) )
} }
} }
@ -570,10 +592,11 @@ public extension SessionCell.AccessoryConfig {
accessibility.hash(into: &hasher) accessibility.hash(into: &hasher)
} }
public static func == (lhs: CustomView, rhs: CustomView) -> Bool { override fileprivate func isEqual(to other: SessionCell.Accessory) -> Bool {
return ( return (
lhs.uniqueId == rhs.uniqueId && other is CustomView &&
lhs.accessibility == rhs.accessibility uniqueId == (other as? CustomView)?.uniqueId &&
accessibility == (other as? CustomView)?.accessibility
) )
} }
} }

Loading…
Cancel
Save