mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Fix voice chats in legacy groups
This commit is contained in:
parent
5096e5c84d
commit
22f9a91f97
@ -1424,6 +1424,12 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
online = true
|
online = true
|
||||||
}
|
}
|
||||||
animateOnline = true
|
animateOnline = true
|
||||||
|
} else if let group = renderedPeer.peer as? TelegramGroup {
|
||||||
|
onlineIsVoiceChat = true
|
||||||
|
if group.flags.contains(.hasActiveVoiceChat) && item.interaction.searchTextHighightState == nil {
|
||||||
|
online = true
|
||||||
|
}
|
||||||
|
animateOnline = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ public struct TelegramGroupFlags: OptionSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static let deactivated = TelegramGroupFlags(rawValue: 1 << 1)
|
public static let deactivated = TelegramGroupFlags(rawValue: 1 << 1)
|
||||||
|
public static let hasVoiceChat = TelegramGroupFlags(rawValue: 1 << 2)
|
||||||
|
public static let hasActiveVoiceChat = TelegramGroupFlags(rawValue: 1 << 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct TelegramGroupToChannelMigrationReference: Equatable {
|
public struct TelegramGroupToChannelMigrationReference: Equatable {
|
||||||
|
@ -51,6 +51,12 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
|||||||
if (flags & (1 << 5)) != 0 {
|
if (flags & (1 << 5)) != 0 {
|
||||||
groupFlags.insert(.deactivated)
|
groupFlags.insert(.deactivated)
|
||||||
}
|
}
|
||||||
|
if (flags & Int32(1 << 23)) != 0 {
|
||||||
|
groupFlags.insert(.hasVoiceChat)
|
||||||
|
}
|
||||||
|
if (flags & Int32(1 << 24)) != 0 {
|
||||||
|
groupFlags.insert(.hasActiveVoiceChat)
|
||||||
|
}
|
||||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: title, photo: imageRepresentationsForApiChatPhoto(photo), participantCount: Int(participantsCount), role: role, membership: left ? .Left : .Member, flags: groupFlags, defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init(apiBannedRights:)), migrationReference: migrationReference, creationDate: date, version: Int(version))
|
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: title, photo: imageRepresentationsForApiChatPhoto(photo), participantCount: Int(participantsCount), role: role, membership: left ? .Left : .Member, flags: groupFlags, defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init(apiBannedRights:)), migrationReference: migrationReference, creationDate: date, version: Int(version))
|
||||||
case let .chatEmpty(id):
|
case let .chatEmpty(id):
|
||||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: "", photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0)
|
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: "", photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0)
|
||||||
|
@ -522,6 +522,15 @@ public func stopGroupCall(account: Account, peerId: PeerId, callId: Int64, acces
|
|||||||
return updated
|
return updated
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if var peer = transaction.getPeer(peerId) as? TelegramGroup {
|
||||||
|
var flags = peer.flags
|
||||||
|
flags.remove(.hasVoiceChat)
|
||||||
|
flags.remove(.hasActiveVoiceChat)
|
||||||
|
peer = peer.updateFlags(flags: flags, version: peer.version)
|
||||||
|
updatePeers(transaction: transaction, peers: [peer], update: { _, updated in
|
||||||
|
return updated
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
account.stateManager.addUpdates(result)
|
account.stateManager.addUpdates(result)
|
||||||
}
|
}
|
||||||
|
@ -1055,6 +1055,11 @@ func peerInfoHeaderButtons(peer: Peer?, cachedData: CachedPeerData?, isOpenedFro
|
|||||||
var canAddMembers = false
|
var canAddMembers = false
|
||||||
var isPublic = false
|
var isPublic = false
|
||||||
var isCreator = false
|
var isCreator = false
|
||||||
|
var hasVoiceChat = false
|
||||||
|
|
||||||
|
if group.flags.contains(.hasVoiceChat) {
|
||||||
|
hasVoiceChat = true
|
||||||
|
}
|
||||||
|
|
||||||
if case .creator = group.role {
|
if case .creator = group.role {
|
||||||
isCreator = true
|
isCreator = true
|
||||||
@ -1079,6 +1084,9 @@ func peerInfoHeaderButtons(peer: Peer?, cachedData: CachedPeerData?, isOpenedFro
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.append(.mute)
|
result.append(.mute)
|
||||||
|
if hasVoiceChat {
|
||||||
|
result.append(.voiceChat)
|
||||||
|
}
|
||||||
result.append(.search)
|
result.append(.search)
|
||||||
result.append(.more)
|
result.append(.more)
|
||||||
}
|
}
|
||||||
|
@ -3012,7 +3012,9 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
|||||||
case .videoCall:
|
case .videoCall:
|
||||||
self.requestCall(isVideo: true)
|
self.requestCall(isVideo: true)
|
||||||
case .voiceChat:
|
case .voiceChat:
|
||||||
if let cachedData = self.data?.cachedData as? CachedChannelData, let activeCall = cachedData.activeCall {
|
if let cachedData = self.data?.cachedData as? CachedGroupData, let activeCall = cachedData.activeCall {
|
||||||
|
self.context.joinGroupCall(peerId: self.peerId, activeCall: activeCall)
|
||||||
|
} else if let cachedData = self.data?.cachedData as? CachedChannelData, let activeCall = cachedData.activeCall {
|
||||||
self.context.joinGroupCall(peerId: self.peerId, activeCall: activeCall)
|
self.context.joinGroupCall(peerId: self.peerId, activeCall: activeCall)
|
||||||
}
|
}
|
||||||
case .mute:
|
case .mute:
|
||||||
@ -3257,7 +3259,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
|||||||
canManageGroupCalls = true
|
canManageGroupCalls = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if canManageGroupCalls {
|
if canManageGroupCalls, !group.flags.contains(.hasVoiceChat) {
|
||||||
items.append(ActionSheetButtonItem(title: presentationData.strings.ChannelInfo_CreateVoiceChat, color: .accent, action: { [weak self] in
|
items.append(ActionSheetButtonItem(title: presentationData.strings.ChannelInfo_CreateVoiceChat, color: .accent, action: { [weak self] in
|
||||||
dismissAction()
|
dismissAction()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user