Conference updates

This commit is contained in:
Isaac 2025-04-15 17:49:31 +04:00
parent 77bfc86c6f
commit c7269fa310
20 changed files with 218 additions and 129 deletions

View File

@ -14182,3 +14182,8 @@ Sorry for the inconvenience.";
"Call.IncomingGroupCallTitle.Multiple_any" = "{} and %d others"; "Call.IncomingGroupCallTitle.Multiple_any" = "{} and %d others";
"GroupCall.RevokeLinkText" = "Are you sure you want to revoke this link? Once you do, no one will be able to join the call using it."; "GroupCall.RevokeLinkText" = "Are you sure you want to revoke this link? Once you do, no one will be able to join the call using it.";
"SendInviteLink.TextCallsRestrictedOneUser" = "%@ does not accept calls.";
"SendInviteLink.TextCallsRestrictedMultipleUsers_1" = "{user_list}, and **%d** more person do not accept calls.";
"SendInviteLink.TextCallsRestrictedMultipleUsers_any" = "{user_list}, and **%d** more people do not accept calls.";

View File

@ -985,6 +985,11 @@ public enum OldChannelsControllerIntent {
case upgrade case upgrade
} }
public enum SendInviteLinkScreenSubject {
case chat(peer: EnginePeer, link: String?)
case groupCall(link: String)
}
public protocol SharedAccountContext: AnyObject { public protocol SharedAccountContext: AnyObject {
var sharedContainerPath: String { get } var sharedContainerPath: String { get }
var basePath: String { get } var basePath: String { get }
@ -1201,6 +1206,8 @@ public protocol SharedAccountContext: AnyObject {
func makeAccountFreezeInfoScreen(context: AccountContext) -> ViewController func makeAccountFreezeInfoScreen(context: AccountContext) -> ViewController
func makeSendInviteLinkScreen(context: AccountContext, subject: SendInviteLinkScreenSubject, peers: [TelegramForbiddenInvitePeer], theme: PresentationTheme?) -> ViewController
func makeDebugSettingsController(context: AccountContext?) -> ViewController? func makeDebugSettingsController(context: AccountContext?) -> ViewController?
func openCreateGroupCallUI(context: AccountContext, peerIds: [EnginePeer.Id], parentController: ViewController) func openCreateGroupCallUI(context: AccountContext, peerIds: [EnginePeer.Id], parentController: ViewController)

View File

@ -700,10 +700,6 @@ public final class CallListController: TelegramBaseController {
guard case let .conferenceCall(conferenceCall) = action?.action else { guard case let .conferenceCall(conferenceCall) = action?.action else {
return return
} }
if conferenceCall.duration != nil {
self.context.sharedContext.openCreateGroupCallUI(context: self.context, peerIds: conferenceCall.otherParticipants, parentController: self)
return
}
if let currentGroupCallController = self.context.sharedContext as? VoiceChatController, case let .group(groupCall) = currentGroupCallController.call, let currentCallId = groupCall.callId, currentCallId == conferenceCall.callId { if let currentGroupCallController = self.context.sharedContext as? VoiceChatController, case let .group(groupCall) = currentGroupCallController.call, let currentCallId = groupCall.callId, currentCallId == conferenceCall.callId {
self.context.sharedContext.navigateToCurrentCall() self.context.sharedContext.navigateToCurrentCall()

View File

@ -126,7 +126,7 @@ private func mappedInsertEntries(context: AccountContext, presentationData: Item
case let .displayTabInfo(_, text): case let .displayTabInfo(_, text):
return ListViewInsertItem(index: entry.index, previousIndex: entry.previousIndex, item: ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: 0), directionHint: entry.directionHint) return ListViewInsertItem(index: entry.index, previousIndex: entry.previousIndex, item: ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: 0), directionHint: entry.directionHint)
case .openNewCall: case .openNewCall:
let item = ItemListPeerActionItem(presentationData: presentationData, style: showSettings ? .blocks : .plain, icon: PresentationResourcesRootController.callListCallIcon(presentationData.theme), title: presentationData.strings.CallList_NewCall, hasSeparator: false, sectionId: 1, height: .generic, noInsets: true, editing: false, action: { let item = ItemListPeerActionItem(presentationData: presentationData, style: showSettings ? .blocks : .plain, icon: PresentationResourcesRootController.callListCallIcon(presentationData.theme), title: presentationData.strings.CallList_NewCall, hasSeparator: false, sectionId: 1, height: .generic, noInsets: !showSettings, editing: false, action: {
nodeInteraction.openNewCall() nodeInteraction.openNewCall()
}) })
return ListViewInsertItem(index: entry.index, previousIndex: entry.previousIndex, item: item, directionHint: entry.directionHint) return ListViewInsertItem(index: entry.index, previousIndex: entry.previousIndex, item: item, directionHint: entry.directionHint)
@ -150,7 +150,7 @@ private func mappedUpdateEntries(context: AccountContext, presentationData: Item
case let .displayTabInfo(_, text): case let .displayTabInfo(_, text):
return ListViewUpdateItem(index: entry.index, previousIndex: entry.previousIndex, item: ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: 0), directionHint: entry.directionHint) return ListViewUpdateItem(index: entry.index, previousIndex: entry.previousIndex, item: ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: 0), directionHint: entry.directionHint)
case .openNewCall: case .openNewCall:
let item = ItemListPeerActionItem(presentationData: presentationData, style: showSettings ? .blocks : .plain, icon: PresentationResourcesRootController.callListCallIcon(presentationData.theme), title: presentationData.strings.CallList_NewCall, hasSeparator: false, sectionId: 1, height: .generic, noInsets: true, editing: false, action: { let item = ItemListPeerActionItem(presentationData: presentationData, style: showSettings ? .blocks : .plain, icon: PresentationResourcesRootController.callListCallIcon(presentationData.theme), title: presentationData.strings.CallList_NewCall, hasSeparator: false, sectionId: 1, height: .generic, noInsets: !showSettings, editing: false, action: {
nodeInteraction.openNewCall() nodeInteraction.openNewCall()
}) })
return ListViewUpdateItem(index: entry.index, previousIndex: entry.previousIndex, item: item, directionHint: entry.directionHint) return ListViewUpdateItem(index: entry.index, previousIndex: entry.previousIndex, item: item, directionHint: entry.directionHint)
@ -525,7 +525,7 @@ final class CallListControllerNode: ASDisplayNode {
|> mapToQueue { (updateAndType, state, groupCalls, showCallsTab, currentGroupCallPeerId) -> Signal<CallListNodeListViewTransition, NoError> in |> mapToQueue { (updateAndType, state, groupCalls, showCallsTab, currentGroupCallPeerId) -> Signal<CallListNodeListViewTransition, NoError> in
let (update, type) = updateAndType let (update, type) = updateAndType
let processedView = CallListNodeView(originalView: update.view, filteredEntries: callListNodeEntriesForView(view: update.view, displayOpenNewCall: mode == .tab && type == .all, groupCalls: groupCalls, state: state, showSettings: showSettings, showCallsTab: showCallsTab, isRecentCalls: type == .all, currentGroupCallPeerId: currentGroupCallPeerId), presentationData: state.presentationData) let processedView = CallListNodeView(originalView: update.view, filteredEntries: callListNodeEntriesForView(view: update.view, displayOpenNewCall: type == .all, groupCalls: groupCalls, state: state, showSettings: showSettings, showCallsTab: showCallsTab, isRecentCalls: type == .all, currentGroupCallPeerId: currentGroupCallPeerId), presentationData: state.presentationData)
let previous = previousView.swap(processedView) let previous = previousView.swap(processedView)
let previousType = previousType.swap(type) let previousType = previousType.swap(type)

View File

@ -44,14 +44,14 @@ enum CallListNodeEntry: Comparable, Identifiable {
case .openNewCall: case .openNewCall:
switch rhs { switch rhs {
case .displayTab, .displayTabInfo: case .displayTab, .displayTabInfo:
return false
default:
return true return true
default:
return false
} }
case let .groupCall(lhsPeerId, lhsTitle): case let .groupCall(lhsPeerId, lhsTitle):
switch rhs { switch rhs {
case .displayTab, .displayTabInfo, .openNewCall: case .displayTab, .displayTabInfo, .openNewCall:
return false return true
case let .groupCall(rhsPeerId, rhsTitle): case let .groupCall(rhsPeerId, rhsTitle):
if lhsTitle == rhsTitle { if lhsTitle == rhsTitle {
return lhsPeerId < rhsPeerId return lhsPeerId < rhsPeerId
@ -64,7 +64,7 @@ enum CallListNodeEntry: Comparable, Identifiable {
case let .hole(lhsIndex): case let .hole(lhsIndex):
switch rhs { switch rhs {
case .displayTab, .displayTabInfo, .groupCall, .openNewCall: case .displayTab, .displayTabInfo, .groupCall, .openNewCall:
return false return true
case let .hole(rhsIndex): case let .hole(rhsIndex):
return lhsIndex < rhsIndex return lhsIndex < rhsIndex
case let .message(rhsIndex): case let .message(rhsIndex):
@ -73,7 +73,7 @@ enum CallListNodeEntry: Comparable, Identifiable {
case let .message(lhsIndex): case let .message(lhsIndex):
switch rhs { switch rhs {
case .displayTab, .displayTabInfo, .groupCall, .openNewCall: case .displayTab, .displayTabInfo, .groupCall, .openNewCall:
return false return true
case let .hole(rhsIndex): case let .hole(rhsIndex):
return lhsIndex < rhsIndex return lhsIndex < rhsIndex
case let .message(rhsIndex): case let .message(rhsIndex):

View File

@ -306,10 +306,8 @@ public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder:
if conferenceCall.flags.contains(.isMissed) { if conferenceCall.flags.contains(.isMissed) {
messageText = strings.Chat_CallMessage_DeclinedGroupCall messageText = strings.Chat_CallMessage_DeclinedGroupCall
} else if message.timestamp < currentTime - missedTimeout { } else if conferenceCall.duration == nil && message.timestamp < currentTime - missedTimeout {
messageText = strings.Chat_CallMessage_MissedGroupCall messageText = strings.Chat_CallMessage_MissedGroupCall
} else if conferenceCall.duration != nil {
messageText = strings.Chat_CallMessage_CancelledGroupCall
} else { } else {
if incoming { if incoming {
messageText = strings.Chat_CallMessage_IncomingGroupCall messageText = strings.Chat_CallMessage_IncomingGroupCall

View File

@ -1247,7 +1247,7 @@ public func channelAdminController(context: AccountContext, updatedPresentationD
} }
if let adminPeer, case let .restricted(forbiddenPeer) = error { if let adminPeer, case let .restricted(forbiddenPeer) = error {
let inviteScreen = SendInviteLinkScreen(context: context, peer: channelPeer, link: exportedInvitation?.link, peers: [forbiddenPeer ?? TelegramForbiddenInvitePeer(peer: adminPeer, canInviteWithPremium: false, premiumRequiredToContact: false)]) let inviteScreen = SendInviteLinkScreen(context: context, subject: .chat(peer: channelPeer, link: exportedInvitation?.link), peers: [forbiddenPeer ?? TelegramForbiddenInvitePeer(peer: adminPeer, canInviteWithPremium: false, premiumRequiredToContact: false)])
pushControllerImpl?(inviteScreen) pushControllerImpl?(inviteScreen)
dismissImpl?() dismissImpl?()
@ -1437,7 +1437,7 @@ public func channelAdminController(context: AccountContext, updatedPresentationD
updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(engine: context.engine, peerId: peerId, memberId: adminId, adminRights: TelegramChatAdminRights(rights: updateFlags), rank: updateRank) |> deliverOnMainQueue).start(error: { error in updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(engine: context.engine, peerId: peerId, memberId: adminId, adminRights: TelegramChatAdminRights(rights: updateFlags), rank: updateRank) |> deliverOnMainQueue).start(error: { error in
if case let .addMemberError(addMemberError) = error, case let .restricted(forbiddenPeer) = addMemberError, let admin = adminPeer { if case let .addMemberError(addMemberError) = error, case let .restricted(forbiddenPeer) = addMemberError, let admin = adminPeer {
if let channelPeer { if let channelPeer {
let inviteScreen = SendInviteLinkScreen(context: context, peer: channelPeer, link: exportedInvitation?.link, peers: [forbiddenPeer ?? TelegramForbiddenInvitePeer(peer: admin, canInviteWithPremium: false, premiumRequiredToContact: false)]) let inviteScreen = SendInviteLinkScreen(context: context, subject: .chat(peer: channelPeer, link: exportedInvitation?.link), peers: [forbiddenPeer ?? TelegramForbiddenInvitePeer(peer: admin, canInviteWithPremium: false, premiumRequiredToContact: false)])
pushControllerImpl?(inviteScreen) pushControllerImpl?(inviteScreen)
dismissImpl?() dismissImpl?()
@ -1519,7 +1519,7 @@ public func channelAdminController(context: AccountContext, updatedPresentationD
) )
|> deliverOnMainQueue).startStandalone(next: { exportedInvitation in |> deliverOnMainQueue).startStandalone(next: { exportedInvitation in
let _ = exportedInvitation let _ = exportedInvitation
let inviteScreen = SendInviteLinkScreen(context: context, peer: .legacyGroup(group), link: exportedInvitation?.link, peers: [failedPeer]) let inviteScreen = SendInviteLinkScreen(context: context, subject: .chat(peer: .legacyGroup(group), link: exportedInvitation?.link), peers: [failedPeer])
pushControllerImpl?(inviteScreen) pushControllerImpl?(inviteScreen)
}) })
} else { } else {

View File

@ -560,7 +560,7 @@ public func channelMembersController(context: AccountContext, updatedPresentatio
if !failedPeers.isEmpty, let contactsController, let navigationController = contactsController.navigationController as? NavigationController { if !failedPeers.isEmpty, let contactsController, let navigationController = contactsController.navigationController as? NavigationController {
var viewControllers = navigationController.viewControllers var viewControllers = navigationController.viewControllers
if let index = viewControllers.firstIndex(where: { $0 === contactsController }) { if let index = viewControllers.firstIndex(where: { $0 === contactsController }) {
let inviteScreen = SendInviteLinkScreen(context: context, peer: chatPeer, link: exportedInvitation?.link, peers: failedPeers) let inviteScreen = SendInviteLinkScreen(context: context, subject: .chat(peer: chatPeer, link: exportedInvitation?.link), peers: failedPeers)
viewControllers.remove(at: index) viewControllers.remove(at: index)
viewControllers.append(inviteScreen) viewControllers.append(inviteScreen)
navigationController.setViewControllers(viewControllers, animated: true) navigationController.setViewControllers(viewControllers, animated: true)

View File

@ -3620,14 +3620,24 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
let presentationData = self.accountContext.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: defaultDarkColorPresentationTheme) let presentationData = self.accountContext.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: defaultDarkColorPresentationTheme)
var errorText = presentationData.strings.Login_UnknownError var errorText = presentationData.strings.Login_UnknownError
switch error { switch error {
case let .privacy(peer): case let .privacy(peer):
if let peer { if let peer {
errorText = presentationData.strings.Call_PrivacyErrorMessage(peer.compactDisplayTitle).string if let currentInviteLinks = self.currentInviteLinks {
let inviteLinkScreen = self.accountContext.sharedContext.makeSendInviteLinkScreen(context: self.accountContext, subject: .groupCall(link: currentInviteLinks.listenerLink), peers: [TelegramForbiddenInvitePeer(peer: peer, canInviteWithPremium: false, premiumRequiredToContact: false)], theme: defaultDarkColorPresentationTheme)
if let navigationController = self.accountContext.sharedContext.mainWindow?.viewController as? NavigationController {
navigationController.pushViewController(inviteLinkScreen)
}
return
} else {
errorText = presentationData.strings.Call_PrivacyErrorMessage(peer.compactDisplayTitle).string
}
} }
default: default:
break break
} }
self.accountContext.sharedContext.mainWindow?.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: presentationData), title: nil, text: errorText, actions: [ self.accountContext.sharedContext.mainWindow?.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: presentationData), title: nil, text: errorText, actions: [
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {}) TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {})
]), on: .root, blockInteraction: false, completion: {}) ]), on: .root, blockInteraction: false, completion: {})
@ -3752,6 +3762,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
} }
} }
public var currentInviteLinks: GroupCallInviteLinks?
private var currentMyAudioLevel: Float = 0.0 private var currentMyAudioLevel: Float = 0.0
private var currentMyAudioLevelTimestamp: Double = 0.0 private var currentMyAudioLevelTimestamp: Double = 0.0
private var isSendingTyping: Bool = false private var isSendingTyping: Bool = false

View File

@ -1530,6 +1530,9 @@ final class VideoChatScreenComponent: Component {
return return
} }
self.inviteLinks = value self.inviteLinks = value
if case let .group(groupCall) = self.currentCall, let groupCall = groupCall as? PresentationGroupCallImpl {
groupCall.currentInviteLinks = value
}
}) })
self.reconnectedAsEventsDisposable?.dispose() self.reconnectedAsEventsDisposable?.dispose()

View File

@ -379,7 +379,7 @@ public final class ConferenceCallE2EContext {
// Peer ids that are in the blockchain but not in the server list // Peer ids that are in the blockchain but not in the server list
var removedPeerIds = blockchainPeerIds.filter { blockchainPeerId in var removedPeerIds = blockchainPeerIds.filter { blockchainPeerId in
return !result.participants.contains(where: { participant in return !result.participants.contains(where: { participant in
if case let .peer(id) = participant.id, id.namespace == Namespaces.Peer.CloudChannel, id.id._internalGetInt64Value() == blockchainPeerId { if case let .peer(id) = participant.id, id.namespace == Namespaces.Peer.CloudUser, id.id._internalGetInt64Value() == blockchainPeerId {
return true return true
} else { } else {
return false return false

View File

@ -200,7 +200,7 @@ func _internal_joinCallInvitationInformation(account: Account, messageId: Messag
} }
var members: [EnginePeer] = [] var members: [EnginePeer] = []
for participant in call.topParticipants { for participant in call.topParticipants {
if let peer = participant.peer { if let peer = participant.peer, peer.id != account.peerId {
members.append(peer) members.append(peer)
} }
} }

View File

@ -625,10 +625,8 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
if conferenceCall.flags.contains(.isMissed) { if conferenceCall.flags.contains(.isMissed) {
titleString = strings.Chat_CallMessage_DeclinedGroupCall titleString = strings.Chat_CallMessage_DeclinedGroupCall
} else if message.timestamp < currentTime - missedTimeout { } else if conferenceCall.duration == nil && message.timestamp < currentTime - missedTimeout {
titleString = strings.Chat_CallMessage_MissedGroupCall titleString = strings.Chat_CallMessage_MissedGroupCall
} else if conferenceCall.duration != nil {
titleString = strings.Chat_CallMessage_CancelledGroupCall
} else { } else {
if incoming { if incoming {
titleString = strings.Chat_CallMessage_IncomingGroupCall titleString = strings.Chat_CallMessage_IncomingGroupCall

View File

@ -174,10 +174,8 @@ public class ChatMessageCallBubbleContentNode: ChatMessageBubbleContentNode {
let currentTime = Int32(Date().timeIntervalSince1970) let currentTime = Int32(Date().timeIntervalSince1970)
if conferenceCall.flags.contains(.isMissed) { if conferenceCall.flags.contains(.isMissed) {
titleString = item.presentationData.strings.Chat_CallMessage_DeclinedGroupCall titleString = item.presentationData.strings.Chat_CallMessage_DeclinedGroupCall
} else if item.message.timestamp < currentTime - missedTimeout { } else if conferenceCall.duration == nil && item.message.timestamp < currentTime - missedTimeout {
titleString = item.presentationData.strings.Chat_CallMessage_MissedGroupCall titleString = item.presentationData.strings.Chat_CallMessage_MissedGroupCall
} else if conferenceCall.duration != nil {
titleString = item.presentationData.strings.Chat_CallMessage_CancelledGroupCall
} else { } else {
if incoming { if incoming {
titleString = item.presentationData.strings.Chat_CallMessage_IncomingGroupCall titleString = item.presentationData.strings.Chat_CallMessage_IncomingGroupCall

View File

@ -14182,7 +14182,7 @@ public func presentAddMembersImpl(context: AccountContext, updatedPresentationDa
if !failedPeers.isEmpty, let contactsController, let navigationController = contactsController.navigationController as? NavigationController { if !failedPeers.isEmpty, let contactsController, let navigationController = contactsController.navigationController as? NavigationController {
var viewControllers = navigationController.viewControllers var viewControllers = navigationController.viewControllers
if let index = viewControllers.firstIndex(where: { $0 === contactsController }) { if let index = viewControllers.firstIndex(where: { $0 === contactsController }) {
let inviteScreen = SendInviteLinkScreen(context: context, peer: EnginePeer(groupPeer), link: exportedInvitation?.link, peers: failedPeers) let inviteScreen = SendInviteLinkScreen(context: context, subject: .chat(peer: EnginePeer(groupPeer), link: exportedInvitation?.link), peers: failedPeers)
viewControllers.remove(at: index) viewControllers.remove(at: index)
viewControllers.append(inviteScreen) viewControllers.append(inviteScreen)
navigationController.setViewControllers(viewControllers, animated: true) navigationController.setViewControllers(viewControllers, animated: true)

View File

@ -23,23 +23,20 @@ private final class SendInviteLinkScreenComponent: Component {
typealias EnvironmentType = ViewControllerComponentContainer.Environment typealias EnvironmentType = ViewControllerComponentContainer.Environment
let context: AccountContext let context: AccountContext
let peer: EnginePeer let subject: SendInviteLinkScreenSubject
let link: String?
let peers: [TelegramForbiddenInvitePeer] let peers: [TelegramForbiddenInvitePeer]
let peerPresences: [EnginePeer.Id: EnginePeer.Presence] let peerPresences: [EnginePeer.Id: EnginePeer.Presence]
let sendPaidMessageStars: [EnginePeer.Id: StarsAmount] let sendPaidMessageStars: [EnginePeer.Id: StarsAmount]
init( init(
context: AccountContext, context: AccountContext,
peer: EnginePeer, subject: SendInviteLinkScreenSubject,
link: String?,
peers: [TelegramForbiddenInvitePeer], peers: [TelegramForbiddenInvitePeer],
peerPresences: [EnginePeer.Id: EnginePeer.Presence], peerPresences: [EnginePeer.Id: EnginePeer.Presence],
sendPaidMessageStars: [EnginePeer.Id: StarsAmount] sendPaidMessageStars: [EnginePeer.Id: StarsAmount]
) { ) {
self.context = context self.context = context
self.peer = peer self.subject = subject
self.link = link
self.peers = peers self.peers = peers
self.peerPresences = peerPresences self.peerPresences = peerPresences
self.sendPaidMessageStars = sendPaidMessageStars self.sendPaidMessageStars = sendPaidMessageStars
@ -49,9 +46,6 @@ private final class SendInviteLinkScreenComponent: Component {
if lhs.context !== rhs.context { if lhs.context !== rhs.context {
return false return false
} }
if lhs.link != rhs.link {
return false
}
if lhs.peers != rhs.peers { if lhs.peers != rhs.peers {
return false return false
} }
@ -315,7 +309,12 @@ private final class SendInviteLinkScreenComponent: Component {
if self.component == nil { if self.component == nil {
for peer in component.peers { for peer in component.peers {
if component.link != nil && !peer.premiumRequiredToContact { switch component.subject {
case let .chat(_, link):
if link != nil && !peer.premiumRequiredToContact {
self.selectedItems.insert(peer.peer.id)
}
case .groupCall:
self.selectedItems.insert(peer.peer.id) self.selectedItems.insert(peer.peer.id)
} }
} }
@ -329,10 +328,15 @@ private final class SendInviteLinkScreenComponent: Component {
return peer.canInviteWithPremium return peer.canInviteWithPremium
} }
var hasInviteLink = true var hasInviteLink = true
if premiumRestrictedUsers.count == component.peers.count && component.link == nil { switch component.subject {
hasInviteLink = false case let .chat(_, link):
} else if component.link != nil && !premiumRestrictedUsers.isEmpty && component.peers.allSatisfy({ $0.premiumRequiredToContact }) { if premiumRestrictedUsers.count == component.peers.count && link == nil {
hasInviteLink = false hasInviteLink = false
} else if link != nil && !premiumRestrictedUsers.isEmpty && component.peers.allSatisfy({ $0.premiumRequiredToContact }) {
hasInviteLink = false
}
case .groupCall:
hasInviteLink = true
} }
if themeUpdated { if themeUpdated {
@ -453,48 +457,85 @@ private final class SendInviteLinkScreenComponent: Component {
contentHeight += 8.0 contentHeight += 8.0
let text: String let text: String
if premiumRestrictedUsers.count == 1 { switch component.subject {
if case let .channel(channel) = component.peer, case .broadcast = channel.info { case let .chat(peer, _):
text = environment.strings.SendInviteLink_ChannelTextContactsAndPremiumOneUser(premiumRestrictedUsers[0].peer.compactDisplayTitle).string if premiumRestrictedUsers.count == 1 {
} else { if case let .channel(channel) = peer, case .broadcast = channel.info {
text = environment.strings.SendInviteLink_TextContactsAndPremiumOneUser(premiumRestrictedUsers[0].peer.compactDisplayTitle).string text = environment.strings.SendInviteLink_ChannelTextContactsAndPremiumOneUser(premiumRestrictedUsers[0].peer.compactDisplayTitle).string
} } else {
} else { text = environment.strings.SendInviteLink_TextContactsAndPremiumOneUser(premiumRestrictedUsers[0].peer.compactDisplayTitle).string
let extraCount = premiumRestrictedUsers.count - 3
var peersTextArray: [String] = []
for i in 0 ..< min(3, premiumRestrictedUsers.count) {
peersTextArray.append("**\(premiumRestrictedUsers[i].peer.compactDisplayTitle)**")
}
var peersText = ""
if #available(iOS 13.0, *) {
let listFormatter = ListFormatter()
listFormatter.locale = localeWithStrings(environment.strings)
if let value = listFormatter.string(from: peersTextArray) {
peersText = value
} }
} } else {
if peersText.isEmpty { let extraCount = premiumRestrictedUsers.count - 3
for i in 0 ..< peersTextArray.count {
if i != 0 { var peersTextArray: [String] = []
peersText.append(", ") for i in 0 ..< min(3, premiumRestrictedUsers.count) {
peersTextArray.append("**\(premiumRestrictedUsers[i].peer.compactDisplayTitle)**")
}
var peersText = ""
if #available(iOS 13.0, *) {
let listFormatter = ListFormatter()
listFormatter.locale = localeWithStrings(environment.strings)
if let value = listFormatter.string(from: peersTextArray) {
peersText = value
}
}
if peersText.isEmpty {
for i in 0 ..< peersTextArray.count {
if i != 0 {
peersText.append(", ")
}
peersText.append(peersTextArray[i])
}
}
if extraCount >= 1 {
if case let .channel(channel) = peer, case .broadcast = channel.info {
text = environment.strings.SendInviteLink_ChannelTextContactsAndPremiumMultipleUsers(Int32(extraCount)).replacingOccurrences(of: "{user_list}", with: peersText)
} else {
text = environment.strings.SendInviteLink_TextContactsAndPremiumMultipleUsers(Int32(extraCount)).replacingOccurrences(of: "{user_list}", with: peersText)
}
} else {
if case let .channel(channel) = peer, case .broadcast = channel.info {
text = environment.strings.SendInviteLink_ChannelTextContactsAndPremiumOneUser(peersText).string
} else {
text = environment.strings.SendInviteLink_TextContactsAndPremiumOneUser(peersText).string
} }
peersText.append(peersTextArray[i])
} }
} }
case .groupCall:
if extraCount >= 1 { if premiumRestrictedUsers.count == 1 {
if case let .channel(channel) = component.peer, case .broadcast = channel.info { text = environment.strings.SendInviteLink_TextCallsRestrictedOneUser(premiumRestrictedUsers[0].peer.compactDisplayTitle).string
text = environment.strings.SendInviteLink_ChannelTextContactsAndPremiumMultipleUsers(Int32(extraCount)).replacingOccurrences(of: "{user_list}", with: peersText)
} else {
text = environment.strings.SendInviteLink_TextContactsAndPremiumMultipleUsers(Int32(extraCount)).replacingOccurrences(of: "{user_list}", with: peersText)
}
} else { } else {
if case let .channel(channel) = component.peer, case .broadcast = channel.info { let extraCount = premiumRestrictedUsers.count - 3
text = environment.strings.SendInviteLink_ChannelTextContactsAndPremiumOneUser(peersText).string
var peersTextArray: [String] = []
for i in 0 ..< min(3, premiumRestrictedUsers.count) {
peersTextArray.append("**\(premiumRestrictedUsers[i].peer.compactDisplayTitle)**")
}
var peersText = ""
if #available(iOS 13.0, *) {
let listFormatter = ListFormatter()
listFormatter.locale = localeWithStrings(environment.strings)
if let value = listFormatter.string(from: peersTextArray) {
peersText = value
}
}
if peersText.isEmpty {
for i in 0 ..< peersTextArray.count {
if i != 0 {
peersText.append(", ")
}
peersText.append(peersTextArray[i])
}
}
if extraCount >= 1 {
text = environment.strings.SendInviteLink_TextCallsRestrictedMultipleUsers(Int32(extraCount)).replacingOccurrences(of: "{user_list}", with: peersText)
} else { } else {
text = environment.strings.SendInviteLink_TextContactsAndPremiumOneUser(peersText).string text = environment.strings.SendInviteLink_TextCallsRestrictedOneUser(peersText).string
} }
} }
} }
@ -693,11 +734,19 @@ private final class SendInviteLinkScreenComponent: Component {
actionButton = ComponentView() actionButton = ComponentView()
self.actionButton = actionButton self.actionButton = actionButton
} }
let titleText: String
switch component.subject {
case let .chat(_, link):
titleText = link != nil ? environment.strings.SendInviteLink_InviteTitle : environment.strings.SendInviteLink_LinkUnavailableTitle
case .groupCall:
titleText = environment.strings.SendInviteLink_InviteTitle
}
let titleSize = title.update( let titleSize = title.update(
transition: .immediate, transition: .immediate,
component: AnyComponent(MultilineTextComponent( component: AnyComponent(MultilineTextComponent(
text: .plain(NSAttributedString(string: component.link != nil ? environment.strings.SendInviteLink_InviteTitle : environment.strings.SendInviteLink_LinkUnavailableTitle, font: Font.semibold(24.0), textColor: environment.theme.list.itemPrimaryTextColor)) text: .plain(NSAttributedString(string: titleText, font: Font.semibold(24.0), textColor: environment.theme.list.itemPrimaryTextColor))
)), )),
environment: {}, environment: {},
containerSize: CGSize(width: availableSize.width - leftButtonFrame.maxX * 2.0, height: 100.0) containerSize: CGSize(width: availableSize.width - leftButtonFrame.maxX * 2.0, height: 100.0)
@ -714,30 +763,35 @@ private final class SendInviteLinkScreenComponent: Component {
contentHeight += 8.0 contentHeight += 8.0
let text: String let text: String
if !premiumRestrictedUsers.isEmpty { switch component.subject {
if component.link != nil { case let .chat(_, link):
text = environment.strings.SendInviteLink_TextSendInviteLink if !premiumRestrictedUsers.isEmpty {
} else { if link != nil {
if component.peers.count == 1 { text = environment.strings.SendInviteLink_TextSendInviteLink
text = environment.strings.SendInviteLink_TextUnavailableSingleUser(component.peers[0].peer.displayTitle(strings: environment.strings, displayOrder: .firstLast)).string
} else { } else {
text = environment.strings.SendInviteLink_TextUnavailableMultipleUsers(Int32(component.peers.count)) if component.peers.count == 1 {
} text = environment.strings.SendInviteLink_TextUnavailableSingleUser(component.peers[0].peer.displayTitle(strings: environment.strings, displayOrder: .firstLast)).string
} } else {
} else { text = environment.strings.SendInviteLink_TextUnavailableMultipleUsers(Int32(component.peers.count))
if component.link != nil { }
if component.peers.count == 1 {
text = environment.strings.SendInviteLink_TextAvailableSingleUser(component.peers[0].peer.displayTitle(strings: environment.strings, displayOrder: .firstLast)).string
} else {
text = environment.strings.SendInviteLink_TextAvailableMultipleUsers(Int32(component.peers.count))
} }
} else { } else {
if component.peers.count == 1 { if link != nil {
text = environment.strings.SendInviteLink_TextUnavailableSingleUser(component.peers[0].peer.displayTitle(strings: environment.strings, displayOrder: .firstLast)).string if component.peers.count == 1 {
text = environment.strings.SendInviteLink_TextAvailableSingleUser(component.peers[0].peer.displayTitle(strings: environment.strings, displayOrder: .firstLast)).string
} else {
text = environment.strings.SendInviteLink_TextAvailableMultipleUsers(Int32(component.peers.count))
}
} else { } else {
text = environment.strings.SendInviteLink_TextUnavailableMultipleUsers(Int32(component.peers.count)) if component.peers.count == 1 {
text = environment.strings.SendInviteLink_TextUnavailableSingleUser(component.peers[0].peer.displayTitle(strings: environment.strings, displayOrder: .firstLast)).string
} else {
text = environment.strings.SendInviteLink_TextUnavailableMultipleUsers(Int32(component.peers.count))
}
} }
} }
case .groupCall:
text = " "
} }
let body = MarkdownAttributeSet(font: Font.regular(15.0), textColor: environment.theme.list.itemPrimaryTextColor) let body = MarkdownAttributeSet(font: Font.regular(15.0), textColor: environment.theme.list.itemPrimaryTextColor)
@ -793,7 +847,13 @@ private final class SendInviteLinkScreenComponent: Component {
} }
let itemSubtitle: PeerListItemComponent.Subtitle let itemSubtitle: PeerListItemComponent.Subtitle
let canBeSelected = component.link != nil && !peer.premiumRequiredToContact let canBeSelected : Bool
switch component.subject {
case let .chat(_, link):
canBeSelected = link != nil && !peer.premiumRequiredToContact
case .groupCall:
canBeSelected = true
}
if peer.premiumRequiredToContact { if peer.premiumRequiredToContact {
itemSubtitle = .text(text: environment.strings.SendInviteLink_StatusAvailableToPremiumOnly, icon: .lock) itemSubtitle = .text(text: environment.strings.SendInviteLink_StatusAvailableToPremiumOnly, icon: .lock)
} else { } else {
@ -862,16 +922,24 @@ private final class SendInviteLinkScreenComponent: Component {
initialContentHeight += 24.0 initialContentHeight += 24.0
let actionButtonTitle: String let actionButtonTitle: String
if component.link != nil { let actionButtonBadge: String?
actionButtonTitle = self.selectedItems.isEmpty ? environment.strings.SendInviteLink_ActionSkip : environment.strings.SendInviteLink_ActionInvite switch component.subject {
} else { case let.chat(_, link):
actionButtonTitle = environment.strings.SendInviteLink_ActionClose if link != nil {
actionButtonTitle = self.selectedItems.isEmpty ? environment.strings.SendInviteLink_ActionSkip : environment.strings.SendInviteLink_ActionInvite
} else {
actionButtonTitle = environment.strings.SendInviteLink_ActionClose
}
actionButtonBadge = (self.selectedItems.isEmpty || link == nil) ? nil : "\(self.selectedItems.count)"
case .groupCall:
actionButtonTitle = environment.strings.SendInviteLink_ActionInvite
actionButtonBadge = self.selectedItems.isEmpty ? nil : "\(self.selectedItems.count)"
} }
let actionButtonSize = actionButton.update( let actionButtonSize = actionButton.update(
transition: transition, transition: transition,
component: AnyComponent(SolidRoundedButtonComponent( component: AnyComponent(SolidRoundedButtonComponent(
title: actionButtonTitle, title: actionButtonTitle,
badge: (self.selectedItems.isEmpty || component.link == nil) ? nil : "\(self.selectedItems.count)", badge: actionButtonBadge,
theme: SolidRoundedButtonComponent.Theme(theme: environment.theme), theme: SolidRoundedButtonComponent.Theme(theme: environment.theme),
font: .bold, font: .bold,
fontSize: 17.0, fontSize: 17.0,
@ -885,9 +953,18 @@ private final class SendInviteLinkScreenComponent: Component {
guard let self, let component = self.component, let controller = self.environment?.controller() else { guard let self, let component = self.component, let controller = self.environment?.controller() else {
return return
} }
let link: String?
switch component.subject {
case let .chat(_, linkValue):
link = linkValue
case let .groupCall(linkValue):
link = linkValue
}
if self.selectedItems.isEmpty { if self.selectedItems.isEmpty {
controller.dismiss() controller.dismiss()
} else if let link = component.link { } else if let link {
let selectedPeers = component.peers.filter { self.selectedItems.contains($0.peer.id) } let selectedPeers = component.peers.filter { self.selectedItems.contains($0.peer.id) }
self.presentPaidMessageAlertIfNeeded( self.presentPaidMessageAlertIfNeeded(
@ -1012,15 +1089,21 @@ public class SendInviteLinkScreen: ViewControllerComponentContainer {
private var presenceDisposable: Disposable? private var presenceDisposable: Disposable?
public init(context: AccountContext, peer: EnginePeer, link: String?, peers: [TelegramForbiddenInvitePeer]) { public init(context: AccountContext, subject: SendInviteLinkScreenSubject, peers: [TelegramForbiddenInvitePeer], theme: PresentationTheme? = nil) {
self.context = context self.context = context
var link = link switch subject {
if link == nil, let addressName = peer.addressName { case let .chat(peer, link):
link = "https://t.me/\(addressName)" var link = link
if link == nil, let addressName = peer.addressName {
link = "https://t.me/\(addressName)"
}
self.link = link
case let .groupCall(link):
self.link = link
} }
#if DEBUG #if DEBUG && false
var peers = peers var peers = peers
if !"".isEmpty { if !"".isEmpty {
@ -1136,10 +1219,9 @@ public class SendInviteLinkScreen: ViewControllerComponentContainer {
} }
#endif #endif
self.link = link
self.peers = peers self.peers = peers
super.init(context: context, component: SendInviteLinkScreenComponent(context: context, peer: peer, link: link, peers: peers, peerPresences: [:], sendPaidMessageStars: [:]), navigationBarAppearance: .none) super.init(context: context, component: SendInviteLinkScreenComponent(context: context, subject: subject, peers: peers, peerPresences: [:], sendPaidMessageStars: [:]), navigationBarAppearance: .none, theme: theme.flatMap { .custom($0) } ?? .default)
self.statusBar.statusBarStyle = .Ignore self.statusBar.statusBarStyle = .Ignore
self.navigationPresentation = .flatModal self.navigationPresentation = .flatModal
@ -1169,7 +1251,7 @@ public class SendInviteLinkScreen: ViewControllerComponentContainer {
parsedSendPaidMessageStars[id] = sendPaidMessageStars parsedSendPaidMessageStars[id] = sendPaidMessageStars
} }
} }
self.updateComponent(component: AnyComponent(SendInviteLinkScreenComponent(context: context, peer: peer, link: link, peers: peers, peerPresences: parsedPresences, sendPaidMessageStars: parsedSendPaidMessageStars)), transition: .immediate) self.updateComponent(component: AnyComponent(SendInviteLinkScreenComponent(context: context, subject: subject, peers: peers, peerPresences: parsedPresences, sendPaidMessageStars: parsedSendPaidMessageStars)), transition: .immediate)
}) })
} }

View File

@ -2893,10 +2893,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
guard case let .conferenceCall(conferenceCall) = action?.action else { guard case let .conferenceCall(conferenceCall) = action?.action else {
return return
} }
if conferenceCall.duration != nil {
self.context.sharedContext.openCreateGroupCallUI(context: self.context, peerIds: conferenceCall.otherParticipants, parentController: self)
return
}
if let currentGroupCallController = self.context.sharedContext.currentGroupCallController as? VoiceChatController, case let .group(groupCall) = currentGroupCallController.call, let currentCallId = groupCall.callId, currentCallId == conferenceCall.callId { if let currentGroupCallController = self.context.sharedContext.currentGroupCallController as? VoiceChatController, case let .group(groupCall) = currentGroupCallController.call, let currentCallId = groupCall.callId, currentCallId == conferenceCall.callId {
self.context.sharedContext.navigateToCurrentCall() self.context.sharedContext.navigateToCurrentCall()

View File

@ -2733,7 +2733,6 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
var messageIdsWithUnseenPersonalMention: [MessageId] = [] var messageIdsWithUnseenPersonalMention: [MessageId] = []
var messageIdsWithUnseenReactions: [MessageId] = [] var messageIdsWithUnseenReactions: [MessageId] = []
var messageIdsWithInactiveExtendedMedia = Set<MessageId>() var messageIdsWithInactiveExtendedMedia = Set<MessageId>()
var messageIdsWithGroupCalls: [MessageId] = []
var downloadableResourceIds: [(messageId: MessageId, resourceId: String)] = [] var downloadableResourceIds: [(messageId: MessageId, resourceId: String)] = []
var allVisibleAnchorMessageIds: [(MessageId, Int)] = [] var allVisibleAnchorMessageIds: [(MessageId, Int)] = []
var visibleAdOpaqueIds: [Data] = [] var visibleAdOpaqueIds: [Data] = []
@ -2832,13 +2831,6 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
storiesRequiredValidation = true storiesRequiredValidation = true
} else if let webpage = media as? TelegramMediaWebpage, case let .Loaded(content) = webpage.content, let _ = content.story { } else if let webpage = media as? TelegramMediaWebpage, case let .Loaded(content) = webpage.content, let _ = content.story {
storiesRequiredValidation = true storiesRequiredValidation = true
} else if let media = media as? TelegramMediaAction {
if case let .conferenceCall(conferenceCall) = media.action {
if conferenceCall.duration != nil {
} else {
messageIdsWithGroupCalls.append(message.id)
}
}
} }
} }
if contentRequiredValidation { if contentRequiredValidation {
@ -3096,9 +3088,6 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
if !peerIdsWithRefreshStories.isEmpty { if !peerIdsWithRefreshStories.isEmpty {
self.context.account.viewTracker.refreshStoryStatsForPeerIds(peerIds: peerIdsWithRefreshStories) self.context.account.viewTracker.refreshStoryStatsForPeerIds(peerIds: peerIdsWithRefreshStories)
} }
if !messageIdsWithGroupCalls.isEmpty {
self.inlineGroupCallsProcessingManager.add(messageIdsWithGroupCalls.map { MessageAndThreadId(messageId: $0, threadId: nil) })
}
self.currentEarlierPrefetchMessages = toEarlierMediaMessages self.currentEarlierPrefetchMessages = toEarlierMediaMessages
self.currentLaterPrefetchMessages = toLaterMediaMessages self.currentLaterPrefetchMessages = toLaterMediaMessages

View File

@ -850,7 +850,7 @@ public func createGroupControllerImpl(context: AccountContext, peerIds: [PeerId]
|> deliverOnMainQueue).start(next: { peer in |> deliverOnMainQueue).start(next: { peer in
if let peer, let exportedInvitation, let link = exportedInvitation.link { if let peer, let exportedInvitation, let link = exportedInvitation.link {
let inviteScreen = SendInviteLinkScreen(context: context, peer: peer, link: link, peers: result.result.forbiddenPeers) let inviteScreen = SendInviteLinkScreen(context: context, subject: .chat(peer: peer, link: link), peers: result.result.forbiddenPeers)
controller?.push(inviteScreen) controller?.push(inviteScreen)
} }
}) })

View File

@ -81,6 +81,7 @@ import AccountFreezeInfoScreen
import JoinSubjectScreen import JoinSubjectScreen
import OldChannelsController import OldChannelsController
import InviteLinksUI import InviteLinksUI
import SendInviteLinkScreen
private final class AccountUserInterfaceInUseContext { private final class AccountUserInterfaceInUseContext {
let subscribers = Bag<(Bool) -> Void>() let subscribers = Bag<(Bool) -> Void>()
@ -3819,6 +3820,10 @@ public final class SharedAccountContextImpl: SharedAccountContext {
public func makeAccountFreezeInfoScreen(context: AccountContext) -> ViewController { public func makeAccountFreezeInfoScreen(context: AccountContext) -> ViewController {
return AccountFreezeInfoScreen(context: context) return AccountFreezeInfoScreen(context: context)
} }
public func makeSendInviteLinkScreen(context: AccountContext, subject: SendInviteLinkScreenSubject, peers: [TelegramForbiddenInvitePeer], theme: PresentationTheme?) -> ViewController {
return SendInviteLinkScreen(context: context, subject: subject, peers: peers, theme: theme)
}
} }
private func peerInfoControllerImpl(context: AccountContext, updatedPresentationData: (PresentationData, Signal<PresentationData, NoError>)?, peer: Peer, mode: PeerInfoControllerMode, avatarInitiallyExpanded: Bool, isOpenedFromChat: Bool, requestsContext: PeerInvitationImportersContext? = nil) -> ViewController? { private func peerInfoControllerImpl(context: AccountContext, updatedPresentationData: (PresentationData, Signal<PresentationData, NoError>)?, peer: Peer, mode: PeerInfoControllerMode, avatarInitiallyExpanded: Bool, isOpenedFromChat: Bool, requestsContext: PeerInvitationImportersContext? = nil) -> ViewController? {