mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-08 01:40:09 +00:00
Refactoring
This commit is contained in:
parent
8f656dbce1
commit
b4f35689f0
@ -68,7 +68,7 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch
|
|||||||
items.append(.separator)
|
items.append(.separator)
|
||||||
case .recentSearch:
|
case .recentSearch:
|
||||||
items.append(.action(ContextMenuActionItem(text: strings.ChatList_Context_RemoveFromRecents, textColor: .destructive, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Clear"), color: theme.contextMenu.destructiveColor) }, action: { _, f in
|
items.append(.action(ContextMenuActionItem(text: strings.ChatList_Context_RemoveFromRecents, textColor: .destructive, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Clear"), color: theme.contextMenu.destructiveColor) }, action: { _, f in
|
||||||
let _ = (removeRecentlySearchedPeer(postbox: context.account.postbox, peerId: peerId)
|
let _ = (context.engine.peers.removeRecentlySearchedPeer(peerId: peerId)
|
||||||
|> deliverOnMainQueue).start(completed: {
|
|> deliverOnMainQueue).start(completed: {
|
||||||
f(.default)
|
f(.default)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2004,11 +2004,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
|> delay(0.8, queue: Queue.mainQueue())
|
|> delay(0.8, queue: Queue.mainQueue())
|
||||||
let progressDisposable = progressSignal.start()
|
let progressDisposable = progressSignal.start()
|
||||||
|
|
||||||
let signal: Signal<Void, NoError> = strongSelf.context.account.postbox.transaction { transaction -> Void in
|
let signal: Signal<Never, NoError> = strongSelf.context.engine.peers.removePeerChats(peerIds: Array(peerIds))
|
||||||
for peerId in peerIds {
|
|
||||||
removePeerChat(account: context.account, transaction: transaction, mediaBox: context.account.postbox.mediaBox, peerId: peerId, reportChatSpam: false, deleteGloballyIfPossible: peerId.namespace == Namespaces.Peer.SecretChat)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|> afterDisposed {
|
|> afterDisposed {
|
||||||
Queue.mainQueue().async {
|
Queue.mainQueue().async {
|
||||||
progressDisposable.dispose()
|
progressDisposable.dispose()
|
||||||
@ -2693,7 +2689,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
if let channel = chatPeer as? TelegramChannel {
|
if let channel = chatPeer as? TelegramChannel {
|
||||||
strongSelf.context.peerChannelMemberCategoriesContextsManager.externallyRemoved(peerId: channel.id, memberId: strongSelf.context.account.peerId)
|
strongSelf.context.peerChannelMemberCategoriesContextsManager.externallyRemoved(peerId: channel.id, memberId: strongSelf.context.account.peerId)
|
||||||
}
|
}
|
||||||
let _ = removePeerChat(account: strongSelf.context.account, peerId: peerId, reportChatSpam: false, deleteGloballyIfPossible: deleteGloballyIfPossible).start(completed: {
|
let _ = strongSelf.context.engine.peers.removePeerChat(peerId: peerId, reportChatSpam: false, deleteGloballyIfPossible: deleteGloballyIfPossible).start(completed: {
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -191,7 +191,7 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let _ = (clearRecentlySearchedPeers(postbox: strongSelf.context.account.postbox)
|
let _ = (strongSelf.context.engine.peers.clearRecentlySearchedPeers()
|
||||||
|> deliverOnMainQueue).start()
|
|> deliverOnMainQueue).start()
|
||||||
})
|
})
|
||||||
]), ActionSheetItemGroup(items: [
|
]), ActionSheetItemGroup(items: [
|
||||||
|
|||||||
@ -1213,7 +1213,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
}, peerSelected: { [weak self] peer, _ in
|
}, peerSelected: { [weak self] peer, _ in
|
||||||
interaction.dismissInput()
|
interaction.dismissInput()
|
||||||
interaction.openPeer(peer, false)
|
interaction.openPeer(peer, false)
|
||||||
let _ = addRecentlySearchedPeer(postbox: context.account.postbox, peerId: peer.id).start()
|
let _ = context.engine.peers.addRecentlySearchedPeer(peerId: peer.id).start()
|
||||||
self?.listNode.clearHighlightAnimated(true)
|
self?.listNode.clearHighlightAnimated(true)
|
||||||
}, disabledPeerSelected: { _ in
|
}, disabledPeerSelected: { _ in
|
||||||
}, togglePeerSelected: { _ in
|
}, togglePeerSelected: { _ in
|
||||||
@ -1407,7 +1407,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
|> distinctUntilChanged
|
|> distinctUntilChanged
|
||||||
|
|
||||||
let previousRecentlySearchedPeerOrder = Atomic<[PeerId]>(value: [])
|
let previousRecentlySearchedPeerOrder = Atomic<[PeerId]>(value: [])
|
||||||
let fixedRecentlySearchedPeers = recentlySearchedPeers(postbox: context.account.postbox)
|
let fixedRecentlySearchedPeers = context.engine.peers.recentlySearchedPeers()
|
||||||
|> map { peers -> [RecentlySearchedPeer] in
|
|> map { peers -> [RecentlySearchedPeer] in
|
||||||
var result: [RecentlySearchedPeer] = []
|
var result: [RecentlySearchedPeer] = []
|
||||||
let _ = previousRecentlySearchedPeerOrder.modify { current in
|
let _ = previousRecentlySearchedPeerOrder.modify { current in
|
||||||
@ -1479,7 +1479,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
let firstTime = previousEntries == nil
|
let firstTime = previousEntries == nil
|
||||||
let transition = chatListSearchContainerPreparedRecentTransition(from: previousEntries ?? [], to: entries, context: context, presentationData: presentationData, filter: peersFilter, peerSelected: { peer in
|
let transition = chatListSearchContainerPreparedRecentTransition(from: previousEntries ?? [], to: entries, context: context, presentationData: presentationData, filter: peersFilter, peerSelected: { peer in
|
||||||
interaction.openPeer(peer, true)
|
interaction.openPeer(peer, true)
|
||||||
let _ = addRecentlySearchedPeer(postbox: context.account.postbox, peerId: peer.id).start()
|
let _ = context.engine.peers.addRecentlySearchedPeer(peerId: peer.id).start()
|
||||||
self?.recentListNode.clearHighlightAnimated(true)
|
self?.recentListNode.clearHighlightAnimated(true)
|
||||||
}, disabledPeerSelected: { peer in
|
}, disabledPeerSelected: { peer in
|
||||||
interaction.openDisabledPeer(peer)
|
interaction.openDisabledPeer(peer)
|
||||||
@ -1492,7 +1492,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
}, clearRecentlySearchedPeers: {
|
}, clearRecentlySearchedPeers: {
|
||||||
interaction.clearRecentSearch()
|
interaction.clearRecentSearch()
|
||||||
}, deletePeer: { peerId in
|
}, deletePeer: { peerId in
|
||||||
let _ = removeRecentlySearchedPeer(postbox: context.account.postbox, peerId: peerId).start()
|
let _ = context.engine.peers.removeRecentlySearchedPeer(peerId: peerId).start()
|
||||||
})
|
})
|
||||||
strongSelf.enqueueRecentTransition(transition, firstTime: firstTime)
|
strongSelf.enqueueRecentTransition(transition, firstTime: firstTime)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -450,7 +450,7 @@ public final class SecretMediaPreviewController: ViewController {
|
|||||||
self?.didSetReady = true
|
self?.didSetReady = true
|
||||||
}
|
}
|
||||||
self._ready.set(ready |> map { true })
|
self._ready.set(ready |> map { true })
|
||||||
self.markMessageAsConsumedDisposable.set(markMessageContentAsConsumedInteractively(postbox: self.context.account.postbox, messageId: message.id).start())
|
self.markMessageAsConsumedDisposable.set(self.context.engine.messages.markMessageContentAsConsumedInteractively(messageId: message.id).start())
|
||||||
} else {
|
} else {
|
||||||
var beginTimeAndTimeout: (Double, Double)?
|
var beginTimeAndTimeout: (Double, Double)?
|
||||||
var videoDuration: Int32?
|
var videoDuration: Int32?
|
||||||
|
|||||||
@ -927,14 +927,14 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
|
|||||||
return current.withUpdatedUpdating(true)
|
return current.withUpdatedUpdating(true)
|
||||||
}
|
}
|
||||||
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||||
updateRightsDisposable.set((removeGroupAdmin(account: context.account, peerId: peerId, adminId: adminId)
|
updateRightsDisposable.set((context.engine.peers.removeGroupAdmin(peerId: peerId, adminId: adminId)
|
||||||
|> deliverOnMainQueue).start(error: { _ in
|
|> deliverOnMainQueue).start(error: { _ in
|
||||||
}, completed: {
|
}, completed: {
|
||||||
updated(nil)
|
updated(nil)
|
||||||
dismissImpl?()
|
dismissImpl?()
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(account: context.account, peerId: peerId, memberId: adminId, adminRights: nil, rank: nil) |> deliverOnMainQueue).start(error: { _ in
|
updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(engine: context.engine, peerId: peerId, memberId: adminId, adminRights: nil, rank: nil) |> deliverOnMainQueue).start(error: { _ in
|
||||||
|
|
||||||
}, completed: {
|
}, completed: {
|
||||||
updated(nil)
|
updated(nil)
|
||||||
@ -1041,7 +1041,7 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
|
|||||||
updateState { current in
|
updateState { current in
|
||||||
return current.withUpdatedUpdating(true)
|
return current.withUpdatedUpdating(true)
|
||||||
}
|
}
|
||||||
updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(account: context.account, peerId: peerId, memberId: adminId, adminRights: TelegramChatAdminRights(rights: updateFlags ?? []), rank: effectiveRank) |> deliverOnMainQueue).start(error: { error in
|
updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(engine: context.engine, peerId: peerId, memberId: adminId, adminRights: TelegramChatAdminRights(rights: updateFlags ?? []), rank: effectiveRank) |> deliverOnMainQueue).start(error: { error in
|
||||||
updateState { current in
|
updateState { current in
|
||||||
return current.withUpdatedUpdating(false)
|
return current.withUpdatedUpdating(false)
|
||||||
}
|
}
|
||||||
@ -1089,7 +1089,7 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
|
|||||||
updateState { current in
|
updateState { current in
|
||||||
return current.withUpdatedUpdating(true)
|
return current.withUpdatedUpdating(true)
|
||||||
}
|
}
|
||||||
updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(account: context.account, peerId: peerId, memberId: adminId, adminRights: TelegramChatAdminRights(rights: currentFlags), rank: updateRank) |> deliverOnMainQueue).start(error: { _ in
|
updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(engine: context.engine, peerId: peerId, memberId: adminId, adminRights: TelegramChatAdminRights(rights: currentFlags), rank: updateRank) |> deliverOnMainQueue).start(error: { _ in
|
||||||
|
|
||||||
}, completed: {
|
}, completed: {
|
||||||
updated(TelegramChatAdminRights(rights: currentFlags))
|
updated(TelegramChatAdminRights(rights: currentFlags))
|
||||||
@ -1134,7 +1134,7 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
|
|||||||
updateState { current in
|
updateState { current in
|
||||||
return current.withUpdatedUpdating(true)
|
return current.withUpdatedUpdating(true)
|
||||||
}
|
}
|
||||||
updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(account: context.account, peerId: peerId, memberId: adminId, adminRights: TelegramChatAdminRights(rights: updateFlags), rank: updateRank) |> deliverOnMainQueue).start(error: { error in
|
updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(engine: context.engine, peerId: peerId, memberId: adminId, adminRights: TelegramChatAdminRights(rights: updateFlags), rank: updateRank) |> deliverOnMainQueue).start(error: { error in
|
||||||
if case let .addMemberError(addMemberError) = error, let admin = adminView.peers[adminView.peerId] {
|
if case let .addMemberError(addMemberError) = error, let admin = adminView.peers[adminView.peerId] {
|
||||||
var text = presentationData.strings.Login_UnknownError
|
var text = presentationData.strings.Login_UnknownError
|
||||||
switch addMemberError {
|
switch addMemberError {
|
||||||
@ -1201,7 +1201,7 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
|
|||||||
updateState { current in
|
updateState { current in
|
||||||
return current.withUpdatedUpdating(true)
|
return current.withUpdatedUpdating(true)
|
||||||
}
|
}
|
||||||
updateRightsDisposable.set((addGroupAdmin(account: context.account, peerId: peerId, adminId: adminId)
|
updateRightsDisposable.set((context.engine.peers.addGroupAdmin(peerId: peerId, adminId: adminId)
|
||||||
|> deliverOnMainQueue).start(error: { error in
|
|> deliverOnMainQueue).start(error: { error in
|
||||||
if case let .addMemberError(error) = error, case .privacy = error, let admin = adminView.peers[adminView.peerId] {
|
if case let .addMemberError(error) = error, case .privacy = error, let admin = adminView.peers[adminView.peerId] {
|
||||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(admin.compactDisplayTitle, admin.compactDisplayTitle).0, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(admin.compactDisplayTitle, admin.compactDisplayTitle).0, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||||
@ -1234,7 +1234,7 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
|
|||||||
guard let upgradedPeerId = upgradedPeerId else {
|
guard let upgradedPeerId = upgradedPeerId else {
|
||||||
return .fail(.conversionFailed)
|
return .fail(.conversionFailed)
|
||||||
}
|
}
|
||||||
return context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(account: context.account, peerId: upgradedPeerId, memberId: adminId, adminRights: TelegramChatAdminRights(rights: updateFlags), rank: updateRank)
|
return context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(engine: context.engine, peerId: upgradedPeerId, memberId: adminId, adminRights: TelegramChatAdminRights(rights: updateFlags), rank: updateRank)
|
||||||
|> mapError { error -> WrappedUpdateChannelAdminRightsError in
|
|> mapError { error -> WrappedUpdateChannelAdminRightsError in
|
||||||
return .direct(error)
|
return .direct(error)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -583,14 +583,14 @@ public func channelAdminsController(context: AccountContext, peerId initialPeerI
|
|||||||
return $0.withUpdatedRemovingPeerId(adminId)
|
return $0.withUpdatedRemovingPeerId(adminId)
|
||||||
}
|
}
|
||||||
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||||
removeAdminDisposable.set((removeGroupAdmin(account: context.account, peerId: peerId, adminId: adminId)
|
removeAdminDisposable.set((context.engine.peers.removeGroupAdmin(peerId: peerId, adminId: adminId)
|
||||||
|> deliverOnMainQueue).start(completed: {
|
|> deliverOnMainQueue).start(completed: {
|
||||||
updateState {
|
updateState {
|
||||||
return $0.withUpdatedRemovingPeerId(nil)
|
return $0.withUpdatedRemovingPeerId(nil)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
removeAdminDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(account: context.account, peerId: peerId, memberId: adminId, adminRights: nil, rank: nil)
|
removeAdminDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(engine: context.engine, peerId: peerId, memberId: adminId, adminRights: nil, rank: nil)
|
||||||
|> deliverOnMainQueue).start(completed: {
|
|> deliverOnMainQueue).start(completed: {
|
||||||
updateState {
|
updateState {
|
||||||
return $0.withUpdatedRemovingPeerId(nil)
|
return $0.withUpdatedRemovingPeerId(nil)
|
||||||
|
|||||||
@ -437,7 +437,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
|
|||||||
|
|
||||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||||
if case .searchAdmins = mode {
|
if case .searchAdmins = mode {
|
||||||
return context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(account: context.account, peerId: peerId, memberId: memberId, adminRights: nil, rank: nil)
|
return context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(engine: context.engine, peerId: peerId, memberId: memberId, adminRights: nil, rank: nil)
|
||||||
|> `catch` { _ -> Signal<Void, NoError> in
|
|> `catch` { _ -> Signal<Void, NoError> in
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
@ -465,7 +465,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
if case .searchAdmins = mode {
|
if case .searchAdmins = mode {
|
||||||
return removeGroupAdmin(account: context.account, peerId: peerId, adminId: memberId)
|
return context.engine.peers.removeGroupAdmin(peerId: peerId, adminId: memberId)
|
||||||
|> `catch` { _ -> Signal<Void, NoError> in
|
|> `catch` { _ -> Signal<Void, NoError> in
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -455,9 +455,9 @@ public func oldChannelsController(context: AccountContext, intent: OldChannelsCo
|
|||||||
let state = stateValue.with { $0 }
|
let state = stateValue.with { $0 }
|
||||||
let _ = (peersPromise.get()
|
let _ = (peersPromise.get()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> mapToSignal { peers in
|
|> mapToSignal { peers -> Signal<Never, NoError> in
|
||||||
|
let peers = peers ?? []
|
||||||
return context.account.postbox.transaction { transaction -> Void in
|
return context.account.postbox.transaction { transaction -> Void in
|
||||||
if let peers = peers {
|
|
||||||
for peer in peers {
|
for peer in peers {
|
||||||
if state.selectedPeers.contains(peer.peer.id) {
|
if state.selectedPeers.contains(peer.peer.id) {
|
||||||
if transaction.getPeer(peer.peer.id) == nil {
|
if transaction.getPeer(peer.peer.id) == nil {
|
||||||
@ -465,11 +465,11 @@ public func oldChannelsController(context: AccountContext, intent: OldChannelsCo
|
|||||||
return updated
|
return updated
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
removePeerChat(account: context.account, transaction: transaction, mediaBox: context.account.postbox.mediaBox, peerId: peer.peer.id, reportChatSpam: false, deleteGloballyIfPossible: false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|> ignoreValues
|
||||||
|
|> then(context.engine.peers.removePeerChats(peerIds: Array(peers.map(\.peer.id))))
|
||||||
}
|
}
|
||||||
|> deliverOnMainQueue).start(completed: {
|
|> deliverOnMainQueue).start(completed: {
|
||||||
completed(true)
|
completed(true)
|
||||||
|
|||||||
@ -848,7 +848,7 @@ final class ThemeGridSearchContentNode: SearchDisplayControllerContentNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func clearRecentSearch() {
|
private func clearRecentSearch() {
|
||||||
let _ = (clearRecentlySearchedPeers(postbox: self.context.account.postbox) |> deliverOnMainQueue).start()
|
let _ = (self.context.engine.peers.clearRecentlySearchedPeers() |> deliverOnMainQueue).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func scrollToTop() {
|
override func scrollToTop() {
|
||||||
|
|||||||
@ -743,7 +743,7 @@ final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
}, extendedInitialReveal: self.presetText != nil, segmentedValues: self.segmentedValues)
|
}, extendedInitialReveal: self.presetText != nil, segmentedValues: self.segmentedValues)
|
||||||
self.peersContentNode = peersContentNode
|
self.peersContentNode = peersContentNode
|
||||||
peersContentNode.openSearch = { [weak self] in
|
peersContentNode.openSearch = { [weak self] in
|
||||||
let _ = (recentlySearchedPeers(postbox: context.account.postbox)
|
let _ = (context.engine.peers.recentlySearchedPeers()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { peers in
|
|> deliverOnMainQueue).start(next: { peers in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
|
|||||||
@ -901,7 +901,7 @@ public func groupStatsController(context: AccountContext, peerId: PeerId, cached
|
|||||||
}
|
}
|
||||||
promotePeerImpl = { [weak controller] participantPeerId in
|
promotePeerImpl = { [weak controller] participantPeerId in
|
||||||
if let navigationController = controller?.navigationController as? NavigationController {
|
if let navigationController = controller?.navigationController as? NavigationController {
|
||||||
let _ = (fetchChannelParticipant(account: context.account, peerId: peerId, participantId: participantPeerId)
|
let _ = (context.engine.peers.fetchChannelParticipant(peerId: peerId, participantId: participantPeerId)
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { participant in
|
|> deliverOnMainQueue).start(next: { participant in
|
||||||
if let participant = participant, let controller = context.sharedContext.makeChannelAdminController(context: context, peerId: peerId, adminId: participantPeerId, initialParticipant: participant) {
|
if let participant = participant, let controller = context.sharedContext.makeChannelAdminController(context: context, peerId: peerId, adminId: participantPeerId, initialParticipant: participant) {
|
||||||
|
|||||||
@ -80,7 +80,7 @@ public enum AddChannelMemberError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func addChannelMember(account: Account, peerId: PeerId, memberId: PeerId) -> Signal<(ChannelParticipant?, RenderedChannelParticipant), AddChannelMemberError> {
|
public func addChannelMember(account: Account, peerId: PeerId, memberId: PeerId) -> Signal<(ChannelParticipant?, RenderedChannelParticipant), AddChannelMemberError> {
|
||||||
return fetchChannelParticipant(account: account, peerId: peerId, participantId: memberId)
|
return _internal_fetchChannelParticipant(account: account, peerId: peerId, participantId: memberId)
|
||||||
|> mapError { error -> AddChannelMemberError in
|
|> mapError { error -> AddChannelMemberError in
|
||||||
}
|
}
|
||||||
|> mapToSignal { currentParticipant -> Signal<(ChannelParticipant?, RenderedChannelParticipant), AddChannelMemberError> in
|
|> mapToSignal { currentParticipant -> Signal<(ChannelParticipant?, RenderedChannelParticipant), AddChannelMemberError> in
|
||||||
|
|||||||
@ -10,7 +10,7 @@ public enum NotificationTokenType {
|
|||||||
case voip
|
case voip
|
||||||
}
|
}
|
||||||
|
|
||||||
public func unregisterNotificationToken(account: Account, token: Data, type: NotificationTokenType, otherAccountUserIds: [PeerId.Id]) -> Signal<Never, NoError> {
|
func _internal_unregisterNotificationToken(account: Account, token: Data, type: NotificationTokenType, otherAccountUserIds: [PeerId.Id]) -> Signal<Never, NoError> {
|
||||||
let mappedType: Int32
|
let mappedType: Int32
|
||||||
switch type {
|
switch type {
|
||||||
case .aps:
|
case .aps:
|
||||||
@ -23,7 +23,7 @@ public func unregisterNotificationToken(account: Account, token: Data, type: Not
|
|||||||
|> ignoreValues
|
|> ignoreValues
|
||||||
}
|
}
|
||||||
|
|
||||||
public func registerNotificationToken(account: Account, token: Data, type: NotificationTokenType, sandbox: Bool, otherAccountUserIds: [PeerId.Id], excludeMutedChats: Bool) -> Signal<Never, NoError> {
|
func _internal_registerNotificationToken(account: Account, token: Data, type: NotificationTokenType, sandbox: Bool, otherAccountUserIds: [PeerId.Id], excludeMutedChats: Bool) -> Signal<Never, NoError> {
|
||||||
return masterNotificationsKey(account: account, ignoreDisabled: false)
|
return masterNotificationsKey(account: account, ignoreDisabled: false)
|
||||||
|> mapToSignal { masterKey -> Signal<Never, NoError> in
|
|> mapToSignal { masterKey -> Signal<Never, NoError> in
|
||||||
let mappedType: Int32
|
let mappedType: Int32
|
||||||
@ -1,4 +1,7 @@
|
|||||||
|
import Foundation
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
import Postbox
|
||||||
|
import SyncCore
|
||||||
|
|
||||||
public extension TelegramEngine {
|
public extension TelegramEngine {
|
||||||
final class AccountData {
|
final class AccountData {
|
||||||
@ -35,5 +38,13 @@ public extension TelegramEngine {
|
|||||||
public func updateAbout(about: String?) -> Signal<Void, UpdateAboutError> {
|
public func updateAbout(about: String?) -> Signal<Void, UpdateAboutError> {
|
||||||
return _internal_updateAbout(account: self.account, about: about)
|
return _internal_updateAbout(account: self.account, about: about)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func unregisterNotificationToken(token: Data, type: NotificationTokenType, otherAccountUserIds: [PeerId.Id]) -> Signal<Never, NoError> {
|
||||||
|
return _internal_unregisterNotificationToken(account: self.account, token: token, type: type, otherAccountUserIds: otherAccountUserIds)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func registerNotificationToken(token: Data, type: NotificationTokenType, sandbox: Bool, otherAccountUserIds: [PeerId.Id], excludeMutedChats: Bool) -> Signal<Never, NoError> {
|
||||||
|
return _internal_registerNotificationToken(account: self.account, token: token, type: type, sandbox: sandbox, otherAccountUserIds: otherAccountUserIds, excludeMutedChats: excludeMutedChats)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ public enum EarliestUnseenPersonalMentionMessageResult: Equatable {
|
|||||||
case result(MessageId?)
|
case result(MessageId?)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func earliestUnseenPersonalMentionMessage(account: Account, peerId: PeerId) -> Signal<EarliestUnseenPersonalMentionMessageResult, NoError> {
|
func _internal_earliestUnseenPersonalMentionMessage(account: Account, peerId: PeerId) -> Signal<EarliestUnseenPersonalMentionMessageResult, NoError> {
|
||||||
return account.viewTracker.aroundMessageHistoryViewForLocation(.peer(peerId), index: .lowerBound, anchorIndex: .lowerBound, count: 4, fixedCombinedReadStates: nil, tagMask: .unseenPersonalMessage, additionalData: [.peerChatState(peerId)])
|
return account.viewTracker.aroundMessageHistoryViewForLocation(.peer(peerId), index: .lowerBound, anchorIndex: .lowerBound, count: 4, fixedCombinedReadStates: nil, tagMask: .unseenPersonalMessage, additionalData: [.peerChatState(peerId)])
|
||||||
|> mapToSignal { view -> Signal<EarliestUnseenPersonalMentionMessageResult, NoError> in
|
|> mapToSignal { view -> Signal<EarliestUnseenPersonalMentionMessageResult, NoError> in
|
||||||
if view.0.isLoading {
|
if view.0.isLoading {
|
||||||
@ -5,7 +5,7 @@ import SwiftSignalKit
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
public func installInteractiveReadMessagesAction(postbox: Postbox, stateManager: AccountStateManager, peerId: PeerId) -> Disposable {
|
func _internal_installInteractiveReadMessagesAction(postbox: Postbox, stateManager: AccountStateManager, peerId: PeerId) -> Disposable {
|
||||||
return postbox.installStoreMessageAction(peerId: peerId, { messages, transaction in
|
return postbox.installStoreMessageAction(peerId: peerId, { messages, transaction in
|
||||||
var consumeMessageIds: [MessageId] = []
|
var consumeMessageIds: [MessageId] = []
|
||||||
|
|
||||||
@ -5,7 +5,7 @@ import SwiftSignalKit
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
public func markMessageContentAsConsumedInteractively(postbox: Postbox, messageId: MessageId) -> Signal<Void, NoError> {
|
func _internal_markMessageContentAsConsumedInteractively(postbox: Postbox, messageId: MessageId) -> Signal<Void, NoError> {
|
||||||
return postbox.transaction { transaction -> Void in
|
return postbox.transaction { transaction -> Void in
|
||||||
if let message = transaction.getMessage(messageId), message.flags.contains(.Incoming) {
|
if let message = transaction.getMessage(messageId), message.flags.contains(.Incoming) {
|
||||||
var updateMessage = false
|
var updateMessage = false
|
||||||
@ -10,7 +10,7 @@ public enum RequestMessageSelectPollOptionError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
public func requestMessageSelectPollOption(account: Account, messageId: MessageId, opaqueIdentifiers: [Data]) -> Signal<TelegramMediaPoll?, RequestMessageSelectPollOptionError> {
|
func _internal_requestMessageSelectPollOption(account: Account, messageId: MessageId, opaqueIdentifiers: [Data]) -> Signal<TelegramMediaPoll?, RequestMessageSelectPollOptionError> {
|
||||||
return account.postbox.loadedPeerWithId(messageId.peerId)
|
return account.postbox.loadedPeerWithId(messageId.peerId)
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> castError(RequestMessageSelectPollOptionError.self)
|
|> castError(RequestMessageSelectPollOptionError.self)
|
||||||
@ -80,7 +80,7 @@ public func requestMessageSelectPollOption(account: Account, messageId: MessageI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func requestClosePoll(postbox: Postbox, network: Network, stateManager: AccountStateManager, messageId: MessageId) -> Signal<Void, NoError> {
|
func _internal_requestClosePoll(postbox: Postbox, network: Network, stateManager: AccountStateManager, messageId: MessageId) -> Signal<Void, NoError> {
|
||||||
return postbox.transaction { transaction -> (TelegramMediaPoll, Api.InputPeer)? in
|
return postbox.transaction { transaction -> (TelegramMediaPoll, Api.InputPeer)? in
|
||||||
guard let inputPeer = transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) else {
|
guard let inputPeer = transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) else {
|
||||||
return nil
|
return nil
|
||||||
@ -419,7 +419,7 @@ public final class PollResultsContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(account: Account, messageId: MessageId, poll: TelegramMediaPoll) {
|
init(account: Account, messageId: MessageId, poll: TelegramMediaPoll) {
|
||||||
let queue = self.queue
|
let queue = self.queue
|
||||||
self.impl = QueueLocalObject(queue: queue, generate: {
|
self.impl = QueueLocalObject(queue: queue, generate: {
|
||||||
return PollResultsContextImpl(queue: queue, account: account, messageId: messageId, poll: poll)
|
return PollResultsContextImpl(queue: queue, account: account, messageId: messageId, poll: poll)
|
||||||
@ -55,7 +55,7 @@ func _internal_requestStartBotInGroup(account: Account, botPeerId: PeerId, group
|
|||||||
|> mapToSignal { result -> Signal<StartBotInGroupResult, RequestStartBotInGroupError> in
|
|> mapToSignal { result -> Signal<StartBotInGroupResult, RequestStartBotInGroupError> in
|
||||||
account.stateManager.addUpdates(result)
|
account.stateManager.addUpdates(result)
|
||||||
if groupPeerId.namespace == Namespaces.Peer.CloudChannel {
|
if groupPeerId.namespace == Namespaces.Peer.CloudChannel {
|
||||||
return fetchChannelParticipant(account: account, peerId: groupPeerId, participantId: botPeerId)
|
return _internal_fetchChannelParticipant(account: account, peerId: groupPeerId, participantId: botPeerId)
|
||||||
|> mapError { _ -> RequestStartBotInGroupError in return .generic
|
|> mapError { _ -> RequestStartBotInGroupError in return .generic
|
||||||
}
|
}
|
||||||
|> mapToSignal { participant -> Signal<StartBotInGroupResult, RequestStartBotInGroupError> in
|
|> mapToSignal { participant -> Signal<StartBotInGroupResult, RequestStartBotInGroupError> in
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import Foundation
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
import Postbox
|
||||||
import SyncCore
|
import SyncCore
|
||||||
@ -122,5 +123,29 @@ public extension TelegramEngine {
|
|||||||
public func getMessagesLoadIfNecessary(_ messageIds: [MessageId], strategy: GetMessagesStrategy = .cloud) -> Signal <[Message], NoError> {
|
public func getMessagesLoadIfNecessary(_ messageIds: [MessageId], strategy: GetMessagesStrategy = .cloud) -> Signal <[Message], NoError> {
|
||||||
return _internal_getMessagesLoadIfNecessary(messageIds, postbox: self.account.postbox, network: self.account.network, accountPeerId: self.account.peerId, strategy: strategy)
|
return _internal_getMessagesLoadIfNecessary(messageIds, postbox: self.account.postbox, network: self.account.network, accountPeerId: self.account.peerId, strategy: strategy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func markMessageContentAsConsumedInteractively(messageId: MessageId) -> Signal<Void, NoError> {
|
||||||
|
return _internal_markMessageContentAsConsumedInteractively(postbox: self.account.postbox, messageId: messageId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func installInteractiveReadMessagesAction(peerId: PeerId) -> Disposable {
|
||||||
|
return _internal_installInteractiveReadMessagesAction(postbox: self.account.postbox, stateManager: self.account.stateManager, peerId: peerId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func requestMessageSelectPollOption(messageId: MessageId, opaqueIdentifiers: [Data]) -> Signal<TelegramMediaPoll?, RequestMessageSelectPollOptionError> {
|
||||||
|
return _internal_requestMessageSelectPollOption(account: self.account, messageId: messageId, opaqueIdentifiers: opaqueIdentifiers)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func requestClosePoll(messageId: MessageId) -> Signal<Void, NoError> {
|
||||||
|
return _internal_requestClosePoll(postbox: self.account.postbox, network: self.account.network, stateManager: self.account.stateManager, messageId: messageId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func pollResults(messageId: MessageId, poll: TelegramMediaPoll) -> PollResultsContext {
|
||||||
|
return PollResultsContext(account: self.account, messageId: messageId, poll: poll)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func earliestUnseenPersonalMentionMessage(peerId: PeerId) -> Signal<EarliestUnseenPersonalMentionMessageResult, NoError> {
|
||||||
|
return _internal_earliestUnseenPersonalMentionMessage(account: self.account, peerId: peerId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import MtProtoKit
|
|||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
func _internal_updateChannelMemberBannedRights(account: Account, peerId: PeerId, memberId: PeerId, rights: TelegramChatBannedRights?) -> Signal<(ChannelParticipant?, RenderedChannelParticipant?, Bool), NoError> {
|
func _internal_updateChannelMemberBannedRights(account: Account, peerId: PeerId, memberId: PeerId, rights: TelegramChatBannedRights?) -> Signal<(ChannelParticipant?, RenderedChannelParticipant?, Bool), NoError> {
|
||||||
return fetchChannelParticipant(account: account, peerId: peerId, participantId: memberId)
|
return _internal_fetchChannelParticipant(account: account, peerId: peerId, participantId: memberId)
|
||||||
|> mapToSignal { currentParticipant -> Signal<(ChannelParticipant?, RenderedChannelParticipant?, Bool), NoError> in
|
|> mapToSignal { currentParticipant -> Signal<(ChannelParticipant?, RenderedChannelParticipant?, Bool), NoError> in
|
||||||
return account.postbox.transaction { transaction -> Signal<(ChannelParticipant?, RenderedChannelParticipant?, Bool), NoError> in
|
return account.postbox.transaction { transaction -> Signal<(ChannelParticipant?, RenderedChannelParticipant?, Bool), NoError> in
|
||||||
if let peer = transaction.getPeer(peerId), let inputChannel = apiInputChannel(peer), let _ = transaction.getPeer(account.peerId), let memberPeer = transaction.getPeer(memberId), let inputPeer = apiInputPeer(memberPeer) {
|
if let peer = transaction.getPeer(peerId), let inputChannel = apiInputChannel(peer), let _ = transaction.getPeer(account.peerId), let memberPeer = transaction.getPeer(memberId), let inputPeer = apiInputPeer(memberPeer) {
|
||||||
|
|||||||
@ -77,7 +77,7 @@ func _internal_updateChannelOwnership(account: Account, accountStateManager: Acc
|
|||||||
return .fail(.invalidPassword)
|
return .fail(.invalidPassword)
|
||||||
}
|
}
|
||||||
|
|
||||||
return combineLatest(fetchChannelParticipant(account: account, peerId: channelId, participantId: account.peerId), fetchChannelParticipant(account: account, peerId: channelId, participantId: memberId))
|
return combineLatest(_internal_fetchChannelParticipant(account: account, peerId: channelId, participantId: account.peerId), _internal_fetchChannelParticipant(account: account, peerId: channelId, participantId: memberId))
|
||||||
|> mapError { error -> ChannelOwnershipTransferError in
|
|> mapError { error -> ChannelOwnershipTransferError in
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ public enum RemoveGroupAdminError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
public func removeGroupAdmin(account: Account, peerId: PeerId, adminId: PeerId) -> Signal<Void, RemoveGroupAdminError> {
|
func _internal_removeGroupAdmin(account: Account, peerId: PeerId, adminId: PeerId) -> Signal<Void, RemoveGroupAdminError> {
|
||||||
return account.postbox.transaction { transaction -> Signal<Void, RemoveGroupAdminError> in
|
return account.postbox.transaction { transaction -> Signal<Void, RemoveGroupAdminError> in
|
||||||
if let peer = transaction.getPeer(peerId), let adminPeer = transaction.getPeer(adminId), let inputUser = apiInputUser(adminPeer) {
|
if let peer = transaction.getPeer(peerId), let adminPeer = transaction.getPeer(adminId), let inputUser = apiInputUser(adminPeer) {
|
||||||
if let group = peer as? TelegramGroup {
|
if let group = peer as? TelegramGroup {
|
||||||
@ -58,7 +58,7 @@ public enum AddGroupAdminError {
|
|||||||
case adminsTooMuch
|
case adminsTooMuch
|
||||||
}
|
}
|
||||||
|
|
||||||
public func addGroupAdmin(account: Account, peerId: PeerId, adminId: PeerId) -> Signal<Void, AddGroupAdminError> {
|
func _internal_addGroupAdmin(account: Account, peerId: PeerId, adminId: PeerId) -> Signal<Void, AddGroupAdminError> {
|
||||||
return account.postbox.transaction { transaction -> Signal<Void, AddGroupAdminError> in
|
return account.postbox.transaction { transaction -> Signal<Void, AddGroupAdminError> in
|
||||||
if let peer = transaction.getPeer(peerId), let adminPeer = transaction.getPeer(adminId), let inputUser = apiInputUser(adminPeer) {
|
if let peer = transaction.getPeer(peerId), let adminPeer = transaction.getPeer(adminId), let inputUser = apiInputUser(adminPeer) {
|
||||||
if let group = peer as? TelegramGroup {
|
if let group = peer as? TelegramGroup {
|
||||||
@ -127,7 +127,7 @@ public enum UpdateChannelAdminRightsError {
|
|||||||
case adminsTooMuch
|
case adminsTooMuch
|
||||||
}
|
}
|
||||||
|
|
||||||
public func fetchChannelParticipant(account: Account, peerId: PeerId, participantId: PeerId) -> Signal<ChannelParticipant?, NoError> {
|
func _internal_fetchChannelParticipant(account: Account, peerId: PeerId, participantId: PeerId) -> Signal<ChannelParticipant?, NoError> {
|
||||||
return account.postbox.transaction { transaction -> Signal<ChannelParticipant?, NoError> in
|
return account.postbox.transaction { transaction -> Signal<ChannelParticipant?, NoError> in
|
||||||
if let peer = transaction.getPeer(peerId), let adminPeer = transaction.getPeer(participantId), let inputPeer = apiInputPeer(adminPeer) {
|
if let peer = transaction.getPeer(peerId), let adminPeer = transaction.getPeer(participantId), let inputPeer = apiInputPeer(adminPeer) {
|
||||||
if let channel = peer as? TelegramChannel, let inputChannel = apiInputChannel(channel) {
|
if let channel = peer as? TelegramChannel, let inputChannel = apiInputChannel(channel) {
|
||||||
@ -150,8 +150,8 @@ public func fetchChannelParticipant(account: Account, peerId: PeerId, participan
|
|||||||
} |> switchToLatest
|
} |> switchToLatest
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updateChannelAdminRights(account: Account, peerId: PeerId, adminId: PeerId, rights: TelegramChatAdminRights?, rank: String?) -> Signal<(ChannelParticipant?, RenderedChannelParticipant), UpdateChannelAdminRightsError> {
|
func _internal_updateChannelAdminRights(account: Account, peerId: PeerId, adminId: PeerId, rights: TelegramChatAdminRights?, rank: String?) -> Signal<(ChannelParticipant?, RenderedChannelParticipant), UpdateChannelAdminRightsError> {
|
||||||
return fetchChannelParticipant(account: account, peerId: peerId, participantId: adminId)
|
return _internal_fetchChannelParticipant(account: account, peerId: peerId, participantId: adminId)
|
||||||
|> mapError { error -> UpdateChannelAdminRightsError in
|
|> mapError { error -> UpdateChannelAdminRightsError in
|
||||||
}
|
}
|
||||||
|> mapToSignal { currentParticipant -> Signal<(ChannelParticipant?, RenderedChannelParticipant), UpdateChannelAdminRightsError> in
|
|> mapToSignal { currentParticipant -> Signal<(ChannelParticipant?, RenderedChannelParticipant), UpdateChannelAdminRightsError> in
|
||||||
@ -17,7 +17,7 @@ public struct PeerSpecificStickerPackData {
|
|||||||
public let canSetup: Bool
|
public let canSetup: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
public func peerSpecificStickerPack(postbox: Postbox, network: Network, peerId: PeerId) -> Signal<PeerSpecificStickerPackData, NoError> {
|
func _internal_peerSpecificStickerPack(postbox: Postbox, network: Network, peerId: PeerId) -> Signal<PeerSpecificStickerPackData, NoError> {
|
||||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||||
let signal: Signal<(WrappedStickerPackCollectionInfo, Bool), NoError> = postbox.combinedView(keys: [.cachedPeerData(peerId: peerId)])
|
let signal: Signal<(WrappedStickerPackCollectionInfo, Bool), NoError> = postbox.combinedView(keys: [.cachedPeerData(peerId: peerId)])
|
||||||
|> map { view -> (WrappedStickerPackCollectionInfo, Bool) in
|
|> map { view -> (WrappedStickerPackCollectionInfo, Bool) in
|
||||||
@ -4,19 +4,19 @@ import SwiftSignalKit
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
public func addRecentlySearchedPeer(postbox: Postbox, peerId: PeerId) -> Signal<Void, NoError> {
|
func _internal_addRecentlySearchedPeer(postbox: Postbox, peerId: PeerId) -> Signal<Void, NoError> {
|
||||||
return postbox.transaction { transaction -> Void in
|
return postbox.transaction { transaction -> Void in
|
||||||
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.RecentlySearchedPeerIds, item: OrderedItemListEntry(id: RecentPeerItemId(peerId).rawValue, contents: RecentPeerItem(rating: 0.0)), removeTailIfCountExceeds: 20)
|
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.RecentlySearchedPeerIds, item: OrderedItemListEntry(id: RecentPeerItemId(peerId).rawValue, contents: RecentPeerItem(rating: 0.0)), removeTailIfCountExceeds: 20)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func removeRecentlySearchedPeer(postbox: Postbox, peerId: PeerId) -> Signal<Void, NoError> {
|
func _internal_removeRecentlySearchedPeer(postbox: Postbox, peerId: PeerId) -> Signal<Void, NoError> {
|
||||||
return postbox.transaction { transaction -> Void in
|
return postbox.transaction { transaction -> Void in
|
||||||
transaction.removeOrderedItemListItem(collectionId: Namespaces.OrderedItemList.RecentlySearchedPeerIds, itemId: RecentPeerItemId(peerId).rawValue)
|
transaction.removeOrderedItemListItem(collectionId: Namespaces.OrderedItemList.RecentlySearchedPeerIds, itemId: RecentPeerItemId(peerId).rawValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func clearRecentlySearchedPeers(postbox: Postbox) -> Signal<Void, NoError> {
|
func _internal_clearRecentlySearchedPeers(postbox: Postbox) -> Signal<Void, NoError> {
|
||||||
return postbox.transaction { transaction -> Void in
|
return postbox.transaction { transaction -> Void in
|
||||||
transaction.replaceOrderedItemListItems(collectionId: Namespaces.OrderedItemList.RecentlySearchedPeerIds, items: [])
|
transaction.replaceOrderedItemListItems(collectionId: Namespaces.OrderedItemList.RecentlySearchedPeerIds, items: [])
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ public struct RecentlySearchedPeer: Equatable {
|
|||||||
public let subpeerSummary: RecentlySearchedPeerSubpeerSummary?
|
public let subpeerSummary: RecentlySearchedPeerSubpeerSummary?
|
||||||
}
|
}
|
||||||
|
|
||||||
public func recentlySearchedPeers(postbox: Postbox) -> Signal<[RecentlySearchedPeer], NoError> {
|
func _internal_recentlySearchedPeers(postbox: Postbox) -> Signal<[RecentlySearchedPeer], NoError> {
|
||||||
return postbox.combinedView(keys: [.orderedItemList(id: Namespaces.OrderedItemList.RecentlySearchedPeerIds)])
|
return postbox.combinedView(keys: [.orderedItemList(id: Namespaces.OrderedItemList.RecentlySearchedPeerIds)])
|
||||||
|> mapToSignal { view -> Signal<[RecentlySearchedPeer], NoError> in
|
|> mapToSignal { view -> Signal<[RecentlySearchedPeer], NoError> in
|
||||||
var peerIds: [PeerId] = []
|
var peerIds: [PeerId] = []
|
||||||
@ -4,13 +4,13 @@ import SwiftSignalKit
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
public func removePeerChat(account: Account, peerId: PeerId, reportChatSpam: Bool, deleteGloballyIfPossible: Bool = false) -> Signal<Void, NoError> {
|
func _internal_removePeerChat(account: Account, peerId: PeerId, reportChatSpam: Bool, deleteGloballyIfPossible: Bool = false) -> Signal<Void, NoError> {
|
||||||
return account.postbox.transaction { transaction -> Void in
|
return account.postbox.transaction { transaction -> Void in
|
||||||
removePeerChat(account: account, transaction: transaction, mediaBox: account.postbox.mediaBox, peerId: peerId, reportChatSpam: reportChatSpam, deleteGloballyIfPossible: deleteGloballyIfPossible)
|
_internal_removePeerChat(account: account, transaction: transaction, mediaBox: account.postbox.mediaBox, peerId: peerId, reportChatSpam: reportChatSpam, deleteGloballyIfPossible: deleteGloballyIfPossible)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func terminateSecretChat(transaction: Transaction, peerId: PeerId, requestRemoteHistoryRemoval: Bool) {
|
func _internal_terminateSecretChat(transaction: Transaction, peerId: PeerId, requestRemoteHistoryRemoval: Bool) {
|
||||||
if let state = transaction.getPeerChatState(peerId) as? SecretChatState, state.embeddedState != .terminated {
|
if let state = transaction.getPeerChatState(peerId) as? SecretChatState, state.embeddedState != .terminated {
|
||||||
let updatedState = addSecretChatOutgoingOperation(transaction: transaction, peerId: peerId, operation: SecretChatOutgoingOperationContents.terminate(reportSpam: false, requestRemoteHistoryRemoval: requestRemoteHistoryRemoval), state: state).withUpdatedEmbeddedState(.terminated)
|
let updatedState = addSecretChatOutgoingOperation(transaction: transaction, peerId: peerId, operation: SecretChatOutgoingOperationContents.terminate(reportSpam: false, requestRemoteHistoryRemoval: requestRemoteHistoryRemoval), state: state).withUpdatedEmbeddedState(.terminated)
|
||||||
if updatedState != state {
|
if updatedState != state {
|
||||||
@ -24,7 +24,7 @@ public func terminateSecretChat(transaction: Transaction, peerId: PeerId, reques
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func removePeerChat(account: Account, transaction: Transaction, mediaBox: MediaBox, peerId: PeerId, reportChatSpam: Bool, deleteGloballyIfPossible: Bool) {
|
func _internal_removePeerChat(account: Account, transaction: Transaction, mediaBox: MediaBox, peerId: PeerId, reportChatSpam: Bool, deleteGloballyIfPossible: Bool) {
|
||||||
if let _ = transaction.getPeerChatInterfaceState(peerId) {
|
if let _ = transaction.getPeerChatInterfaceState(peerId) {
|
||||||
transaction.updatePeerChatInterfaceState(peerId, update: { current in
|
transaction.updatePeerChatInterfaceState(peerId, update: { current in
|
||||||
if let current = current {
|
if let current = current {
|
||||||
@ -231,5 +231,61 @@ public extension TelegramEngine {
|
|||||||
public func peerCommands(id: PeerId) -> Signal<PeerCommands, NoError> {
|
public func peerCommands(id: PeerId) -> Signal<PeerCommands, NoError> {
|
||||||
return _internal_peerCommands(account: self.account, id: id)
|
return _internal_peerCommands(account: self.account, id: id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func addGroupAdmin(peerId: PeerId, adminId: PeerId) -> Signal<Void, AddGroupAdminError> {
|
||||||
|
return _internal_addGroupAdmin(account: self.account, peerId: peerId, adminId: adminId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func removeGroupAdmin(peerId: PeerId, adminId: PeerId) -> Signal<Void, RemoveGroupAdminError> {
|
||||||
|
return _internal_removeGroupAdmin(account: self.account, peerId: peerId, adminId: adminId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func fetchChannelParticipant(peerId: PeerId, participantId: PeerId) -> Signal<ChannelParticipant?, NoError> {
|
||||||
|
return _internal_fetchChannelParticipant(account: self.account, peerId: peerId, participantId: participantId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func updateChannelAdminRights(peerId: PeerId, adminId: PeerId, rights: TelegramChatAdminRights?, rank: String?) -> Signal<(ChannelParticipant?, RenderedChannelParticipant), UpdateChannelAdminRightsError> {
|
||||||
|
return _internal_updateChannelAdminRights(account: self.account, peerId: peerId, adminId: adminId, rights: rights, rank: rank)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func peerSpecificStickerPack(peerId: PeerId) -> Signal<PeerSpecificStickerPackData, NoError> {
|
||||||
|
return _internal_peerSpecificStickerPack(postbox: self.account.postbox, network: self.account.network, peerId: peerId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func addRecentlySearchedPeer(peerId: PeerId) -> Signal<Void, NoError> {
|
||||||
|
return _internal_addRecentlySearchedPeer(postbox: self.account.postbox, peerId: peerId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func removeRecentlySearchedPeer(peerId: PeerId) -> Signal<Void, NoError> {
|
||||||
|
return _internal_removeRecentlySearchedPeer(postbox: self.account.postbox, peerId: peerId)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func clearRecentlySearchedPeers() -> Signal<Void, NoError> {
|
||||||
|
return _internal_clearRecentlySearchedPeers(postbox: self.account.postbox)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func recentlySearchedPeers() -> Signal<[RecentlySearchedPeer], NoError> {
|
||||||
|
return _internal_recentlySearchedPeers(postbox: self.account.postbox)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func removePeerChat(peerId: PeerId, reportChatSpam: Bool, deleteGloballyIfPossible: Bool = false) -> Signal<Void, NoError> {
|
||||||
|
return _internal_removePeerChat(account: self.account, peerId: peerId, reportChatSpam: reportChatSpam, deleteGloballyIfPossible: deleteGloballyIfPossible)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func removePeerChats(peerIds: [PeerId]) -> Signal<Never, NoError> {
|
||||||
|
return self.account.postbox.transaction { transaction -> Void in
|
||||||
|
for peerId in peerIds {
|
||||||
|
_internal_removePeerChat(account: self.account, transaction: transaction, mediaBox: self.account.postbox.mediaBox, peerId: peerId, reportChatSpam: false, deleteGloballyIfPossible: peerId.namespace == Namespaces.Peer.SecretChat)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|> ignoreValues
|
||||||
|
}
|
||||||
|
|
||||||
|
public func terminateSecretChat(peerId: PeerId, requestRemoteHistoryRemoval: Bool) -> Signal<Never, NoError> {
|
||||||
|
return self.account.postbox.transaction { transaction -> Void in
|
||||||
|
_internal_terminateSecretChat(transaction: transaction, peerId: peerId, requestRemoteHistoryRemoval: requestRemoteHistoryRemoval)
|
||||||
|
}
|
||||||
|
|> ignoreValues
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2281,7 +2281,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
disposables = DisposableDict()
|
disposables = DisposableDict()
|
||||||
strongSelf.selectMessagePollOptionDisposables = disposables
|
strongSelf.selectMessagePollOptionDisposables = disposables
|
||||||
}
|
}
|
||||||
let signal = requestMessageSelectPollOption(account: strongSelf.context.account, messageId: id, opaqueIdentifiers: opaqueIdentifiers)
|
let signal = strongSelf.context.engine.messages.requestMessageSelectPollOption(messageId: id, opaqueIdentifiers: opaqueIdentifiers)
|
||||||
disposables.set((signal
|
disposables.set((signal
|
||||||
|> deliverOnMainQueue).start(next: { resultPoll in
|
|> deliverOnMainQueue).start(next: { resultPoll in
|
||||||
guard let strongSelf = self, let resultPoll = resultPoll else {
|
guard let strongSelf = self, let resultPoll = resultPoll else {
|
||||||
@ -4909,7 +4909,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
self.chatDisplayNode.navigateButtons.mentionsPressed = { [weak self] in
|
self.chatDisplayNode.navigateButtons.mentionsPressed = { [weak self] in
|
||||||
if let strongSelf = self, strongSelf.isNodeLoaded, case let .peer(peerId) = strongSelf.chatLocation {
|
if let strongSelf = self, strongSelf.isNodeLoaded, case let .peer(peerId) = strongSelf.chatLocation {
|
||||||
let signal = earliestUnseenPersonalMentionMessage(account: strongSelf.context.account, peerId: peerId)
|
let signal = strongSelf.context.engine.messages.earliestUnseenPersonalMentionMessage(peerId: peerId)
|
||||||
strongSelf.navigationActionDisposable.set((signal |> deliverOnMainQueue).start(next: { result in
|
strongSelf.navigationActionDisposable.set((signal |> deliverOnMainQueue).start(next: { result in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
switch result {
|
switch result {
|
||||||
@ -6385,7 +6385,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
let controller = OverlayStatusController(theme: strongSelf.presentationData.theme, type: .loading(cancelled: nil))
|
let controller = OverlayStatusController(theme: strongSelf.presentationData.theme, type: .loading(cancelled: nil))
|
||||||
strongSelf.present(controller, in: .window(.root))
|
strongSelf.present(controller, in: .window(.root))
|
||||||
let signal = requestMessageSelectPollOption(account: strongSelf.context.account, messageId: id, opaqueIdentifiers: [])
|
let signal = strongSelf.context.engine.messages.requestMessageSelectPollOption(messageId: id, opaqueIdentifiers: [])
|
||||||
|> afterDisposed { [weak controller] in
|
|> afterDisposed { [weak controller] in
|
||||||
Queue.mainQueue().async {
|
Queue.mainQueue().async {
|
||||||
controller?.dismiss()
|
controller?.dismiss()
|
||||||
@ -6447,7 +6447,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
let controller = OverlayStatusController(theme: strongSelf.presentationData.theme, type: .loading(cancelled: nil))
|
let controller = OverlayStatusController(theme: strongSelf.presentationData.theme, type: .loading(cancelled: nil))
|
||||||
strongSelf.present(controller, in: .window(.root))
|
strongSelf.present(controller, in: .window(.root))
|
||||||
let signal = requestClosePoll(postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, stateManager: strongSelf.context.account.stateManager, messageId: id)
|
let signal = strongSelf.context.engine.messages.requestClosePoll(messageId: id)
|
||||||
|> afterDisposed { [weak controller] in
|
|> afterDisposed { [weak controller] in
|
||||||
Queue.mainQueue().async {
|
Queue.mainQueue().async {
|
||||||
controller?.dismiss()
|
controller?.dismiss()
|
||||||
@ -11421,12 +11421,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
let _ = strongSelf.context.engine.privacy.requestUpdatePeerIsBlocked(peerId: peer.id, isBlocked: true).start()
|
let _ = strongSelf.context.engine.privacy.requestUpdatePeerIsBlocked(peerId: peer.id, isBlocked: true).start()
|
||||||
if let _ = chatPeer as? TelegramSecretChat {
|
if let _ = chatPeer as? TelegramSecretChat {
|
||||||
let _ = (strongSelf.context.account.postbox.transaction { transaction in
|
let _ = strongSelf.context.engine.peers.terminateSecretChat(peerId: chatPeer.id, requestRemoteHistoryRemoval: true).start()
|
||||||
terminateSecretChat(transaction: transaction, peerId: chatPeer.id, requestRemoteHistoryRemoval: true)
|
|
||||||
}).start()
|
|
||||||
}
|
}
|
||||||
if deleteChat {
|
if deleteChat {
|
||||||
let _ = removePeerChat(account: strongSelf.context.account, peerId: chatPeer.id, reportChatSpam: reportSpam).start()
|
let _ = strongSelf.context.engine.peers.removePeerChat(peerId: chatPeer.id, reportChatSpam: reportSpam).start()
|
||||||
strongSelf.effectiveNavigationController?.filterController(strongSelf, animated: true)
|
strongSelf.effectiveNavigationController?.filterController(strongSelf, animated: true)
|
||||||
} else if reportSpam {
|
} else if reportSpam {
|
||||||
let _ = strongSelf.context.engine.peers.reportPeer(peerId: peer.id, reason: .spam, message: "").start()
|
let _ = strongSelf.context.engine.peers.reportPeer(peerId: peer.id, reason: .spam, message: "").start()
|
||||||
@ -11562,7 +11560,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
self.commitPurposefulAction()
|
self.commitPurposefulAction()
|
||||||
self.chatDisplayNode.historyNode.disconnect()
|
self.chatDisplayNode.historyNode.disconnect()
|
||||||
let _ = removePeerChat(account: self.context.account, peerId: peerId, reportChatSpam: reportChatSpam).start()
|
let _ = self.context.engine.peers.removePeerChat(peerId: peerId, reportChatSpam: reportChatSpam).start()
|
||||||
self.effectiveNavigationController?.popToRoot(animated: true)
|
self.effectiveNavigationController?.popToRoot(animated: true)
|
||||||
|
|
||||||
let _ = self.context.engine.privacy.requestUpdatePeerIsBlocked(peerId: peerId, isBlocked: true).start()
|
let _ = self.context.engine.privacy.requestUpdatePeerIsBlocked(peerId: peerId, isBlocked: true).start()
|
||||||
@ -11808,7 +11806,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
private func presentBanMessageOptions(accountPeerId: PeerId, author: Peer, messageIds: Set<MessageId>, options: ChatAvailableMessageActionOptions) {
|
private func presentBanMessageOptions(accountPeerId: PeerId, author: Peer, messageIds: Set<MessageId>, options: ChatAvailableMessageActionOptions) {
|
||||||
let peerId = self.chatLocation.peerId
|
let peerId = self.chatLocation.peerId
|
||||||
do {
|
do {
|
||||||
self.navigationActionDisposable.set((fetchChannelParticipant(account: self.context.account, peerId: peerId, participantId: author.id)
|
self.navigationActionDisposable.set((self.context.engine.peers.fetchChannelParticipant(peerId: peerId, participantId: author.id)
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] participant in
|
|> deliverOnMainQueue).start(next: { [weak self] participant in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let canBan = participant?.canBeBannedBy(peerId: accountPeerId) ?? true
|
let canBan = participant?.canBeBannedBy(peerId: accountPeerId) ?? true
|
||||||
|
|||||||
@ -2001,7 +2001,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
|||||||
} else if self.interactiveReadActionDisposable == nil {
|
} else if self.interactiveReadActionDisposable == nil {
|
||||||
if case let .peer(peerId) = self.chatLocation {
|
if case let .peer(peerId) = self.chatLocation {
|
||||||
if !self.context.sharedContext.immediateExperimentalUISettings.skipReadHistory {
|
if !self.context.sharedContext.immediateExperimentalUISettings.skipReadHistory {
|
||||||
self.interactiveReadActionDisposable = installInteractiveReadMessagesAction(postbox: self.context.account.postbox, stateManager: self.context.account.stateManager, peerId: peerId)
|
self.interactiveReadActionDisposable = self.context.engine.messages.installInteractiveReadMessagesAction(peerId: peerId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -772,7 +772,7 @@ final class ChatMediaInputNode: ChatInputNode {
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
peerSpecificPack = combineLatest(peerSpecificStickerPack(postbox: context.account.postbox, network: context.account.network, peerId: peerId), context.account.postbox.multiplePeersView([peerId]), self.dismissedPeerSpecificStickerPack.get())
|
peerSpecificPack = combineLatest(context.engine.peers.peerSpecificStickerPack(peerId: peerId), context.account.postbox.multiplePeersView([peerId]), self.dismissedPeerSpecificStickerPack.get())
|
||||||
|> map { packData, peersView, dismissedPeerSpecificPack -> (PeerSpecificPackData?, CanInstallPeerSpecificPack) in
|
|> map { packData, peersView, dismissedPeerSpecificPack -> (PeerSpecificPackData?, CanInstallPeerSpecificPack) in
|
||||||
if let peer = peersView.peers[peerId] {
|
if let peer = peersView.peers[peerId] {
|
||||||
var canInstall: CanInstallPeerSpecificPack = .none
|
var canInstall: CanInstallPeerSpecificPack = .none
|
||||||
|
|||||||
@ -839,7 +839,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||||||
if canBan {
|
if canBan {
|
||||||
actions.append(ContextMenuAction(content: .text(title: self.presentationData.strings.Conversation_ContextMenuBan, accessibilityLabel: self.presentationData.strings.Conversation_ContextMenuBan), action: { [weak self] in
|
actions.append(ContextMenuAction(content: .text(title: self.presentationData.strings.Conversation_ContextMenuBan, accessibilityLabel: self.presentationData.strings.Conversation_ContextMenuBan), action: { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.banDisposables.set((fetchChannelParticipant(account: strongSelf.context.account, peerId: strongSelf.peer.id, participantId: author.id)
|
strongSelf.banDisposables.set((strongSelf.context.engine.peers.fetchChannelParticipant(peerId: strongSelf.peer.id, participantId: author.id)
|
||||||
|> deliverOnMainQueue).start(next: { participant in
|
|> deliverOnMainQueue).start(next: { participant in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.presentController(channelBannedMemberController(context: strongSelf.context, peerId: strongSelf.peer.id, memberId: author.id, initialParticipant: participant, updated: { _ in }, upgradedToSupergroup: { _, f in f() }), .window(.root), ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
strongSelf.presentController(channelBannedMemberController(context: strongSelf.context, peerId: strongSelf.peer.id, memberId: author.id, initialParticipant: participant, updated: { _ in }, upgradedToSupergroup: { _, f in f() }), .window(.root), ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||||
|
|||||||
@ -4294,7 +4294,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
|||||||
|
|
||||||
strongSelf.activeActionDisposable.set(strongSelf.context.engine.privacy.requestUpdatePeerIsBlocked(peerId: peer.id, isBlocked: true).start())
|
strongSelf.activeActionDisposable.set(strongSelf.context.engine.privacy.requestUpdatePeerIsBlocked(peerId: peer.id, isBlocked: true).start())
|
||||||
if deleteChat {
|
if deleteChat {
|
||||||
let _ = removePeerChat(account: strongSelf.context.account, peerId: strongSelf.peerId, reportChatSpam: reportSpam).start()
|
let _ = strongSelf.context.engine.peers.removePeerChat(peerId: strongSelf.peerId, reportChatSpam: reportSpam).start()
|
||||||
(strongSelf.controller?.navigationController as? NavigationController)?.popToRoot(animated: true)
|
(strongSelf.controller?.navigationController as? NavigationController)?.popToRoot(animated: true)
|
||||||
} else if reportSpam {
|
} else if reportSpam {
|
||||||
let _ = strongSelf.context.engine.peers.reportPeer(peerId: strongSelf.peerId, reason: .spam, message: "").start()
|
let _ = strongSelf.context.engine.peers.reportPeer(peerId: strongSelf.peerId, reason: .spam, message: "").start()
|
||||||
|
|||||||
@ -808,7 +808,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
let _ = markMessageContentAsConsumedInteractively(postbox: self.context.account.postbox, messageId: item.message.id).start()
|
let _ = self.context.engine.messages.markMessageContentAsConsumedInteractively(messageId: item.message.id).start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -323,7 +323,7 @@ public func pollResultsController(context: AccountContext, messageId: MessageId,
|
|||||||
|
|
||||||
let actionsDisposable = DisposableSet()
|
let actionsDisposable = DisposableSet()
|
||||||
|
|
||||||
let resultsContext = PollResultsContext(account: context.account, messageId: messageId, poll: poll)
|
let resultsContext = context.engine.messages.pollResults(messageId: messageId, poll: poll)
|
||||||
|
|
||||||
let arguments = PollResultsControllerArguments(context: context,
|
let arguments = PollResultsControllerArguments(context: context,
|
||||||
collapseOption: { optionId in
|
collapseOption: { optionId in
|
||||||
|
|||||||
@ -867,7 +867,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
guard let token = token else {
|
guard let token = token else {
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
return unregisterNotificationToken(account: account, token: token, type: .aps(encrypt: false), otherAccountUserIds: (account.testingEnvironment ? allTestingUserIds : allProductionUserIds).filter({ $0 != account.peerId.id }))
|
return TelegramEngine(account: account).accountData.unregisterNotificationToken(token: token, type: .aps(encrypt: false), otherAccountUserIds: (account.testingEnvironment ? allTestingUserIds : allProductionUserIds).filter({ $0 != account.peerId.id }))
|
||||||
}
|
}
|
||||||
appliedVoip = self.voipNotificationToken
|
appliedVoip = self.voipNotificationToken
|
||||||
|> distinctUntilChanged(isEqual: { $0 == $1 })
|
|> distinctUntilChanged(isEqual: { $0 == $1 })
|
||||||
@ -875,7 +875,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
guard let token = token else {
|
guard let token = token else {
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
return unregisterNotificationToken(account: account, token: token, type: .voip, otherAccountUserIds: (account.testingEnvironment ? allTestingUserIds : allProductionUserIds).filter({ $0 != account.peerId.id }))
|
return TelegramEngine(account: account).accountData.unregisterNotificationToken(token: token, type: .voip, otherAccountUserIds: (account.testingEnvironment ? allTestingUserIds : allProductionUserIds).filter({ $0 != account.peerId.id }))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
appliedAps = self.apsNotificationToken
|
appliedAps = self.apsNotificationToken
|
||||||
@ -890,7 +890,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
} else {
|
} else {
|
||||||
encrypt = false
|
encrypt = false
|
||||||
}
|
}
|
||||||
return registerNotificationToken(account: account, token: token, type: .aps(encrypt: encrypt), sandbox: sandbox, otherAccountUserIds: (account.testingEnvironment ? activeTestingUserIds : activeProductionUserIds).filter({ $0 != account.peerId.id }), excludeMutedChats: !settings.includeMuted)
|
return TelegramEngine(account: account).accountData.registerNotificationToken(token: token, type: .aps(encrypt: encrypt), sandbox: sandbox, otherAccountUserIds: (account.testingEnvironment ? activeTestingUserIds : activeProductionUserIds).filter({ $0 != account.peerId.id }), excludeMutedChats: !settings.includeMuted)
|
||||||
}
|
}
|
||||||
appliedVoip = self.voipNotificationToken
|
appliedVoip = self.voipNotificationToken
|
||||||
|> distinctUntilChanged(isEqual: { $0 == $1 })
|
|> distinctUntilChanged(isEqual: { $0 == $1 })
|
||||||
@ -898,7 +898,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
guard let token = token else {
|
guard let token = token else {
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
return registerNotificationToken(account: account, token: token, type: .voip, sandbox: sandbox, otherAccountUserIds: (account.testingEnvironment ? activeTestingUserIds : activeProductionUserIds).filter({ $0 != account.peerId.id }), excludeMutedChats: !settings.includeMuted)
|
return TelegramEngine(account: account).accountData.registerNotificationToken(token: token, type: .voip, sandbox: sandbox, otherAccountUserIds: (account.testingEnvironment ? activeTestingUserIds : activeProductionUserIds).filter({ $0 != account.peerId.id }), excludeMutedChats: !settings.includeMuted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -378,8 +378,8 @@ public final class PeerChannelMemberCategoriesContextsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updateMemberAdminRights(account: Account, peerId: PeerId, memberId: PeerId, adminRights: TelegramChatAdminRights?, rank: String?) -> Signal<Void, UpdateChannelAdminRightsError> {
|
public func updateMemberAdminRights(engine: TelegramEngine, peerId: PeerId, memberId: PeerId, adminRights: TelegramChatAdminRights?, rank: String?) -> Signal<Void, UpdateChannelAdminRightsError> {
|
||||||
return updateChannelAdminRights(account: account, peerId: peerId, adminId: memberId, rights: adminRights, rank: rank)
|
return engine.peers.updateChannelAdminRights(peerId: peerId, adminId: memberId, rights: adminRights, rank: rank)
|
||||||
|> map(Optional.init)
|
|> map(Optional.init)
|
||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> beforeNext { [weak self] result in
|
|> beforeNext { [weak self] result in
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user