no message

This commit is contained in:
Peter 2017-01-31 18:07:58 +03:00
parent bf311fed75
commit eaa061add0
17 changed files with 5705 additions and 4430 deletions

View File

@ -261,6 +261,10 @@
D0BC386E1E3FDAB70044D6FE /* CreateGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BC386D1E3FDAB70044D6FE /* CreateGroup.swift */; };
D0BC38701E40853E0044D6FE /* UpdatePeers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BC386F1E40853E0044D6FE /* UpdatePeers.swift */; };
D0BC38751E40A7F70044D6FE /* RemovePeerChat.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BC38741E40A7F70044D6FE /* RemovePeerChat.swift */; };
D0BC38771E40BAAA0044D6FE /* ManagedSynchronizePinnedChatsOperations.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BC38761E40BAAA0044D6FE /* ManagedSynchronizePinnedChatsOperations.swift */; };
D0BC38791E40BAF20044D6FE /* SynchronizePinnedChatsOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BC38781E40BAF20044D6FE /* SynchronizePinnedChatsOperation.swift */; };
D0BC387B1E40D2880044D6FE /* TogglePeerChatPinned.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BC387A1E40D2880044D6FE /* TogglePeerChatPinned.swift */; };
D0BC387C1E40D2880044D6FE /* TogglePeerChatPinned.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BC387A1E40D2880044D6FE /* TogglePeerChatPinned.swift */; };
D0CAF2EA1D75EC600011F558 /* MtProtoKitDynamic.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0CAF2E91D75EC600011F558 /* MtProtoKitDynamic.framework */; };
D0DC354E1DE368F7000195EB /* RequestChatContextResults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0DC354D1DE368F7000195EB /* RequestChatContextResults.swift */; };
D0DC35501DE36900000195EB /* ChatContextResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0DC354F1DE36900000195EB /* ChatContextResult.swift */; };
@ -493,6 +497,9 @@
D0BC386D1E3FDAB70044D6FE /* CreateGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreateGroup.swift; sourceTree = "<group>"; };
D0BC386F1E40853E0044D6FE /* UpdatePeers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdatePeers.swift; sourceTree = "<group>"; };
D0BC38741E40A7F70044D6FE /* RemovePeerChat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemovePeerChat.swift; sourceTree = "<group>"; };
D0BC38761E40BAAA0044D6FE /* ManagedSynchronizePinnedChatsOperations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManagedSynchronizePinnedChatsOperations.swift; sourceTree = "<group>"; };
D0BC38781E40BAF20044D6FE /* SynchronizePinnedChatsOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SynchronizePinnedChatsOperation.swift; sourceTree = "<group>"; };
D0BC387A1E40D2880044D6FE /* TogglePeerChatPinned.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TogglePeerChatPinned.swift; sourceTree = "<group>"; };
D0CAF2E91D75EC600011F558 /* MtProtoKitDynamic.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MtProtoKitDynamic.framework; path = "../../../../Library/Developer/Xcode/DerivedData/Telegram-iOS-diblohvjozhgaifjcniwdlixlilx/Build/Products/Debug-iphonesimulator/MtProtoKitDynamic.framework"; sourceTree = "<group>"; };
D0DC354D1DE368F7000195EB /* RequestChatContextResults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestChatContextResults.swift; sourceTree = "<group>"; };
D0DC354F1DE36900000195EB /* ChatContextResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatContextResult.swift; sourceTree = "<group>"; };
@ -739,6 +746,8 @@
D0AAD1B71E326FE200D5B9DE /* ManagedAutoremoveMessageOperations.swift */,
D00D97C91E32917C00E5C2B6 /* PeerInputActivityManager.swift */,
D0AB0B991D666520002C78E7 /* ManagedSynchronizePeerReadStates.swift */,
D0BC38781E40BAF20044D6FE /* SynchronizePinnedChatsOperation.swift */,
D0BC38761E40BAAA0044D6FE /* ManagedSynchronizePinnedChatsOperations.swift */,
);
name = State;
sourceTree = "<group>";
@ -932,6 +941,7 @@
D07827BA1E00451F00071108 /* SearchPeers.swift */,
D0BC386D1E3FDAB70044D6FE /* CreateGroup.swift */,
D0BC38741E40A7F70044D6FE /* RemovePeerChat.swift */,
D0BC387A1E40D2880044D6FE /* TogglePeerChatPinned.swift */,
);
name = Peers;
sourceTree = "<group>";
@ -1191,6 +1201,7 @@
D0448C991E268F9A005A61A7 /* SecretApiLayer46.swift in Sources */,
D003702B1DA42586004308D3 /* PhoneNumber.swift in Sources */,
D03B0CF91D62250800955575 /* TelegramMediaMap.swift in Sources */,
D0BC38791E40BAF20044D6FE /* SynchronizePinnedChatsOperation.swift in Sources */,
D03B0D671D631A8B00955575 /* AccountViewTracker.swift in Sources */,
D0B843BB1DA7FF30005F29E1 /* NBMetadataCoreTestMapper.m in Sources */,
D03B0D101D62255C00955575 /* UpdatesApiUtils.swift in Sources */,
@ -1212,11 +1223,13 @@
D0448CA21E291B14005A61A7 /* FetchSecretFileResource.swift in Sources */,
D00C7CCC1E3620C30080C3D5 /* CachedChannelParticipants.swift in Sources */,
D09BB6B41DB02C2B00A905C0 /* PendingMessageManager.swift in Sources */,
D0BC387B1E40D2880044D6FE /* TogglePeerChatPinned.swift in Sources */,
D0448C8E1E22993C005A61A7 /* ProcessSecretChatIncomingDecryptedOperations.swift in Sources */,
D0448C911E251F96005A61A7 /* SecretChatEncryption.swift in Sources */,
D0FA8BA11E1F99E1001E855B /* SecretChatFileReference.swift in Sources */,
D07827BB1E00451F00071108 /* SearchPeers.swift in Sources */,
D0DC354E1DE368F7000195EB /* RequestChatContextResults.swift in Sources */,
D0BC38771E40BAAA0044D6FE /* ManagedSynchronizePinnedChatsOperations.swift in Sources */,
D0B843851DA6EDC4005F29E1 /* CachedChannelData.swift in Sources */,
D0B843831DA6EDB8005F29E1 /* CachedGroupData.swift in Sources */,
D0E35A121DE4A25E00BC6096 /* OutgoingChatContextResultMessageAttribute.swift in Sources */,
@ -1371,6 +1384,7 @@
D001F3EF1E128A1C007A8C60 /* AccountIntermediateState.swift in Sources */,
D00C7CCD1E3620C30080C3D5 /* CachedChannelParticipants.swift in Sources */,
D03C536E1DAD5CA9004C17B3 /* PhoneNumber.swift in Sources */,
D0BC387C1E40D2880044D6FE /* TogglePeerChatPinned.swift in Sources */,
D0B844111DAB91CD005F29E1 /* Regex.swift in Sources */,
D0B844321DAB91E0005F29E1 /* NBPhoneMetaDataGenerator.m in Sources */,
D073CEA41DCBF3EA007511FD /* MultipartUpload.swift in Sources */,

View File

@ -266,6 +266,7 @@ private var declaredEncodables: Void = {
declareEncodable(AutoremoveTimeoutMessageAttribute.self, f: { AutoremoveTimeoutMessageAttribute(decoder: $0) })
declareEncodable(GlobalNotificationSettings.self, f: { GlobalNotificationSettings(decoder: $0) })
declareEncodable(CloudChatRemoveChatOperation.self, f: { CloudChatRemoveChatOperation(decoder: $0) })
declareEncodable(SynchronizePinnedChatsOperation.self, f: { SynchronizePinnedChatsOperation(decoder: $0) })
return
}()
@ -484,7 +485,7 @@ public class Account {
appSandbox = .boolTrue
#endif
return network.request(Api.functions.account.registerDevice(tokenType: 1, token: tokenString, deviceModel: "iPhone Simulator", systemVersion: systemVersion, appVersion: appVersionString, appSandbox: appSandbox, langCode: langCode))
return network.request(Api.functions.account.registerDevice(tokenType: 1, token: tokenString, deviceModel: "iPhone Simulator", systemVersion: systemVersion, appVersion: appVersionString, appSandbox: appSandbox))
|> retryRequest
|> mapToSignal { _ -> Signal<Void, NoError> in
return .complete()
@ -519,7 +520,7 @@ public class Account {
appSandbox = .boolTrue
#endif
return network.request(Api.functions.account.registerDevice(tokenType: 9, token: tokenString, deviceModel: "iPhone Simulator", systemVersion: systemVersion, appVersion: appVersionString, appSandbox: appSandbox, langCode: langCode))
return network.request(Api.functions.account.registerDevice(tokenType: 9, token: tokenString, deviceModel: "iPhone Simulator", systemVersion: systemVersion, appVersion: appVersionString, appSandbox: appSandbox))
|> retryRequest
|> mapToSignal { _ -> Signal<Void, NoError> in
return .complete()
@ -565,6 +566,7 @@ public class Account {
self.managedOperationsDisposable.add(managedCloudChatRemoveMessagesOperations(postbox: self.postbox, network: self.network, stateManager: self.stateManager).start())
self.managedOperationsDisposable.add(managedAutoremoveMessageOperations(postbox: self.postbox).start())
self.managedOperationsDisposable.add(managedGlobalNotificationSettings(postbox: self.postbox, network: self.network).start())
self.managedOperationsDisposable.add(managedSynchronizePinnedChatsOperations(postbox: self.postbox, network: self.network, stateManager: self.stateManager).start())
let updatedPresence = self.shouldKeepOnlinePresence.get()
|> distinctUntilChanged

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ private func md5(_ data : Data) -> Data {
}
private func updatedRemoteContactPeers(network: Network, hash: String) -> Signal<([Peer], [PeerId: PeerPresence])?, NoError> {
return network.request(Api.functions.contacts.getContacts(nHash: hash))
return network.request(Api.functions.contacts.getContacts(hash: hash))
|> retryRequest
|> map { result -> ([Peer], [PeerId: PeerPresence])? in
switch result {

View File

@ -157,7 +157,7 @@ func fetchChatListHole(network: Network, postbox: Postbox, hole: ChatListHole) -
}
return offset
|> mapToSignal { (timestamp, id, peer) in
return network.request(Api.functions.messages.getDialogs(offsetDate: timestamp, offsetId: id, offsetPeer: peer, limit: 100))
return network.request(Api.functions.messages.getDialogs(flags: 0, offsetDate: timestamp, offsetId: id, offsetPeer: peer, limit: 100))
|> retryRequest
|> mapToSignal { result -> Signal<Void, NoError> in
let dialogsChats: [Api.Chat]

View File

@ -441,7 +441,7 @@ extension InstantPageBlock {
case let .pageBlockSubtitle(text):
self = .subtitle(RichText(apiText: text))
case let .pageBlockAuthorDate(author, publishedDate):
self = .authorDate(author: .plain(author), date: publishedDate)
self = .authorDate(author: RichText(apiText: author), date: publishedDate)
case let .pageBlockHeader(text):
self = .header(RichText(apiText: text))
case let .pageBlockSubheader(text):
@ -468,8 +468,8 @@ extension InstantPageBlock {
self = .video(id: MediaId(namespace: Namespaces.Media.CloudVideo, id: videoId), caption: RichText(apiText: caption), autoplay: (flags & (1 << 0)) != 0, loop: (flags & (1 << 1)) != 0)
case let .pageBlockCover(cover):
self = .cover(InstantPageBlock(apiBlock: cover))
case let .pageBlockEmbed(flags, url, html, w, h, caption):
self = .webEmbed(url: url, html: html, dimensions: CGSize(width: CGFloat(w), height: CGFloat(h)), caption: RichText(apiText: caption), stretchToWidth: (flags & (1 << 0)) != 0, allowScrolling: (flags & (1 << 3)) != 0)
case let .pageBlockEmbed(flags, url, html, posterPhotoId, w, h, caption):
self = .webEmbed(url: url, html: html, dimensions: CGSize(width: CGFloat(w ?? 0), height: CGFloat(h ?? 0)), caption: RichText(apiText: caption), stretchToWidth: (flags & (1 << 0)) != 0, allowScrolling: (flags & (1 << 3)) != 0)
case let .pageBlockEmbedPost(url, webpageId, authorPhotoId, author, date, blocks, caption):
self = .postEmbed(url: url, webpageId: webpageId == 0 ? nil : MediaId(namespace: Namespaces.Media.CloudWebpage, id: webpageId), avatarId: authorPhotoId == 0 ? nil : MediaId(namespace: Namespaces.Media.CloudImage, id: authorPhotoId), author: author, date: date, blocks: blocks.map({ InstantPageBlock(apiBlock: $0) }), caption: RichText(apiText: caption))
case let .pageBlockCollage(items, caption):

View File

@ -140,7 +140,7 @@ private func removeMessages(postbox: Postbox, network: Network, stateManager: Ac
return .complete()
}
} else {
return network.request(Api.functions.messages.deleteMessages(id: operation.messageIds.map { $0.id }))
return network.request(Api.functions.messages.deleteMessages(flags: 0, id: operation.messageIds.map { $0.id }))
|> map { result -> Api.messages.AffectedMessages? in
return result
}
@ -200,7 +200,7 @@ private func removeChat(modifier: Modifier, postbox: Postbox, network: Network,
}
} else if peer.id.namespace == Namespaces.Peer.CloudUser {
if let inputPeer = apiInputPeer(peer), let topMessageId = modifier.getTopPeerMessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud) {
return network.request(Api.functions.messages.deleteHistory(peer: inputPeer, maxId: topMessageId.id))
return network.request(Api.functions.messages.deleteHistory(flags: 0, peer: inputPeer, maxId: topMessageId.id))
|> map { result -> Api.messages.AffectedHistory? in
return result
}

View File

@ -0,0 +1,135 @@
import Foundation
#if os(macOS)
import PostboxMac
import SwiftSignalKitMac
import MtProtoKitMac
#else
import Postbox
import SwiftSignalKit
import MtProtoKitDynamic
#endif
private final class ManagedSynchronizePinnedChatsOperationsHelper {
var operationDisposables: [Int32: Disposable] = [:]
func update(_ entries: [PeerMergedOperationLogEntry]) -> (disposeOperations: [Disposable], beginOperations: [(PeerMergedOperationLogEntry, MetaDisposable)]) {
var disposeOperations: [Disposable] = []
var beginOperations: [(PeerMergedOperationLogEntry, MetaDisposable)] = []
var hasRunningOperationForPeerId = Set<PeerId>()
var validMergedIndices = Set<Int32>()
for entry in entries {
if !hasRunningOperationForPeerId.contains(entry.peerId) {
hasRunningOperationForPeerId.insert(entry.peerId)
validMergedIndices.insert(entry.mergedIndex)
if self.operationDisposables[entry.mergedIndex] == nil {
let disposable = MetaDisposable()
beginOperations.append((entry, disposable))
self.operationDisposables[entry.mergedIndex] = disposable
}
}
}
var removeMergedIndices: [Int32] = []
for (mergedIndex, disposable) in self.operationDisposables {
if !validMergedIndices.contains(mergedIndex) {
removeMergedIndices.append(mergedIndex)
disposeOperations.append(disposable)
}
}
for mergedIndex in removeMergedIndices {
self.operationDisposables.removeValue(forKey: mergedIndex)
}
return (disposeOperations, beginOperations)
}
func reset() -> [Disposable] {
let disposables = Array(self.operationDisposables.values)
self.operationDisposables.removeAll()
return disposables
}
}
private func withTakenOperation(postbox: Postbox, peerId: PeerId, tagLocalIndex: Int32, _ f: @escaping (Modifier, PeerMergedOperationLogEntry?) -> Signal<Void, NoError>) -> Signal<Void, NoError> {
return postbox.modify { modifier -> Signal<Void, NoError> in
var result: PeerMergedOperationLogEntry?
modifier.operationLogUpdateEntry(peerId: peerId, tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: tagLocalIndex, { entry in
if let entry = entry, let _ = entry.mergedIndex, entry.contents is SynchronizePinnedChatsOperation {
result = entry.mergedEntry!
return PeerOperationLogEntryUpdate(mergedIndex: .none, contents: .none)
} else {
return PeerOperationLogEntryUpdate(mergedIndex: .none, contents: .none)
}
})
return f(modifier, result)
} |> switchToLatest
}
func managedSynchronizePinnedChatsOperations(postbox: Postbox, network: Network, stateManager: AccountStateManager) -> Signal<Void, NoError> {
return Signal { _ in
let helper = Atomic<ManagedSynchronizePinnedChatsOperationsHelper>(value: ManagedSynchronizePinnedChatsOperationsHelper())
let disposable = postbox.mergedOperationLogView(tag: OperationLogTags.SynchronizePinnedChats, limit: 10).start(next: { view in
let (disposeOperations, beginOperations) = helper.with { helper -> (disposeOperations: [Disposable], beginOperations: [(PeerMergedOperationLogEntry, MetaDisposable)]) in
return helper.update(view.entries)
}
for disposable in disposeOperations {
disposable.dispose()
}
for (entry, disposable) in beginOperations {
let signal = withTakenOperation(postbox: postbox, peerId: entry.peerId, tagLocalIndex: entry.tagLocalIndex, { modifier, entry -> Signal<Void, NoError> in
if let entry = entry {
if let operation = entry.contents as? SynchronizePinnedChatsOperation {
return synchronizePinnedChats(modifier: modifier, postbox: postbox, network: network, stateManager: stateManager, operation: operation)
} else {
assertionFailure()
}
}
return .complete()
})
|> then(postbox.modify { modifier -> Void in
let _ = modifier.operationLogRemoveEntry(peerId: entry.peerId, tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: entry.tagLocalIndex)
})
disposable.set(signal.start())
}
})
return ActionDisposable {
let disposables = helper.with { helper -> [Disposable] in
return helper.reset()
}
for disposable in disposables {
disposable.dispose()
}
disposable.dispose()
}
}
}
private func synchronizePinnedChats(modifier: Modifier, postbox: Postbox, network: Network, stateManager: AccountStateManager, operation: SynchronizePinnedChatsOperation) -> Signal<Void, NoError> {
let peerIds = modifier.getPinnedPeerIds().filter {
$0.namespace != Namespaces.Peer.SecretChat
}
var inputPeers: [Api.InputPeer] = []
for peerId in peerIds {
if let peer = modifier.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
inputPeers.append(inputPeer)
}
}
return network.request(Api.functions.messages.reorderPinnedDialogs(flags: 1 << 0, order: inputPeers))
|> `catch` { _ -> Signal<Api.Bool, NoError> in
return .single(Api.Bool.boolFalse)
}
|> mapToSignal { result -> Signal<Void, NoError> in
return .complete()
}
}

View File

@ -133,7 +133,7 @@ private func removeMessages(postbox: Postbox, network: Network, stateManager: Ac
return .complete()
}
} else {
return network.request(Api.functions.messages.deleteMessages(id: operation.messageIds.map { $0.id }))
return network.request(Api.functions.messages.deleteMessages(flags: 0, id: operation.messageIds.map { $0.id }))
|> map { result -> Api.messages.AffectedMessages? in
return result
}

View File

@ -64,6 +64,7 @@ struct OperationLogTags {
static let CloudChatRemoveMessages = PeerOperationLogTag(value: 3)
static let SynchronizePinnedCloudChats = PeerOperationLogTag(value: 4)
static let AutoremoveMessages = PeerOperationLogTag(value: 5)
static let SynchronizePinnedChats = PeerOperationLogTag(value: 6)
}
private enum PreferencesKeyValues: Int32 {

View File

@ -20,7 +20,7 @@ public class BoxedMessage: NSObject {
public class Serialization: NSObject, MTSerialization {
public func currentLayer() -> UInt {
return 60
return 62
}
public func parseMessage(_ data: Data!) -> Any! {
@ -57,7 +57,7 @@ public class Serialization: NSObject, MTSerialization {
if let config = parse(Buffer(data: response)) {
switch config {
//config flags:# date:int expires:int test_mode:Bool this_dc:int dc_options:Vector<DcOption> chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int chat_big_size:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int rating_e_decay:int stickers_recent_limit:int tmp_sessions:flags.0?int phonecalls_enabled:flags.1?true disabled_features:Vector<DisabledFeature> = Config;
case let .config(_, _, _, _, _, dcOptions, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
case let .config(_, _, _, _, _, dcOptions, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
var addressList = [MTDatacenterAddress]()
for option in dcOptions {
switch option {

View File

@ -147,6 +147,8 @@ extension Api.Message {
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: inviterId))
case let .messageActionChatMigrateTo(channelId):
result.append(PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId))
case let .messageActionPhoneCall(flags, callId, reason, duration):
break
}
return result

View File

@ -0,0 +1,37 @@
import Foundation
#if os(macOS)
import PostboxMac
#else
import Postbox
#endif
final class SynchronizePinnedChatsOperation: Coding {
private let previousPeerIds: [PeerId]
init(previousPeerIds: [PeerId]) {
self.previousPeerIds = previousPeerIds
}
init(decoder: Decoder) {
self.previousPeerIds = PeerId.decodeArrayFromBuffer(decoder.decodeBytesForKey("p")!)
}
func encode(_ encoder: Encoder) {
let buffer = WriteBuffer()
PeerId.encodeArrayToBuffer(self.previousPeerIds, buffer: buffer)
encoder.encodeBytes(buffer, forKey: "p")
}
}
func addSynchronizePinnedChatsOperation(modifier: Modifier) {
var updateLocalIndex: Int32?
modifier.operationLogEnumerateEntries(peerId: PeerId(namespace: 0, id: 0), tag: OperationLogTags.SynchronizePinnedChats, { entry in
updateLocalIndex = entry.tagLocalIndex
return false
})
let operationContents = SynchronizePinnedChatsOperation(previousPeerIds: modifier.getPinnedPeerIds())
if let updateLocalIndex = updateLocalIndex {
let _ = modifier.operationLogRemoveEntry(peerId: PeerId(namespace: 0, id: 0), tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: updateLocalIndex)
}
modifier.operationLogAddEntry(peerId: PeerId(namespace: 0, id: 0), tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: operationContents)
}

View File

@ -140,7 +140,5 @@ public func telegramMediaImageFromApiPhoto(_ photo: Api.Photo) -> TelegramMediaI
return TelegramMediaImage(imageId: MediaId(namespace: Namespaces.Media.CloudImage, id: id), representations: telegramMediaImageRepresentationsFromApiSizes(sizes))
case .photoEmpty:
return nil
case .wallPhoto:
return nil
}
}

View File

@ -138,13 +138,6 @@ public func telegramMediaMapFromApiGeoPoint(_ geo: Api.GeoPoint, title: String?,
switch geo {
case let .geoPoint(long, lat):
return TelegramMediaMap(latitude: lat, longitude: long, geoPlace: nil, venue: venue)
case let .geoPlace(long, lat, name):
var geoPlace: NamedGeoPlace?
switch name {
case let .geoPlaceName(country, state, city, district, street):
geoPlace = NamedGeoPlace(country: country, state: state, city: city, district: district, street: street)
}
return TelegramMediaMap(latitude: lat, longitude: long, geoPlace: geoPlace, venue: venue)
case .geoPointEmpty:
return TelegramMediaMap(latitude: 0.0, longitude: 0.0, geoPlace: nil, venue: venue)
}

View File

@ -0,0 +1,21 @@
import Foundation
#if os(macOS)
import PostboxMac
import SwiftSignalKitMac
#else
import Postbox
import SwiftSignalKit
#endif
public func togglePeerChatPinned(postbox: Postbox, peerId: PeerId) -> Signal<Void, NoError> {
return postbox.modify { modifier -> Void in
var peerIds = modifier.getPinnedPeerIds()
if let index = peerIds.index(of: peerId) {
peerIds.remove(at: index)
} else {
peerIds.insert(peerId, at: 0)
}
modifier.setPinnedPeerIds(peerIds)
addSynchronizePinnedChatsOperation(modifier: modifier)
}
}

View File

@ -127,14 +127,10 @@ extension Api.Update {
return (pts, ptsCount)
case let .updateReadHistoryOutbox(_, _, pts, ptsCount):
return (pts, ptsCount)
case let .updateReadMessages(_, pts, ptsCount):
return (pts, ptsCount)
case let .updateEditMessage(_, pts, ptsCount):
return (pts, ptsCount)
case let .updateReadMessagesContents(_, pts, ptsCount):
return (pts, ptsCount)
case let .updateRestoreMessages(_, pts):
return (pts, 1)
case let .updateWebPage(_, pts, ptsCount):
return (pts, ptsCount)
default: