mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-30 15:10:56 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
c7b77883bb
@ -1272,8 +1272,8 @@ public func openPostbox(basePath: String, seedConfiguration: SeedConfiguration,
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
//debugSaveState(basePath: basePath, name: "previous1")
|
||||
//debugRestoreState(basePath: basePath, name: "previous1")
|
||||
//debugSaveState(basePath: basePath + "/db", name: "previous1")
|
||||
debugRestoreState(basePath: basePath + "/db", name: "previous1")
|
||||
#endif
|
||||
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
@ -2438,6 +2438,8 @@ final class PostboxImpl {
|
||||
for id in messageIds {
|
||||
if self.messageHistoryIndexTable.exists(id) {
|
||||
filteredIds.insert(id)
|
||||
} else {
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,13 +78,7 @@ public extension TelegramChannel {
|
||||
if let adminRights = self.adminRights, adminRights.rights.contains(.canManageTopics) {
|
||||
return true
|
||||
}
|
||||
if let bannedRights = self.bannedRights, bannedRights.flags.contains(.banManageTopics) {
|
||||
return false
|
||||
}
|
||||
if let defaultBannedRights = self.defaultBannedRights, defaultBannedRights.flags.contains(.banManageTopics) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
case .createTopics:
|
||||
if self.flags.contains(.isCreator) {
|
||||
return true
|
||||
|
@ -1729,7 +1729,8 @@ public final class AccountViewTracker {
|
||||
tagMask: tagMask,
|
||||
appendMessagesFromTheSameGroup: false,
|
||||
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
|
||||
}
|
||||
|
||||
let titleSideInset: CGFloat = 3.0
|
||||
let titleSideInset: CGFloat = 6.0
|
||||
var titleFrame: CGRect
|
||||
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)
|
||||
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
|
||||
|
||||
if activitySize.height.isZero {
|
||||
|
@ -4933,7 +4933,37 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
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
|
||||
|
||||
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.threadInfo = messageAndTopic.threadData?.info
|
||||
|
||||
@ -5679,6 +5709,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|
||||
struct ReferenceMessage {
|
||||
var id: MessageId
|
||||
var minId: MessageId
|
||||
var isScrolled: Bool
|
||||
}
|
||||
|
||||
@ -5692,18 +5723,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self.chatDisplayNode.historyNode.topVisibleMessageRange.get()
|
||||
)
|
||||
|> map { scrolledToMessageId, topVisibleMessageRange -> ReferenceMessage? in
|
||||
let topVisibleMessage: MessageId?
|
||||
topVisibleMessage = topVisibleMessageRange?.upperBound.id
|
||||
let bottomVisibleMessage = topVisibleMessageRange?.lowerBound.id
|
||||
let topVisibleMessage = topVisibleMessageRange?.upperBound.id
|
||||
|
||||
if let scrolledToMessageId = scrolledToMessageId {
|
||||
if let topVisibleMessage = topVisibleMessage {
|
||||
if let topVisibleMessage, let bottomVisibleMessage {
|
||||
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)
|
||||
} else if let topVisibleMessage = topVisibleMessage {
|
||||
return ReferenceMessage(id: topVisibleMessage, isScrolled: false)
|
||||
return ReferenceMessage(id: scrolledToMessageId.id, minId: scrolledToMessageId.id, isScrolled: true)
|
||||
} else if let topVisibleMessage, let bottomVisibleMessage {
|
||||
return ReferenceMessage(id: topVisibleMessage, minId: bottomVisibleMessage, isScrolled: false)
|
||||
} else {
|
||||
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)
|
||||
}
|
||||
|
||||
@ -5940,6 +5976,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
matches = true
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ func chatHistoryEntriesForView(
|
||||
var adminRanks: [PeerId: CachedChannelAdminRank] = [:]
|
||||
var stickersEnabled = true
|
||||
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 {
|
||||
if case let .cacheEntry(id, data) = additionalEntry {
|
||||
if id == cachedChannelAdminRanksEntryId(peerId: peerId), let data = data?.get(CachedChannelAdminRanks.self) {
|
||||
|
@ -151,8 +151,8 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
|
||||
case .member:
|
||||
isMember = true
|
||||
case .left:
|
||||
if case .replyThread = chatPresentationInterfaceState.chatLocation {
|
||||
if !channel.flags.contains(.joinToSend) && !channel.flags.contains(.isForum) {
|
||||
if case let .replyThread(message) = chatPresentationInterfaceState.chatLocation {
|
||||
if !message.isForumPost && !channel.flags.contains(.joinToSend) {
|
||||
isMember = true
|
||||
}
|
||||
}
|
||||
|
@ -1397,9 +1397,17 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
authorRank = attributes.rank
|
||||
}
|
||||
|
||||
if authorRank == nil, let topicAuthorId = item.associatedData.topicAuthorId, topicAuthorId == message.author?.id {
|
||||
var enableAutoRank = false
|
||||
if case .admin = authorRank {
|
||||
} else if case .owner = authorRank {
|
||||
} else if authorRank == nil {
|
||||
enableAutoRank = true
|
||||
}
|
||||
if enableAutoRank {
|
||||
if let topicAuthorId = item.associatedData.topicAuthorId, topicAuthorId == message.author?.id {
|
||||
authorRank = .custom(item.presentationData.strings.Chat_Message_TopicAuthorBadge)
|
||||
}
|
||||
}
|
||||
case .group:
|
||||
break
|
||||
}
|
||||
|
@ -1211,10 +1211,10 @@ func peerInfoCanEdit(peer: Peer?, threadData: MessageHistoryThreadData?, cachedD
|
||||
}
|
||||
return true
|
||||
} 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) {
|
||||
return true
|
||||
} else if let threadData = threadData, threadData.isOwnedByMe {
|
||||
} else if threadData.isOwnedByMe {
|
||||
return true
|
||||
} else if peer.hasPermission(.manageTopics) {
|
||||
return true
|
||||
|
@ -741,7 +741,6 @@ public final class OngoingCallContext {
|
||||
return OngoingCallThreadLocalContext.maxLayer()
|
||||
}
|
||||
|
||||
private let tempLogFile: EngineTempBoxFile
|
||||
private let tempStatsLogFile: EngineTempBoxFile
|
||||
|
||||
private var signalingConnectionManager: QueueLocalObject<CallSignalingConnectionManager>?
|
||||
@ -774,8 +773,8 @@ public final class OngoingCallContext {
|
||||
self.callSessionManager = callSessionManager
|
||||
self.logPath = logName.isEmpty ? "" : callLogsPath(account: self.account) + "/" + logName + ".log"
|
||||
let logPath = self.logPath
|
||||
self.tempLogFile = EngineTempBox.shared.tempFile(fileName: "CallLog.txt")
|
||||
let tempLogPath = self.tempLogFile.path
|
||||
|
||||
let _ = try? FileManager.default.createDirectory(atPath: callLogsPath(account: account), withIntermediateDirectories: true, attributes: nil)
|
||||
|
||||
self.tempStatsLogFile = EngineTempBox.shared.tempFile(fileName: "CallStats.json")
|
||||
let tempStatsLogPath = self.tempStatsLogFile.path
|
||||
@ -880,7 +879,7 @@ public final class OngoingCallContext {
|
||||
}
|
||||
}
|
||||
|
||||
let context = OngoingCallThreadLocalContextWebrtc(version: version, queue: OngoingCallThreadLocalContextQueueImpl(queue: queue), proxy: voipProxyServer, networkType: ongoingNetworkTypeForTypeWebrtc(initialNetworkType), dataSaving: ongoingDataSavingForTypeWebrtc(dataSaving), derivedState: Data(), key: key, isOutgoing: isOutgoing, connections: filteredConnections, maxLayer: maxLayer, allowP2P: allowP2P, allowTCP: enableTCP, enableStunMarking: enableStunMarking, logPath: tempLogPath, statsLogPath: tempStatsLogPath, sendSignalingData: { [weak callSessionManager] data in
|
||||
let context = OngoingCallThreadLocalContextWebrtc(version: version, queue: OngoingCallThreadLocalContextQueueImpl(queue: queue), proxy: voipProxyServer, networkType: ongoingNetworkTypeForTypeWebrtc(initialNetworkType), dataSaving: ongoingDataSavingForTypeWebrtc(dataSaving), derivedState: Data(), key: key, isOutgoing: isOutgoing, connections: filteredConnections, maxLayer: maxLayer, allowP2P: allowP2P, allowTCP: enableTCP, enableStunMarking: enableStunMarking, logPath: logPath, statsLogPath: tempStatsLogPath, sendSignalingData: { [weak callSessionManager] data in
|
||||
queue.async {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
@ -1068,7 +1067,6 @@ public final class OngoingCallContext {
|
||||
if !logPath.isEmpty {
|
||||
statsLogPath = logPath + ".json"
|
||||
}
|
||||
let tempLogPath = self.tempLogFile.path
|
||||
let tempStatsLogPath = self.tempStatsLogFile.path
|
||||
|
||||
self.withContextThenDeallocate { context in
|
||||
@ -1082,12 +1080,6 @@ public final class OngoingCallContext {
|
||||
outgoing: bytesSentWifi))
|
||||
updateAccountNetworkUsageStats(account: self.account, category: .call, delta: delta)
|
||||
|
||||
if !logPath.isEmpty {
|
||||
let logsPath = callLogsPath(account: account)
|
||||
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
|
||||
let _ = try? FileManager.default.moveItem(atPath: tempLogPath, toPath: logPath)
|
||||
}
|
||||
|
||||
if !statsLogPath.isEmpty {
|
||||
let logsPath = callLogsPath(account: account)
|
||||
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user