mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Topic improvements
This commit is contained in:
parent
3fde9cf033
commit
130c9264e1
@ -524,9 +524,9 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
default:
|
default:
|
||||||
let actionTitle: String
|
let actionTitle: String
|
||||||
if channel.flags.contains(.requestToJoin) {
|
if channel.flags.contains(.requestToJoin) {
|
||||||
actionTitle = strongSelf.presentationData.strings.Channel_JoinChannel
|
|
||||||
} else {
|
|
||||||
actionTitle = strongSelf.presentationData.strings.Group_ApplyToJoin
|
actionTitle = strongSelf.presentationData.strings.Group_ApplyToJoin
|
||||||
|
} else {
|
||||||
|
actionTitle = strongSelf.presentationData.strings.Channel_JoinChannel
|
||||||
}
|
}
|
||||||
strongSelf.setToolbar(Toolbar(leftAction: nil, rightAction: nil, middleAction: ToolbarAction(title: actionTitle, isEnabled: true)), transition: .animated(duration: 0.4, curve: .spring))
|
strongSelf.setToolbar(Toolbar(leftAction: nil, rightAction: nil, middleAction: ToolbarAction(title: actionTitle, isEnabled: true)), transition: .animated(duration: 0.4, curve: .spring))
|
||||||
}
|
}
|
||||||
|
@ -1257,6 +1257,7 @@ final class ChatListControllerNode: ASDisplayNode {
|
|||||||
insets.top += navigationBarHeight
|
insets.top += navigationBarHeight
|
||||||
insets.left += layout.safeInsets.left
|
insets.left += layout.safeInsets.left
|
||||||
insets.right += layout.safeInsets.right
|
insets.right += layout.safeInsets.right
|
||||||
|
var additionalPanelInset: CGFloat = 0.0
|
||||||
|
|
||||||
if let toolbar = self.toolbar {
|
if let toolbar = self.toolbar {
|
||||||
var tabBarHeight: CGFloat
|
var tabBarHeight: CGFloat
|
||||||
@ -1268,9 +1269,11 @@ final class ChatListControllerNode: ASDisplayNode {
|
|||||||
if !layout.safeInsets.left.isZero {
|
if !layout.safeInsets.left.isZero {
|
||||||
tabBarHeight = 34.0 + bottomInset
|
tabBarHeight = 34.0 + bottomInset
|
||||||
insets.bottom += 34.0
|
insets.bottom += 34.0
|
||||||
|
additionalPanelInset += 34.0
|
||||||
} else {
|
} else {
|
||||||
tabBarHeight = 49.0 + bottomInset
|
tabBarHeight = 49.0 + bottomInset
|
||||||
insets.bottom += 49.0
|
insets.bottom += 49.0
|
||||||
|
additionalPanelInset += 49.0
|
||||||
}
|
}
|
||||||
|
|
||||||
let tabBarFrame = CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - tabBarHeight), size: CGSize(width: layout.size.width, height: tabBarHeight))
|
let tabBarFrame = CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - tabBarHeight), size: CGSize(width: layout.size.width, height: tabBarHeight))
|
||||||
@ -1302,11 +1305,13 @@ final class ChatListControllerNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var childrenLayout = layout
|
var childrenLayout = layout
|
||||||
childrenLayout.intrinsicInsets = UIEdgeInsets(top: visualNavigationHeight, left: childrenLayout.intrinsicInsets.left, bottom: childrenLayout.intrinsicInsets.bottom, right: childrenLayout.intrinsicInsets.right)
|
childrenLayout.intrinsicInsets = UIEdgeInsets(top: visualNavigationHeight, left: childrenLayout.intrinsicInsets.left, bottom: childrenLayout.intrinsicInsets.bottom + additionalPanelInset, right: childrenLayout.intrinsicInsets.right)
|
||||||
self.controller?.presentationContext.containerLayoutUpdated(childrenLayout, transition: transition)
|
self.controller?.presentationContext.containerLayoutUpdated(childrenLayout, transition: transition)
|
||||||
|
|
||||||
transition.updateFrame(node: self.containerNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
transition.updateFrame(node: self.containerNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
||||||
self.containerNode.update(layout: layout, navigationBarHeight: navigationBarHeight, visualNavigationHeight: visualNavigationHeight, cleanNavigationBarHeight: cleanNavigationBarHeight, isReorderingFilters: self.isReorderingFilters, isEditing: self.isEditing, transition: transition)
|
var containerLayout = layout
|
||||||
|
containerLayout.intrinsicInsets.bottom += additionalPanelInset
|
||||||
|
self.containerNode.update(layout: containerLayout, navigationBarHeight: navigationBarHeight, visualNavigationHeight: visualNavigationHeight, cleanNavigationBarHeight: cleanNavigationBarHeight, isReorderingFilters: self.isReorderingFilters, isEditing: self.isEditing, transition: transition)
|
||||||
|
|
||||||
transition.updateFrame(node: self.inlineTabContainerNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - layout.intrinsicInsets.bottom - 8.0 - 40.0), size: CGSize(width: layout.size.width, height: 40.0)))
|
transition.updateFrame(node: self.inlineTabContainerNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - layout.intrinsicInsets.bottom - 8.0 - 40.0), size: CGSize(width: layout.size.width, height: 40.0)))
|
||||||
|
|
||||||
|
@ -1210,7 +1210,7 @@ public enum PostboxResult {
|
|||||||
case error
|
case error
|
||||||
}
|
}
|
||||||
|
|
||||||
func debugSaveState(basePath:String, name: String) {
|
func debugSaveState(basePath: String, name: String) {
|
||||||
let path = basePath + name
|
let path = basePath + name
|
||||||
let _ = try? FileManager.default.removeItem(atPath: path)
|
let _ = try? FileManager.default.removeItem(atPath: path)
|
||||||
do {
|
do {
|
||||||
@ -1220,7 +1220,7 @@ func debugSaveState(basePath:String, name: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func debugRestoreState(basePath:String, name: String) {
|
func debugRestoreState(basePath: String, name: String) {
|
||||||
let path = basePath + name
|
let path = basePath + name
|
||||||
if FileManager.default.fileExists(atPath: path) {
|
if FileManager.default.fileExists(atPath: path) {
|
||||||
let _ = try? FileManager.default.removeItem(atPath: basePath)
|
let _ = try? FileManager.default.removeItem(atPath: basePath)
|
||||||
@ -1272,8 +1272,8 @@ public func openPostbox(basePath: String, seedConfiguration: SeedConfiguration,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
//debugSaveState(basePath: basePath, name: "previous1")
|
//debugSaveState(basePath: basePath + "/db", name: "previous1")
|
||||||
//debugRestoreState(basePath: basePath, name: "previous1")
|
debugRestoreState(basePath: basePath + "/db", name: "previous1")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
let startTime = CFAbsoluteTimeGetCurrent()
|
let startTime = CFAbsoluteTimeGetCurrent()
|
||||||
@ -2438,6 +2438,8 @@ final class PostboxImpl {
|
|||||||
for id in messageIds {
|
for id in messageIds {
|
||||||
if self.messageHistoryIndexTable.exists(id) {
|
if self.messageHistoryIndexTable.exists(id) {
|
||||||
filteredIds.insert(id)
|
filteredIds.insert(id)
|
||||||
|
} else {
|
||||||
|
assert(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,13 +78,7 @@ public extension TelegramChannel {
|
|||||||
if let adminRights = self.adminRights, adminRights.rights.contains(.canManageTopics) {
|
if let adminRights = self.adminRights, adminRights.rights.contains(.canManageTopics) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if let bannedRights = self.bannedRights, bannedRights.flags.contains(.banManageTopics) {
|
return false
|
||||||
return false
|
|
||||||
}
|
|
||||||
if let defaultBannedRights = self.defaultBannedRights, defaultBannedRights.flags.contains(.banManageTopics) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
case .createTopics:
|
case .createTopics:
|
||||||
if self.flags.contains(.isCreator) {
|
if self.flags.contains(.isCreator) {
|
||||||
return true
|
return true
|
||||||
|
@ -1729,7 +1729,8 @@ public final class AccountViewTracker {
|
|||||||
tagMask: tagMask,
|
tagMask: tagMask,
|
||||||
appendMessagesFromTheSameGroup: false,
|
appendMessagesFromTheSameGroup: false,
|
||||||
namespaces: .not(Namespaces.Message.allScheduled),
|
namespaces: .not(Namespaces.Message.allScheduled),
|
||||||
orderStatistics: orderStatistics
|
orderStatistics: orderStatistics,
|
||||||
|
additionalData: wrappedHistoryViewAdditionalData(chatLocation: chatLocation, additionalData: additionalData)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,12 +728,12 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
|||||||
titleTransition = .immediate
|
titleTransition = .immediate
|
||||||
}
|
}
|
||||||
|
|
||||||
let titleSideInset: CGFloat = 3.0
|
let titleSideInset: CGFloat = 6.0
|
||||||
var titleFrame: CGRect
|
var titleFrame: CGRect
|
||||||
if size.height > 40.0 {
|
if size.height > 40.0 {
|
||||||
var titleSize = self.titleTextNode.updateLayout(size: CGSize(width: clearBounds.width - leftIconWidth - credibilityIconWidth - rightIconWidth - titleSideInset * 2.0, height: size.height), animated: titleTransition.isAnimated)
|
var titleSize = self.titleTextNode.updateLayout(size: CGSize(width: clearBounds.width - leftIconWidth - credibilityIconWidth - rightIconWidth - titleSideInset * 2.0, height: size.height), animated: titleTransition.isAnimated)
|
||||||
titleSize.width += credibilityIconWidth
|
titleSize.width += credibilityIconWidth
|
||||||
let activitySize = self.activityNode.updateLayout(clearBounds.size, alignment: .center)
|
let activitySize = self.activityNode.updateLayout(CGSize(width: clearBounds.size.width - titleSideInset * 2.0, height: clearBounds.size.height), alignment: .center)
|
||||||
let titleInfoSpacing: CGFloat = 0.0
|
let titleInfoSpacing: CGFloat = 0.0
|
||||||
|
|
||||||
if activitySize.height.isZero {
|
if activitySize.height.isZero {
|
||||||
|
@ -4924,7 +4924,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
let avatarContent: EmojiStatusComponent.Content
|
let avatarContent: EmojiStatusComponent.Content
|
||||||
if let fileId = threadInfo.icon {
|
if let fileId = threadInfo.icon {
|
||||||
avatarContent = .animation(content: .customEmoji(fileId: fileId), size: CGSize(width: 48.0, height: 48.0), placeholderColor: strongSelf.presentationData.theme.list.mediaPlaceholderColor, themeColor: strongSelf.presentationData.theme.list.itemAccentColor, loopMode: .count(2))
|
avatarContent = .animation(content: .customEmoji(fileId: fileId), size: CGSize(width: 48.0, height: 48.0), placeholderColor: strongSelf.presentationData.theme.list.mediaPlaceholderColor, themeColor: strongSelf.presentationData.theme.list.itemAccentColor, loopMode: .count(1))
|
||||||
} else {
|
} else {
|
||||||
avatarContent = .topic(title: String(threadInfo.title.prefix(1)), color: threadInfo.iconColor, size: CGSize(width: 32.0, height: 32.0))
|
avatarContent = .topic(title: String(threadInfo.title.prefix(1)), color: threadInfo.iconColor, size: CGSize(width: 32.0, height: 32.0))
|
||||||
}
|
}
|
||||||
@ -4933,7 +4933,37 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
strongSelf.chatTitleView?.titleContent = .replyThread(type: replyThreadType, count: count)
|
strongSelf.chatTitleView?.titleContent = .replyThread(type: replyThreadType, count: count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var wasGroupChannel: Bool?
|
||||||
|
if let previousPeerView = strongSelf.peerView, let info = (previousPeerView.peers[previousPeerView.peerId] as? TelegramChannel)?.info {
|
||||||
|
if case .group = info {
|
||||||
|
wasGroupChannel = true
|
||||||
|
} else {
|
||||||
|
wasGroupChannel = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var isGroupChannel: Bool?
|
||||||
|
if let info = (peerView.peers[peerView.peerId] as? TelegramChannel)?.info {
|
||||||
|
if case .group = info {
|
||||||
|
isGroupChannel = true
|
||||||
|
} else {
|
||||||
|
isGroupChannel = false
|
||||||
|
}
|
||||||
|
}
|
||||||
let firstTime = strongSelf.peerView == nil
|
let firstTime = strongSelf.peerView == nil
|
||||||
|
|
||||||
|
if wasGroupChannel != isGroupChannel {
|
||||||
|
if let isGroupChannel = isGroupChannel, isGroupChannel {
|
||||||
|
let (recentDisposable, _) = strongSelf.context.peerChannelMemberCategoriesContextsManager.recent(engine: strongSelf.context.engine, postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, accountPeerId: context.account.peerId, peerId: peerView.peerId, updated: { _ in })
|
||||||
|
let (adminsDisposable, _) = strongSelf.context.peerChannelMemberCategoriesContextsManager.admins(engine: strongSelf.context.engine, postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, accountPeerId: context.account.peerId, peerId: peerView.peerId, updated: { _ in })
|
||||||
|
let disposable = DisposableSet()
|
||||||
|
disposable.add(recentDisposable)
|
||||||
|
disposable.add(adminsDisposable)
|
||||||
|
strongSelf.chatAdditionalDataDisposable.set(disposable)
|
||||||
|
} else {
|
||||||
|
strongSelf.chatAdditionalDataDisposable.set(nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
strongSelf.peerView = peerView
|
strongSelf.peerView = peerView
|
||||||
strongSelf.threadInfo = messageAndTopic.threadData?.info
|
strongSelf.threadInfo = messageAndTopic.threadData?.info
|
||||||
|
|
||||||
@ -5679,6 +5709,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
struct ReferenceMessage {
|
struct ReferenceMessage {
|
||||||
var id: MessageId
|
var id: MessageId
|
||||||
|
var minId: MessageId
|
||||||
var isScrolled: Bool
|
var isScrolled: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5692,18 +5723,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
self.chatDisplayNode.historyNode.topVisibleMessageRange.get()
|
self.chatDisplayNode.historyNode.topVisibleMessageRange.get()
|
||||||
)
|
)
|
||||||
|> map { scrolledToMessageId, topVisibleMessageRange -> ReferenceMessage? in
|
|> map { scrolledToMessageId, topVisibleMessageRange -> ReferenceMessage? in
|
||||||
let topVisibleMessage: MessageId?
|
let bottomVisibleMessage = topVisibleMessageRange?.lowerBound.id
|
||||||
topVisibleMessage = topVisibleMessageRange?.upperBound.id
|
let topVisibleMessage = topVisibleMessageRange?.upperBound.id
|
||||||
|
|
||||||
if let scrolledToMessageId = scrolledToMessageId {
|
if let scrolledToMessageId = scrolledToMessageId {
|
||||||
if let topVisibleMessage = topVisibleMessage {
|
if let topVisibleMessage, let bottomVisibleMessage {
|
||||||
if scrolledToMessageId.allowedReplacementDirection.contains(.up) && topVisibleMessage < scrolledToMessageId.id {
|
if scrolledToMessageId.allowedReplacementDirection.contains(.up) && topVisibleMessage < scrolledToMessageId.id {
|
||||||
return ReferenceMessage(id: topVisibleMessage, isScrolled: false)
|
return ReferenceMessage(id: topVisibleMessage, minId: bottomVisibleMessage, isScrolled: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ReferenceMessage(id: scrolledToMessageId.id, isScrolled: true)
|
return ReferenceMessage(id: scrolledToMessageId.id, minId: scrolledToMessageId.id, isScrolled: true)
|
||||||
} else if let topVisibleMessage = topVisibleMessage {
|
} else if let topVisibleMessage, let bottomVisibleMessage {
|
||||||
return ReferenceMessage(id: topVisibleMessage, isScrolled: false)
|
return ReferenceMessage(id: topVisibleMessage, minId: bottomVisibleMessage, isScrolled: false)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -5917,6 +5948,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if threadId != nil {
|
||||||
|
if referenceMessage.minId <= topMessage.message.id {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
return ChatPinnedMessage(message: topMessage.message, index: index, totalCount: pinnedMessages.totalCount, topMessageId: topMessageId)
|
return ChatPinnedMessage(message: topMessage.message, index: index, totalCount: pinnedMessages.totalCount, topMessageId: topMessageId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5940,6 +5976,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
matches = true
|
matches = true
|
||||||
}
|
}
|
||||||
if matches {
|
if matches {
|
||||||
|
if threadId != nil, let referenceMessage {
|
||||||
|
if referenceMessage.minId <= entry.message.id {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
message = ChatPinnedMessage(message: entry.message, index: entry.index, totalCount: pinnedMessages.totalCount, topMessageId: topMessageId)
|
message = ChatPinnedMessage(message: entry.message, index: entry.index, totalCount: pinnedMessages.totalCount, topMessageId: topMessageId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ func chatHistoryEntriesForView(
|
|||||||
var adminRanks: [PeerId: CachedChannelAdminRank] = [:]
|
var adminRanks: [PeerId: CachedChannelAdminRank] = [:]
|
||||||
var stickersEnabled = true
|
var stickersEnabled = true
|
||||||
var channelPeer: Peer?
|
var channelPeer: Peer?
|
||||||
if case let .peer(peerId) = location, peerId.namespace == Namespaces.Peer.CloudChannel {
|
if let peerId = location.peerId, peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||||
for additionalEntry in view.additionalData {
|
for additionalEntry in view.additionalData {
|
||||||
if case let .cacheEntry(id, data) = additionalEntry {
|
if case let .cacheEntry(id, data) = additionalEntry {
|
||||||
if id == cachedChannelAdminRanksEntryId(peerId: peerId), let data = data?.get(CachedChannelAdminRanks.self) {
|
if id == cachedChannelAdminRanksEntryId(peerId: peerId), let data = data?.get(CachedChannelAdminRanks.self) {
|
||||||
|
@ -151,8 +151,8 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
|
|||||||
case .member:
|
case .member:
|
||||||
isMember = true
|
isMember = true
|
||||||
case .left:
|
case .left:
|
||||||
if case .replyThread = chatPresentationInterfaceState.chatLocation {
|
if case let .replyThread(message) = chatPresentationInterfaceState.chatLocation {
|
||||||
if !channel.flags.contains(.joinToSend) {
|
if !message.isForumPost && !channel.flags.contains(.joinToSend) {
|
||||||
isMember = true
|
isMember = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1398,8 +1398,8 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
}
|
}
|
||||||
|
|
||||||
var enableAutoRank = false
|
var enableAutoRank = false
|
||||||
if let authorRank = authorRank, case .admin = authorRank {
|
if case .admin = authorRank {
|
||||||
enableAutoRank = true
|
} else if case .owner = authorRank {
|
||||||
} else if authorRank == nil {
|
} else if authorRank == nil {
|
||||||
enableAutoRank = true
|
enableAutoRank = true
|
||||||
}
|
}
|
||||||
|
@ -1211,10 +1211,10 @@ func peerInfoCanEdit(peer: Peer?, threadData: MessageHistoryThreadData?, cachedD
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
} else if let peer = peer as? TelegramChannel {
|
} else if let peer = peer as? TelegramChannel {
|
||||||
if peer.flags.contains(.isForum) {
|
if peer.flags.contains(.isForum), let threadData = threadData {
|
||||||
if peer.flags.contains(.isCreator) {
|
if peer.flags.contains(.isCreator) {
|
||||||
return true
|
return true
|
||||||
} else if let threadData = threadData, threadData.isOwnedByMe {
|
} else if threadData.isOwnedByMe {
|
||||||
return true
|
return true
|
||||||
} else if peer.hasPermission(.manageTopics) {
|
} else if peer.hasPermission(.manageTopics) {
|
||||||
return true
|
return true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user