mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
[WIP] Topics
This commit is contained in:
@@ -81,6 +81,7 @@ swift_library(
|
|||||||
"//submodules/TelegramUI/Components/ForumCreateTopicScreen:ForumCreateTopicScreen",
|
"//submodules/TelegramUI/Components/ForumCreateTopicScreen:ForumCreateTopicScreen",
|
||||||
"//submodules/TelegramUI/Components/ChatTitleView",
|
"//submodules/TelegramUI/Components/ChatTitleView",
|
||||||
"//submodules/AnimationUI:AnimationUI",
|
"//submodules/AnimationUI:AnimationUI",
|
||||||
|
"//submodules/PeerInfoUI",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import TelegramStringFormatting
|
|||||||
import ForumCreateTopicScreen
|
import ForumCreateTopicScreen
|
||||||
import AnimationUI
|
import AnimationUI
|
||||||
import ChatTitleView
|
import ChatTitleView
|
||||||
|
import PeerInfoUI
|
||||||
|
|
||||||
private func fixListNodeScrolling(_ listNode: ListView, searchNode: NavigationBarSearchContentNode) -> Bool {
|
private func fixListNodeScrolling(_ listNode: ListView, searchNode: NavigationBarSearchContentNode) -> Bool {
|
||||||
if listNode.scroller.isDragging {
|
if listNode.scroller.isDragging {
|
||||||
@@ -342,6 +343,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
|
|
||||||
private let selectAddMemberDisposable = MetaDisposable()
|
private let selectAddMemberDisposable = MetaDisposable()
|
||||||
private let addMemberDisposable = MetaDisposable()
|
private let addMemberDisposable = MetaDisposable()
|
||||||
|
private let joinForumDisposable = MetaDisposable()
|
||||||
|
|
||||||
public override func updateNavigationCustomData(_ data: Any?, progress: CGFloat, transition: ContainedViewLayoutTransition) {
|
public override func updateNavigationCustomData(_ data: Any?, progress: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||||
if self.isNodeLoaded {
|
if self.isNodeLoaded {
|
||||||
@@ -499,6 +501,16 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
navigationController.replaceController(strongSelf, with: chatController, animated: true)
|
navigationController.replaceController(strongSelf, with: chatController, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let channel = peerView.peers[peerView.peerId] as? TelegramChannel {
|
||||||
|
switch channel.participationStatus {
|
||||||
|
case .member:
|
||||||
|
strongSelf.setToolbar(nil, transition: .animated(duration: 0.4, curve: .spring))
|
||||||
|
default:
|
||||||
|
//TODO:localize
|
||||||
|
strongSelf.setToolbar(Toolbar(leftAction: nil, rightAction: nil, middleAction: ToolbarAction(title: "Join", isEnabled: true)), transition: .animated(duration: 0.4, curve: .spring))
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1148,6 +1160,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
self.activeDownloadsDisposable?.dispose()
|
self.activeDownloadsDisposable?.dispose()
|
||||||
self.selectAddMemberDisposable.dispose()
|
self.selectAddMemberDisposable.dispose()
|
||||||
self.addMemberDisposable.dispose()
|
self.addMemberDisposable.dispose()
|
||||||
|
self.joinForumDisposable.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func openStatusSetup(sourceView: UIView) {
|
private func openStatusSetup(sourceView: UIView) {
|
||||||
@@ -3108,22 +3121,74 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
])
|
])
|
||||||
])
|
])
|
||||||
self.present(actionSheet, in: .window(.root))
|
self.present(actionSheet, in: .window(.root))
|
||||||
} else if case .middle = action, !peerIds.isEmpty {
|
} else if case .middle = action {
|
||||||
if case .chatList(.root) = self.location {
|
switch self.location {
|
||||||
self.donePressed()
|
case let .chatList(groupId):
|
||||||
self.archiveChats(peerIds: Array(peerIds))
|
|
||||||
} else {
|
|
||||||
if !peerIds.isEmpty {
|
if !peerIds.isEmpty {
|
||||||
self.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingPeerId(peerIds.first!)
|
if groupId == .root {
|
||||||
let _ = (self.context.engine.peers.updatePeersGroupIdInteractively(peerIds: Array(peerIds), groupId: .root)
|
self.donePressed()
|
||||||
|> deliverOnMainQueue).start(completed: { [weak self] in
|
self.archiveChats(peerIds: Array(peerIds))
|
||||||
guard let strongSelf = self else {
|
} else {
|
||||||
|
if !peerIds.isEmpty {
|
||||||
|
self.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingPeerId(peerIds.first!)
|
||||||
|
let _ = (self.context.engine.peers.updatePeersGroupIdInteractively(peerIds: Array(peerIds), groupId: .root)
|
||||||
|
|> deliverOnMainQueue).start(completed: { [weak self] in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingPeerId(nil)
|
||||||
|
strongSelf.donePressed()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case let .forum(peerId):
|
||||||
|
self.joinForumDisposable.set((self.context.peerChannelMemberCategoriesContextsManager.join(engine: context.engine, peerId: peerId, hash: nil)
|
||||||
|
|> afterDisposed { [weak self] in
|
||||||
|
Queue.mainQueue().async {
|
||||||
|
if let strongSelf = self {
|
||||||
|
let _ = strongSelf
|
||||||
|
/*strongSelf.activityIndicator.isHidden = true
|
||||||
|
strongSelf.activityIndicator.stopAnimating()
|
||||||
|
strongSelf.isJoining = false*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start(error: { [weak self] error in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let _ = (strongSelf.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|
||||||
|
|> deliverOnMainQueue).start(next: { peer in
|
||||||
|
guard let strongSelf = self, let peer = peer else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingPeerId(nil)
|
|
||||||
strongSelf.donePressed()
|
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
|
||||||
|
let text: String
|
||||||
|
switch error {
|
||||||
|
case .inviteRequestSent:
|
||||||
|
strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .inviteRequestSent(title: presentationData.strings.Group_RequestToJoinSent, text: presentationData.strings.Group_RequestToJoinSentDescriptionGroup ), elevatedLayout: true, animateInAsReplacement: false, action: { _ in return false }), in: .window(.root))
|
||||||
|
return
|
||||||
|
case .tooMuchJoined:
|
||||||
|
(strongSelf.navigationController as? NavigationController)?.pushViewController(oldChannelsController(context: strongSelf.context, intent: .join, completed: { value in
|
||||||
|
if value {
|
||||||
|
self?.toolbarActionSelected(action: .middle)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
return
|
||||||
|
case .tooMuchUsers:
|
||||||
|
text = presentationData.strings.Conversation_UsersTooMuchError
|
||||||
|
case .generic:
|
||||||
|
if case let .channel(channel) = peer, case .broadcast = channel.info {
|
||||||
|
text = presentationData.strings.Channel_ErrorAccessDenied
|
||||||
|
} else {
|
||||||
|
text = presentationData.strings.Group_ErrorAccessDenied
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||||
})
|
})
|
||||||
}
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public func updatePeers(transaction: Transaction, peers: [Peer], update: (Peer?,
|
|||||||
if let channel = updated as? TelegramChannel {
|
if let channel = updated as? TelegramChannel {
|
||||||
switch channel.participationStatus {
|
switch channel.participationStatus {
|
||||||
case .member:
|
case .member:
|
||||||
updatePeerChatInclusionWithMinTimestamp(transaction: transaction, id: peerId, minTimestamp: channel.creationDate, forceRootGroupIfNotExists: false)
|
updatePeerChatInclusionWithMinTimestamp(transaction: transaction, id: peerId, minTimestamp: channel.creationDate, forceRootGroupIfNotExists: true)
|
||||||
case .left:
|
case .left:
|
||||||
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
transaction.updatePeerChatListInclusion(peerId, inclusion: .notIncluded)
|
||||||
case .kicked where channel.creationDate == 0:
|
case .kicked where channel.creationDate == 0:
|
||||||
|
|||||||
@@ -15673,7 +15673,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let navigationController = strongSelf.effectiveNavigationController {
|
} else if let navigationController = strongSelf.effectiveNavigationController {
|
||||||
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(id: peerId.id), subject: subject, keepStack: .always, peekData: peekData))
|
if case let .channel(channel) = peerId, channel.flags.contains(.isForum) {
|
||||||
|
strongSelf.context.sharedContext.navigateToForumChannel(context: strongSelf.context, peerId: peerId.id, navigationController: navigationController)
|
||||||
|
} else {
|
||||||
|
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(id: peerId.id), subject: subject, keepStack: .always, peekData: peekData))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case .info:
|
case .info:
|
||||||
strongSelf.navigationActionDisposable.set((strongSelf.context.account.postbox.loadedPeerWithId(peerId.id)
|
strongSelf.navigationActionDisposable.set((strongSelf.context.account.postbox.loadedPeerWithId(peerId.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user