mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
[WIP]
This commit is contained in:
parent
e7e9e93535
commit
b1d2eda246
@ -560,9 +560,15 @@ public func channelDiscussionGroupSetupController(context: AccountContext, peerI
|
|||||||
var isEmptyState = false
|
var isEmptyState = false
|
||||||
var displayGroupList = false
|
var displayGroupList = false
|
||||||
if let cachedData = view.cachedData as? CachedChannelData {
|
if let cachedData = view.cachedData as? CachedChannelData {
|
||||||
let isEmpty = cachedData.linkedDiscussionPeerId == nil
|
var isEmpty = true
|
||||||
|
switch cachedData.linkedDiscussionPeerId {
|
||||||
|
case .unknown:
|
||||||
|
isEmpty = true
|
||||||
|
case let .known(value):
|
||||||
|
isEmpty = value == nil
|
||||||
|
}
|
||||||
if let peer = view.peers[view.peerId] as? TelegramChannel, case .broadcast = peer.info {
|
if let peer = view.peers[view.peerId] as? TelegramChannel, case .broadcast = peer.info {
|
||||||
if cachedData.linkedDiscussionPeerId == nil {
|
if isEmpty {
|
||||||
if groups == nil {
|
if groups == nil {
|
||||||
isEmptyState = true
|
isEmptyState = true
|
||||||
} else {
|
} else {
|
||||||
@ -570,13 +576,13 @@ public func channelDiscussionGroupSetupController(context: AccountContext, peerI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let wasEmpty = wasEmpty, wasEmpty != isEmpty {
|
|
||||||
crossfade = true
|
|
||||||
}
|
|
||||||
wasEmpty = isEmpty
|
|
||||||
} else {
|
} else {
|
||||||
isEmptyState = true
|
isEmptyState = true
|
||||||
}
|
}
|
||||||
|
if let wasEmpty = wasEmpty, wasEmpty != isEmptyState {
|
||||||
|
crossfade = true
|
||||||
|
}
|
||||||
|
wasEmpty = isEmptyState
|
||||||
|
|
||||||
var emptyStateItem: ItemListControllerEmptyStateItem?
|
var emptyStateItem: ItemListControllerEmptyStateItem?
|
||||||
if isEmptyState {
|
if isEmptyState {
|
||||||
|
@ -11,14 +11,12 @@ public enum SearchPeerMembersScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func searchPeerMembers(context: AccountContext, peerId: PeerId, chatLocation: ChatLocation, query: String, scope: SearchPeerMembersScope) -> Signal<[Peer], NoError> {
|
public func searchPeerMembers(context: AccountContext, peerId: PeerId, chatLocation: ChatLocation, query: String, scope: SearchPeerMembersScope) -> Signal<[Peer], NoError> {
|
||||||
if case .replyThread = chatLocation {
|
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||||
return .single([])
|
|
||||||
} else if peerId.namespace == Namespaces.Peer.CloudChannel {
|
|
||||||
return context.account.postbox.transaction { transaction -> CachedChannelData? in
|
return context.account.postbox.transaction { transaction -> CachedChannelData? in
|
||||||
return transaction.getPeerCachedData(peerId: peerId) as? CachedChannelData
|
return transaction.getPeerCachedData(peerId: peerId) as? CachedChannelData
|
||||||
}
|
}
|
||||||
|> mapToSignal { cachedData -> Signal<([Peer], Bool), NoError> in
|
|> mapToSignal { cachedData -> Signal<([Peer], Bool), NoError> in
|
||||||
if let cachedData = cachedData, let memberCount = cachedData.participantsSummary.memberCount, memberCount <= 64 {
|
if case .peer = chatLocation, let cachedData = cachedData, let memberCount = cachedData.participantsSummary.memberCount, memberCount <= 64 {
|
||||||
return Signal { subscriber in
|
return Signal { subscriber in
|
||||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, requestUpdate: false, updated: { state in
|
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, requestUpdate: false, updated: { state in
|
||||||
if case .ready = state.loadingState {
|
if case .ready = state.loadingState {
|
||||||
@ -54,19 +52,37 @@ public func searchPeerMembers(context: AccountContext, peerId: PeerId, chatLocat
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Signal { subscriber in
|
return Signal { subscriber in
|
||||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query.isEmpty ? nil : query, updated: { state in
|
switch chatLocation {
|
||||||
if case .ready = state.loadingState {
|
case let .peer(peerId):
|
||||||
subscriber.putNext((state.list.compactMap { participant in
|
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query.isEmpty ? nil : query, updated: { state in
|
||||||
if participant.peer.isDeleted {
|
if case .ready = state.loadingState {
|
||||||
return nil
|
subscriber.putNext((state.list.compactMap { participant in
|
||||||
}
|
if participant.peer.isDeleted {
|
||||||
return participant.peer
|
return nil
|
||||||
}, true))
|
}
|
||||||
|
return participant.peer
|
||||||
|
}, true))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return ActionDisposable {
|
||||||
|
disposable.dispose()
|
||||||
|
}
|
||||||
|
case let .replyThread(replyThreadMessage):
|
||||||
|
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.mentions(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, threadMessageId: replyThreadMessage.messageId, searchQuery: query.isEmpty ? nil : query, updated: { state in
|
||||||
|
if case .ready = state.loadingState {
|
||||||
|
subscriber.putNext((state.list.compactMap { participant in
|
||||||
|
if participant.peer.isDeleted {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return participant.peer
|
||||||
|
}, true))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return ActionDisposable {
|
||||||
|
disposable.dispose()
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
return ActionDisposable {
|
|
||||||
disposable.dispose()
|
|
||||||
}
|
}
|
||||||
} |> runOn(Queue.mainQueue())
|
} |> runOn(Queue.mainQueue())
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[106343499] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsSearch($0) }
|
dict[106343499] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsSearch($0) }
|
||||||
dict[-1548400251] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsKicked($0) }
|
dict[-1548400251] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsKicked($0) }
|
||||||
dict[-1150621555] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsContacts($0) }
|
dict[-1150621555] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsContacts($0) }
|
||||||
dict[915357814] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsMentions($0) }
|
dict[-531931925] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsMentions($0) }
|
||||||
dict[-350980120] = { return Api.WebPage.parse_webPageEmpty($0) }
|
dict[-350980120] = { return Api.WebPage.parse_webPageEmpty($0) }
|
||||||
dict[-981018084] = { return Api.WebPage.parse_webPagePending($0) }
|
dict[-981018084] = { return Api.WebPage.parse_webPagePending($0) }
|
||||||
dict[-392411726] = { return Api.WebPage.parse_webPage($0) }
|
dict[-392411726] = { return Api.WebPage.parse_webPage($0) }
|
||||||
|
@ -9991,7 +9991,7 @@ public extension Api {
|
|||||||
case channelParticipantsSearch(q: String)
|
case channelParticipantsSearch(q: String)
|
||||||
case channelParticipantsKicked(q: String)
|
case channelParticipantsKicked(q: String)
|
||||||
case channelParticipantsContacts(q: String)
|
case channelParticipantsContacts(q: String)
|
||||||
case channelParticipantsMentions(q: String)
|
case channelParticipantsMentions(flags: Int32, q: String?, topMsgId: Int32?)
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
@ -10037,11 +10037,13 @@ public extension Api {
|
|||||||
}
|
}
|
||||||
serializeString(q, buffer: buffer, boxed: false)
|
serializeString(q, buffer: buffer, boxed: false)
|
||||||
break
|
break
|
||||||
case .channelParticipantsMentions(let q):
|
case .channelParticipantsMentions(let flags, let q, let topMsgId):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(915357814)
|
buffer.appendInt32(-531931925)
|
||||||
}
|
}
|
||||||
serializeString(q, buffer: buffer, boxed: false)
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
|
if Int(flags) & Int(1 << 0) != 0 {serializeString(q!, buffer: buffer, boxed: false)}
|
||||||
|
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10062,8 +10064,8 @@ public extension Api {
|
|||||||
return ("channelParticipantsKicked", [("q", q)])
|
return ("channelParticipantsKicked", [("q", q)])
|
||||||
case .channelParticipantsContacts(let q):
|
case .channelParticipantsContacts(let q):
|
||||||
return ("channelParticipantsContacts", [("q", q)])
|
return ("channelParticipantsContacts", [("q", q)])
|
||||||
case .channelParticipantsMentions(let q):
|
case .channelParticipantsMentions(let flags, let q, let topMsgId):
|
||||||
return ("channelParticipantsMentions", [("q", q)])
|
return ("channelParticipantsMentions", [("flags", flags), ("q", q), ("topMsgId", topMsgId)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10121,11 +10123,17 @@ public extension Api {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static func parse_channelParticipantsMentions(_ reader: BufferReader) -> ChannelParticipantsFilter? {
|
public static func parse_channelParticipantsMentions(_ reader: BufferReader) -> ChannelParticipantsFilter? {
|
||||||
var _1: String?
|
var _1: Int32?
|
||||||
_1 = parseString(reader)
|
_1 = reader.readInt32()
|
||||||
|
var _2: String?
|
||||||
|
if Int(_1!) & Int(1 << 0) != 0 {_2 = parseString(reader) }
|
||||||
|
var _3: Int32?
|
||||||
|
if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() }
|
||||||
let _c1 = _1 != nil
|
let _c1 = _1 != nil
|
||||||
if _c1 {
|
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
|
||||||
return Api.ChannelParticipantsFilter.channelParticipantsMentions(q: _1!)
|
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
|
||||||
|
if _c1 && _c2 && _c3 {
|
||||||
|
return Api.ChannelParticipantsFilter.channelParticipantsMentions(flags: _1!, q: _2, topMsgId: _3)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -18,6 +18,7 @@ public enum ChannelMembersCategory {
|
|||||||
case bots(ChannelMembersCategoryFilter)
|
case bots(ChannelMembersCategoryFilter)
|
||||||
case restricted(ChannelMembersCategoryFilter)
|
case restricted(ChannelMembersCategoryFilter)
|
||||||
case banned(ChannelMembersCategoryFilter)
|
case banned(ChannelMembersCategoryFilter)
|
||||||
|
case mentions(threadId: MessageId?, filter: ChannelMembersCategoryFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func channelMembers(postbox: Postbox, network: Network, accountPeerId: PeerId, peerId: PeerId, category: ChannelMembersCategory = .recent(.all), offset: Int32 = 0, limit: Int32 = 64, hash: Int32 = 0) -> Signal<[RenderedChannelParticipant]?, NoError> {
|
public func channelMembers(postbox: Postbox, network: Network, accountPeerId: PeerId, peerId: PeerId, category: ChannelMembersCategory = .recent(.all), offset: Int32 = 0, limit: Int32 = 64, hash: Int32 = 0) -> Signal<[RenderedChannelParticipant]?, NoError> {
|
||||||
@ -32,6 +33,24 @@ public func channelMembers(postbox: Postbox, network: Network, accountPeerId: Pe
|
|||||||
case let .search(query):
|
case let .search(query):
|
||||||
apiFilter = .channelParticipantsSearch(q: query)
|
apiFilter = .channelParticipantsSearch(q: query)
|
||||||
}
|
}
|
||||||
|
case let .mentions(threadId, filter):
|
||||||
|
switch filter {
|
||||||
|
case .all:
|
||||||
|
var flags: Int32 = 0
|
||||||
|
if threadId != nil {
|
||||||
|
flags |= 1 << 1
|
||||||
|
}
|
||||||
|
apiFilter = .channelParticipantsMentions(flags: flags, q: nil, topMsgId: threadId?.id)
|
||||||
|
case let .search(query):
|
||||||
|
var flags: Int32 = 0
|
||||||
|
if threadId != nil {
|
||||||
|
flags |= 1 << 1
|
||||||
|
}
|
||||||
|
if !query.isEmpty {
|
||||||
|
flags |= 1 << 0
|
||||||
|
}
|
||||||
|
apiFilter = .channelParticipantsMentions(flags: flags, q: query.isEmpty ? nil : query, topMsgId: threadId?.id)
|
||||||
|
}
|
||||||
case .admins:
|
case .admins:
|
||||||
apiFilter = .channelParticipantsAdmins
|
apiFilter = .channelParticipantsAdmins
|
||||||
case let .contacts(filter):
|
case let .contacts(filter):
|
||||||
|
@ -189,9 +189,6 @@ final class ChatSearchInputPanelNode: ChatInputPanelNode {
|
|||||||
canSearchMembers = false
|
canSearchMembers = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if case .replyThread = interfaceState.chatLocation {
|
|
||||||
canSearchMembers = false
|
|
||||||
}
|
|
||||||
self.membersButton.isHidden = (!(interfaceState.search?.query.isEmpty ?? true)) || self.displayActivity || !canSearchMembers
|
self.membersButton.isHidden = (!(interfaceState.search?.query.isEmpty ?? true)) || self.displayActivity || !canSearchMembers
|
||||||
|
|
||||||
let resultsEnabled = (resultCount ?? 0) > 0
|
let resultsEnabled = (resultCount ?? 0) > 0
|
||||||
|
@ -64,6 +64,7 @@ public struct ChannelMemberListState {
|
|||||||
enum ChannelMemberListCategory {
|
enum ChannelMemberListCategory {
|
||||||
case recent
|
case recent
|
||||||
case recentSearch(String)
|
case recentSearch(String)
|
||||||
|
case mentions(MessageId?, String?)
|
||||||
case admins(String?)
|
case admins(String?)
|
||||||
case contacts(String?)
|
case contacts(String?)
|
||||||
case bots(String?)
|
case bots(String?)
|
||||||
@ -211,6 +212,12 @@ private final class ChannelMemberSingleCategoryListContext: ChannelMemberCategor
|
|||||||
requestCategory = .recent(.all)
|
requestCategory = .recent(.all)
|
||||||
case let .recentSearch(query):
|
case let .recentSearch(query):
|
||||||
requestCategory = .recent(.search(query))
|
requestCategory = .recent(.search(query))
|
||||||
|
case let .mentions(threadId, query):
|
||||||
|
if let query = query, !query.isEmpty {
|
||||||
|
requestCategory = .mentions(threadId: threadId, filter: .search(query))
|
||||||
|
} else {
|
||||||
|
requestCategory = .mentions(threadId: threadId, filter: .all)
|
||||||
|
}
|
||||||
case let .admins(query):
|
case let .admins(query):
|
||||||
requestCategory = .admins
|
requestCategory = .admins
|
||||||
adminQuery = query
|
adminQuery = query
|
||||||
@ -521,6 +528,8 @@ private final class ChannelMemberSingleCategoryListContext: ChannelMemberCategor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case .mentions:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if updatedList {
|
if updatedList {
|
||||||
@ -728,7 +737,7 @@ final class PeerChannelMemberCategoriesContext {
|
|||||||
emptyTimeout = 0.0
|
emptyTimeout = 0.0
|
||||||
}
|
}
|
||||||
switch key {
|
switch key {
|
||||||
case .recent, .recentSearch, .admins, .contacts, .bots:
|
case .recent, .recentSearch, .admins, .contacts, .bots, .mentions:
|
||||||
let mappedCategory: ChannelMemberListCategory
|
let mappedCategory: ChannelMemberListCategory
|
||||||
switch key {
|
switch key {
|
||||||
case .recent:
|
case .recent:
|
||||||
@ -741,6 +750,8 @@ final class PeerChannelMemberCategoriesContext {
|
|||||||
mappedCategory = .contacts(query)
|
mappedCategory = .contacts(query)
|
||||||
case let .bots(query):
|
case let .bots(query):
|
||||||
mappedCategory = .bots(query)
|
mappedCategory = .bots(query)
|
||||||
|
case let .mentions(threadId, query):
|
||||||
|
mappedCategory = .mentions(threadId, query)
|
||||||
default:
|
default:
|
||||||
mappedCategory = .recent
|
mappedCategory = .recent
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import TelegramStringFormatting
|
|||||||
enum PeerChannelMemberContextKey: Equatable, Hashable {
|
enum PeerChannelMemberContextKey: Equatable, Hashable {
|
||||||
case recent
|
case recent
|
||||||
case recentSearch(String)
|
case recentSearch(String)
|
||||||
|
case mentions(threadId: MessageId?, query: String?)
|
||||||
case admins(String?)
|
case admins(String?)
|
||||||
case contacts(String?)
|
case contacts(String?)
|
||||||
case bots(String?)
|
case bots(String?)
|
||||||
@ -321,6 +322,11 @@ public final class PeerChannelMemberCategoriesContextsManager {
|
|||||||
return self.getContext(postbox: postbox, network: network, accountPeerId: accountPeerId, peerId: peerId, key: key, requestUpdate: requestUpdate, updated: updated)
|
return self.getContext(postbox: postbox, network: network, accountPeerId: accountPeerId, peerId: peerId, key: key, requestUpdate: requestUpdate, updated: updated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func mentions(postbox: Postbox, network: Network, accountPeerId: PeerId, peerId: PeerId, threadMessageId: MessageId?, searchQuery: String? = nil, requestUpdate: Bool = true, updated: @escaping (ChannelMemberListState) -> Void) -> (Disposable, PeerChannelMemberCategoryControl?) {
|
||||||
|
let key: PeerChannelMemberContextKey = .mentions(threadId: threadMessageId, query: searchQuery)
|
||||||
|
return self.getContext(postbox: postbox, network: network, accountPeerId: accountPeerId, peerId: peerId, key: key, requestUpdate: requestUpdate, updated: updated)
|
||||||
|
}
|
||||||
|
|
||||||
public func admins(postbox: Postbox, network: Network, accountPeerId: PeerId, peerId: PeerId, searchQuery: String? = nil, updated: @escaping (ChannelMemberListState) -> Void) -> (Disposable, PeerChannelMemberCategoryControl?) {
|
public func admins(postbox: Postbox, network: Network, accountPeerId: PeerId, peerId: PeerId, searchQuery: String? = nil, updated: @escaping (ChannelMemberListState) -> Void) -> (Disposable, PeerChannelMemberCategoryControl?) {
|
||||||
return self.getContext(postbox: postbox, network: network, accountPeerId: accountPeerId, peerId: peerId, key: .admins(searchQuery), requestUpdate: true, updated: updated)
|
return self.getContext(postbox: postbox, network: network, accountPeerId: accountPeerId, peerId: peerId, key: .admins(searchQuery), requestUpdate: true, updated: updated)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user