mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
[WIP] General UI improvements
This commit is contained in:
@@ -3,20 +3,24 @@ import Postbox
|
||||
public final class ImportableDeviceContactData: Equatable, PostboxCoding {
|
||||
public let firstName: String
|
||||
public let lastName: String
|
||||
public let localIdentifiers: [String]
|
||||
|
||||
public init(firstName: String, lastName: String) {
|
||||
public init(firstName: String, lastName: String, localIdentifiers: [String]) {
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.localIdentifiers = localIdentifiers
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.firstName = decoder.decodeStringForKey("f", orElse: "")
|
||||
self.lastName = decoder.decodeStringForKey("l", orElse: "")
|
||||
self.localIdentifiers = decoder.decodeStringArrayForKey("dis")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.firstName, forKey: "f")
|
||||
encoder.encodeString(self.lastName, forKey: "l")
|
||||
encoder.encodeStringArray(self.localIdentifiers, forKey: "dis")
|
||||
}
|
||||
|
||||
public static func ==(lhs: ImportableDeviceContactData, rhs: ImportableDeviceContactData) -> Bool {
|
||||
@@ -26,6 +30,9 @@ public final class ImportableDeviceContactData: Equatable, PostboxCoding {
|
||||
if lhs.lastName != rhs.lastName {
|
||||
return false
|
||||
}
|
||||
if lhs.localIdentifiers != rhs.localIdentifiers {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import Postbox
|
||||
|
||||
public enum TelegramDeviceContactImportedData: PostboxCoding {
|
||||
case imported(data: ImportableDeviceContactData, importedByCount: Int32)
|
||||
case imported(data: ImportableDeviceContactData, importedByCount: Int32, peerId: PeerId?)
|
||||
case retryLater
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
switch decoder.decodeInt32ForKey("_t", orElse: 0) {
|
||||
case 0:
|
||||
self = .imported(data: decoder.decodeObjectForKey("d", decoder: { ImportableDeviceContactData(decoder: $0) }) as! ImportableDeviceContactData, importedByCount: decoder.decodeInt32ForKey("c", orElse: 0))
|
||||
self = .imported(data: decoder.decodeObjectForKey("d", decoder: { ImportableDeviceContactData(decoder: $0) }) as! ImportableDeviceContactData, importedByCount: decoder.decodeInt32ForKey("c", orElse: 0), peerId: decoder.decodeOptionalInt64ForKey("pid").flatMap(PeerId.init))
|
||||
case 1:
|
||||
self = .retryLater
|
||||
default:
|
||||
@@ -18,10 +18,15 @@ public enum TelegramDeviceContactImportedData: PostboxCoding {
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
switch self {
|
||||
case let .imported(data, importedByCount):
|
||||
case let .imported(data, importedByCount, peerId):
|
||||
encoder.encodeInt32(0, forKey: "_t")
|
||||
encoder.encodeObject(data, forKey: "d")
|
||||
encoder.encodeInt32(importedByCount, forKey: "c")
|
||||
if let peerId = peerId {
|
||||
encoder.encodeInt64(peerId.toInt64(), forKey: "pid")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "pid")
|
||||
}
|
||||
case .retryLater:
|
||||
encoder.encodeInt32(1, forKey: "_t")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user