no message

This commit is contained in:
Peter 2016-10-09 21:56:47 +02:00
parent 760f58c6b1
commit 0d77ae68a9
4 changed files with 61 additions and 4 deletions

View File

@ -9,16 +9,35 @@ public final class CachedGroupData: CachedPeerData {
public let participants: CachedGroupParticipants?
public let exportedInvitation: ExportedInvitation?
public let peerIds: Set<PeerId> = Set<PeerId>()
public let peerIds: Set<PeerId>
public init(participants: CachedGroupParticipants?, exportedInvitation: ExportedInvitation?) {
self.participants = participants
self.exportedInvitation = exportedInvitation
if let participants = participants {
var peerIds = Set<PeerId>()
for participant in participants.participants {
peerIds.insert(participant.peerId)
}
self.peerIds = peerIds
} else {
self.peerIds = Set()
}
}
public init(decoder: Decoder) {
self.participants = decoder.decodeObjectForKey("p", decoder: { CachedGroupParticipants(decoder: $0) }) as? CachedGroupParticipants
let participants = decoder.decodeObjectForKey("p", decoder: { CachedGroupParticipants(decoder: $0) }) as? CachedGroupParticipants
self.participants = participants
self.exportedInvitation = decoder.decodeObjectForKey("i", decoder: { ExportedInvitation(decoder: $0) }) as? ExportedInvitation
if let participants = participants {
var peerIds = Set<PeerId>()
for participant in participants.participants {
peerIds.insert(participant.peerId)
}
self.peerIds = peerIds
} else {
self.peerIds = Set()
}
}
public func encode(_ encoder: Encoder) {

View File

@ -10,6 +10,17 @@ public enum GroupParticipant: Coding, Equatable {
case creator(id: PeerId)
case admin(id: PeerId, invitedBy: PeerId, invitedAt: Int32)
public var peerId: PeerId {
switch self {
case let .member(id, _, _):
return id
case let .creator(id):
return id
case let .admin(id, _, _):
return id
}
}
public init(decoder: Decoder) {
switch decoder.decodeInt32ForKey("v") as Int32 {
case 0:
@ -66,7 +77,7 @@ public enum GroupParticipant: Coding, Equatable {
}
public final class CachedGroupParticipants: Coding, Equatable {
let participants: [GroupParticipant]
public let participants: [GroupParticipant]
let version: Int32
init(participants: [GroupParticipant], version: Int32) {

View File

@ -90,6 +90,25 @@ public func mergeListsStableWithUpdates<T>(leftList: [T], rightList: [T]) -> ([I
var insertItems: [(Int, T, Int?)] = []
var updatedIndices: [(Int, T, Int)] = []
#if (arch(i386) || arch(x86_64)) && os(iOS)
var existingStableIds: [T.T: T] = [:]
for item in leftList {
if let other = existingStableIds[item.stableId] {
assertionFailure()
} else {
existingStableIds[item.stableId] = item
}
}
existingStableIds.removeAll()
for item in rightList {
if let other = existingStableIds[item.stableId] {
assertionFailure()
} else {
existingStableIds[item.stableId] = item
}
}
#endif
var currentList = leftList
/*print("-----------")
@ -253,7 +272,7 @@ public func mergeListsStableWithUpdates<T>(leftList: [T], rightList: [T]) -> ([I
/*if currentList != rightList {
for l in 0 ..< currentList.count {
if currentList[l] != rightList[l] {
print("here")
print("here \(currentList[l]) != \(rightList[l])")
}
}
}*/

View File

@ -716,6 +716,14 @@ private func finalStateWithUpdates(account: Account, state: MutableState, update
default:
break
}
case let .updateChatParticipants(participants):
break
case let .updateChatParticipantAdd(chatId, userId, inviterId, date, version):
break
case let .updateChatParticipantDelete(chatId, userId, version):
break
case let .updateChatParticipantAdmin(chatId, userId, isAdmin, version):
break
default:
break
}