Refactoring [skip ci]

This commit is contained in:
Ali
2023-04-19 23:47:38 +04:00
parent 61b95461d5
commit 6a548e11a6
277 changed files with 613 additions and 19657 deletions

View File

@@ -389,7 +389,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
}
}
public final class TelegramMediaAction: Media {
public final class TelegramMediaAction: Media, Equatable {
public let id: MediaId? = nil
public var peerIds: [PeerId] {
return self.action.peerIds
@@ -416,6 +416,10 @@ public final class TelegramMediaAction: Media {
self.action.encode(encoder)
}
public static func ==(lhs: TelegramMediaAction, rhs: TelegramMediaAction) -> Bool {
return lhs.isEqual(to: rhs)
}
public func isEqual(to other: Media) -> Bool {
if let other = other as? TelegramMediaAction {
return self.action == other.action

View File

@@ -1,6 +1,6 @@
import Postbox
public final class TelegramMediaContact: Media {
public final class TelegramMediaContact: Media, Equatable {
public let id: MediaId? = nil
public let firstName: String
public let lastName: String
@@ -51,6 +51,10 @@ public final class TelegramMediaContact: Media {
}
}
public static func ==(lhs: TelegramMediaContact, rhs: TelegramMediaContact) -> Bool {
return lhs.isEqual(to: rhs)
}
public func isEqual(to other: Media) -> Bool {
if let other = other as? TelegramMediaContact {
if self.id == other.id && self.firstName == other.firstName && self.lastName == other.lastName && self.phoneNumber == other.phoneNumber && self.peerId == other.peerId && self.vCardData == other.vCardData && self.peerIds == other.peerIds {
@@ -63,4 +67,4 @@ public final class TelegramMediaContact: Media {
public func isSemanticallyEqual(to other: Media) -> Bool {
return self.isEqual(to: other)
}
}
}

View File

@@ -1,6 +1,6 @@
import Postbox
public final class TelegramMediaDice: Media {
public final class TelegramMediaDice: Media, Equatable {
public let emoji: String
public let value: Int32?
@@ -26,6 +26,10 @@ public final class TelegramMediaDice: Media {
}
}
public static func ==(lhs: TelegramMediaDice, rhs: TelegramMediaDice) -> Bool {
return lhs.isEqual(to: rhs)
}
public func isEqual(to other: Media) -> Bool {
if let other = other as? TelegramMediaDice {
if self.emoji != other.emoji {

View File

@@ -6,7 +6,7 @@ public enum TelegramMediaExpiredContentData: Int32 {
case file
}
public final class TelegramMediaExpiredContent: Media {
public final class TelegramMediaExpiredContent: Media, Equatable {
public let data: TelegramMediaExpiredContentData
public let id: MediaId? = nil
@@ -24,6 +24,10 @@ public final class TelegramMediaExpiredContent: Media {
encoder.encodeInt32(self.data.rawValue, forKey: "d")
}
public static func ==(lhs: TelegramMediaExpiredContent, rhs: TelegramMediaExpiredContent) -> Bool {
return lhs.isEqual(to: rhs)
}
public func isEqual(to other: Media) -> Bool {
if let other = other as? TelegramMediaExpiredContent {
return self.data == other.data

View File

@@ -1,6 +1,6 @@
import Postbox
public final class TelegramMediaGame: Media {
public final class TelegramMediaGame: Media, Equatable {
public let gameId: Int64
public let accessHash: Int64
public let name: String
@@ -52,6 +52,10 @@ public final class TelegramMediaGame: Media {
}
}
public static func ==(lhs: TelegramMediaGame, rhs: TelegramMediaGame) -> Bool {
return lhs.isEqual(to: rhs)
}
public func isEqual(to other: Media) -> Bool {
guard let other = other as? TelegramMediaGame else {
return false

View File

@@ -87,7 +87,7 @@ public enum TelegramExtendedMedia: PostboxCoding, Equatable {
}
}
public final class TelegramMediaInvoice: Media {
public final class TelegramMediaInvoice: Media, Equatable {
public static let lastVersion: Int32 = 1
public var peerIds: [PeerId] = []
@@ -171,6 +171,10 @@ public final class TelegramMediaInvoice: Media {
encoder.encodeInt32(self.version, forKey: "vrs")
}
public static func ==(lhs: TelegramMediaInvoice, rhs: TelegramMediaInvoice) -> Bool {
return lhs.isEqual(to: rhs)
}
public func isEqual(to other: Media) -> Bool {
guard let other = other as? TelegramMediaInvoice else {
return false

View File

@@ -130,7 +130,7 @@ public final class MapVenue: PostboxCoding, Equatable {
}
}
public final class TelegramMediaMap: Media {
public final class TelegramMediaMap: Media, Equatable {
public let latitude: Double
public let longitude: Double
public let heading: Int32?
@@ -200,6 +200,10 @@ public final class TelegramMediaMap: Media {
}
}
public static func ==(lhs: TelegramMediaMap, rhs: TelegramMediaMap) -> Bool {
return lhs.isEqual(to: rhs)
}
public func isEqual(to other: Media) -> Bool {
if let other = other as? TelegramMediaMap {
if self.latitude != other.latitude || self.longitude != other.longitude {

View File

@@ -2,7 +2,7 @@ import Foundation
import Postbox
public final class TelegramMediaUnsupported: Media {
public final class TelegramMediaUnsupported: Media, Equatable {
public let id: MediaId? = nil
public let peerIds: [PeerId] = []
@@ -15,6 +15,10 @@ public final class TelegramMediaUnsupported: Media {
public func encode(_ encoder: PostboxEncoder) {
}
public static func ==(lhs: TelegramMediaUnsupported, rhs: TelegramMediaUnsupported) -> Bool {
return lhs.isEqual(to: rhs)
}
public func isEqual(to other: Media) -> Bool {
if other is TelegramMediaUnsupported {
return true