From 0322acd7f1dd825de519cb33cbfc679b2ff2de2b Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Fri, 16 Jul 2021 17:49:38 -0700 Subject: [PATCH] Auto select photo avatar --- SignalMessaging/utils/Avatars/AvatarModel.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/SignalMessaging/utils/Avatars/AvatarModel.swift b/SignalMessaging/utils/Avatars/AvatarModel.swift index e7556fa829..f4598395d9 100644 --- a/SignalMessaging/utils/Avatars/AvatarModel.swift +++ b/SignalMessaging/utils/Avatars/AvatarModel.swift @@ -44,6 +44,22 @@ public enum AvatarType: Equatable { case .text: return true } } + + public static func ==(lhs: AvatarType, rhs: AvatarType) -> Bool { + switch (lhs, rhs) { + case (.image(let lhs), .image(let rhs)): + // We implement a custom "Equatable", since two URLs + // are equatated with object equality, and even with + // the same URL treated as different objects with the + // compiler synthesized function. + return lhs.path == rhs.path + case (.icon(let lhs), .icon(let rhs)): + return lhs == rhs + case (.text(let lhs), .text(let rhs)): + return lhs == rhs + default: return false + } + } } public enum AvatarIcon: String, CaseIterable {