mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Separate channel voice chat localization
This commit is contained in:
parent
eab8e7cf68
commit
235934ae8a
@ -5719,6 +5719,7 @@ Sorry for the inconvenience.";
|
|||||||
|
|
||||||
"VoiceChat.PanelJoin" = "Join";
|
"VoiceChat.PanelJoin" = "Join";
|
||||||
"VoiceChat.Title" = "Voice Chat";
|
"VoiceChat.Title" = "Voice Chat";
|
||||||
|
"VoiceChatChannel.Title" = "Live Stream";
|
||||||
|
|
||||||
"VoiceChat.InviteMember" = "Invite Member";
|
"VoiceChat.InviteMember" = "Invite Member";
|
||||||
"VoiceChat.UserInvited" = "You invited **%@** to the voice chat";
|
"VoiceChat.UserInvited" = "You invited **%@** to the voice chat";
|
||||||
@ -6365,6 +6366,7 @@ Sorry for the inconvenience.";
|
|||||||
"ChannelInfo.ScheduleVoiceChat" = "Schedule Voice Chat";
|
"ChannelInfo.ScheduleVoiceChat" = "Schedule Voice Chat";
|
||||||
|
|
||||||
"ScheduleVoiceChat.Title" = "Schedule Voice Chat";
|
"ScheduleVoiceChat.Title" = "Schedule Voice Chat";
|
||||||
|
"ScheduleVoiceChatChannel.Title" = "Schedule Voice Chat";
|
||||||
"ScheduleVoiceChat.GroupText" = "The members of the group will be notified that the voice chat will start in %@.";
|
"ScheduleVoiceChat.GroupText" = "The members of the group will be notified that the voice chat will start in %@.";
|
||||||
"ScheduleVoiceChat.ChannelText" = "The members of the channel will be notified that the voice chat will start in %@.";
|
"ScheduleVoiceChat.ChannelText" = "The members of the channel will be notified that the voice chat will start in %@.";
|
||||||
|
|
||||||
|
@ -265,21 +265,32 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder {
|
|||||||
let availableGroupCall: Signal<GroupCallPanelData?, NoError>
|
let availableGroupCall: Signal<GroupCallPanelData?, NoError>
|
||||||
if case let .peer(peerId) = groupCallPanelSource {
|
if case let .peer(peerId) = groupCallPanelSource {
|
||||||
availableGroupCall = context.account.viewTracker.peerView(peerId)
|
availableGroupCall = context.account.viewTracker.peerView(peerId)
|
||||||
|> map { peerView -> CachedChannelData.ActiveCall? in
|
|> map { peerView -> (CachedChannelData.ActiveCall?, EnginePeer?) in
|
||||||
|
let peer = peerView.peers[peerId].flatMap(EnginePeer.init)
|
||||||
if let cachedData = peerView.cachedData as? CachedChannelData {
|
if let cachedData = peerView.cachedData as? CachedChannelData {
|
||||||
return cachedData.activeCall
|
return (cachedData.activeCall, peer)
|
||||||
} else if let cachedData = peerView.cachedData as? CachedGroupData {
|
} else if let cachedData = peerView.cachedData as? CachedGroupData {
|
||||||
return cachedData.activeCall
|
return (cachedData.activeCall, peer)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return (nil, peer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> distinctUntilChanged
|
|> distinctUntilChanged(isEqual: { lhs, rhs in
|
||||||
|> mapToSignal { activeCall -> Signal<GroupCallPanelData?, NoError> in
|
if lhs.0 != rhs.0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|> mapToSignal { activeCall, peer -> Signal<GroupCallPanelData?, NoError> in
|
||||||
guard let activeCall = activeCall else {
|
guard let activeCall = activeCall else {
|
||||||
return .single(nil)
|
return .single(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isChannel = false
|
||||||
|
if let peer = peer, case let .channel(channel) = peer, case .broadcast = channel.info {
|
||||||
|
isChannel = true
|
||||||
|
}
|
||||||
|
|
||||||
return Signal { [weak context] subscriber in
|
return Signal { [weak context] subscriber in
|
||||||
guard let context = context, let callContextCache = context.cachedGroupCallContexts as? AccountGroupCallContextCacheImpl else {
|
guard let context = context, let callContextCache = context.cachedGroupCallContexts as? AccountGroupCallContextCacheImpl else {
|
||||||
return EmptyDisposable
|
return EmptyDisposable
|
||||||
@ -288,7 +299,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder {
|
|||||||
let disposable = MetaDisposable()
|
let disposable = MetaDisposable()
|
||||||
|
|
||||||
callContextCache.impl.syncWith { impl in
|
callContextCache.impl.syncWith { impl in
|
||||||
let callContext = impl.get(account: context.account, engine: context.engine, peerId: peerId, call: EngineGroupCallDescription(activeCall))
|
let callContext = impl.get(account: context.account, engine: context.engine, peerId: peerId, isChannel: isChannel, call: EngineGroupCallDescription(activeCall))
|
||||||
disposable.set((callContext.context.panelData
|
disposable.set((callContext.context.panelData
|
||||||
|> deliverOnMainQueue).start(next: { panelData in
|
|> deliverOnMainQueue).start(next: { panelData in
|
||||||
callContext.keep()
|
callContext.keep()
|
||||||
|
@ -40,6 +40,7 @@ public enum GroupCallPanelSource {
|
|||||||
|
|
||||||
public final class GroupCallPanelData {
|
public final class GroupCallPanelData {
|
||||||
public let peerId: PeerId
|
public let peerId: PeerId
|
||||||
|
public let isChannel: Bool
|
||||||
public let info: GroupCallInfo
|
public let info: GroupCallInfo
|
||||||
public let topParticipants: [GroupCallParticipantsContext.Participant]
|
public let topParticipants: [GroupCallParticipantsContext.Participant]
|
||||||
public let participantCount: Int
|
public let participantCount: Int
|
||||||
@ -48,6 +49,7 @@ public final class GroupCallPanelData {
|
|||||||
|
|
||||||
public init(
|
public init(
|
||||||
peerId: PeerId,
|
peerId: PeerId,
|
||||||
|
isChannel: Bool,
|
||||||
info: GroupCallInfo,
|
info: GroupCallInfo,
|
||||||
topParticipants: [GroupCallParticipantsContext.Participant],
|
topParticipants: [GroupCallParticipantsContext.Participant],
|
||||||
participantCount: Int,
|
participantCount: Int,
|
||||||
@ -55,6 +57,7 @@ public final class GroupCallPanelData {
|
|||||||
groupCall: PresentationGroupCall?
|
groupCall: PresentationGroupCall?
|
||||||
) {
|
) {
|
||||||
self.peerId = peerId
|
self.peerId = peerId
|
||||||
|
self.isChannel = isChannel
|
||||||
self.info = info
|
self.info = info
|
||||||
self.topParticipants = topParticipants
|
self.topParticipants = topParticipants
|
||||||
self.participantCount = participantCount
|
self.participantCount = participantCount
|
||||||
@ -523,6 +526,9 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
|
|
||||||
var joinText = self.strings.VoiceChat_PanelJoin
|
var joinText = self.strings.VoiceChat_PanelJoin
|
||||||
var title = self.strings.VoiceChat_Title
|
var title = self.strings.VoiceChat_Title
|
||||||
|
if let currentData = self.currentData, currentData.isChannel {
|
||||||
|
title = self.strings.VoiceChatChannel_Title
|
||||||
|
}
|
||||||
var text = self.currentText
|
var text = self.currentText
|
||||||
var isScheduled = false
|
var isScheduled = false
|
||||||
var isLate = false
|
var isLate = false
|
||||||
|
@ -650,9 +650,12 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
}
|
}
|
||||||
|> runOn(Queue.mainQueue())
|
|> runOn(Queue.mainQueue())
|
||||||
|
|
||||||
return accessEnabledSignal
|
return combineLatest(queue: .mainQueue(),
|
||||||
|
accessEnabledSignal,
|
||||||
|
accountContext.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|
||||||
|
)
|
||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { [weak self] accessEnabled -> Signal<Bool, NoError> in
|
|> mapToSignal { [weak self] accessEnabled, peer -> Signal<Bool, NoError> in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return .single(false)
|
return .single(false)
|
||||||
}
|
}
|
||||||
@ -661,6 +664,11 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
return .single(false)
|
return .single(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isChannel = false
|
||||||
|
if let peer = peer, case let .channel(channel) = peer, case .broadcast = channel.info {
|
||||||
|
isChannel = true
|
||||||
|
}
|
||||||
|
|
||||||
let call = PresentationGroupCallImpl(
|
let call = PresentationGroupCallImpl(
|
||||||
accountContext: accountContext,
|
accountContext: accountContext,
|
||||||
audioSession: strongSelf.audioSession,
|
audioSession: strongSelf.audioSession,
|
||||||
@ -669,6 +677,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
initialCall: nil,
|
initialCall: nil,
|
||||||
internalId: internalId,
|
internalId: internalId,
|
||||||
peerId: peerId,
|
peerId: peerId,
|
||||||
|
isChannel: isChannel,
|
||||||
invite: nil,
|
invite: nil,
|
||||||
joinAsPeerId: nil
|
joinAsPeerId: nil
|
||||||
)
|
)
|
||||||
@ -803,9 +812,12 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
}
|
}
|
||||||
|> runOn(Queue.mainQueue())
|
|> runOn(Queue.mainQueue())
|
||||||
|
|
||||||
return accessEnabledSignal
|
return combineLatest(queue: .mainQueue(),
|
||||||
|
accessEnabledSignal,
|
||||||
|
accountContext.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|
||||||
|
)
|
||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> mapToSignal { [weak self] accessEnabled -> Signal<Bool, NoError> in
|
|> mapToSignal { [weak self] accessEnabled, peer -> Signal<Bool, NoError> in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return .single(false)
|
return .single(false)
|
||||||
}
|
}
|
||||||
@ -814,6 +826,11 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
return .single(false)
|
return .single(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isChannel = false
|
||||||
|
if let peer = peer, case let .channel(channel) = peer, case .broadcast = channel.info {
|
||||||
|
isChannel = true
|
||||||
|
}
|
||||||
|
|
||||||
let call = PresentationGroupCallImpl(
|
let call = PresentationGroupCallImpl(
|
||||||
accountContext: accountContext,
|
accountContext: accountContext,
|
||||||
audioSession: strongSelf.audioSession,
|
audioSession: strongSelf.audioSession,
|
||||||
@ -822,6 +839,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
initialCall: initialCall,
|
initialCall: initialCall,
|
||||||
internalId: internalId,
|
internalId: internalId,
|
||||||
peerId: peerId,
|
peerId: peerId,
|
||||||
|
isChannel: isChannel,
|
||||||
invite: invite,
|
invite: invite,
|
||||||
joinAsPeerId: joinAsPeerId
|
joinAsPeerId: joinAsPeerId
|
||||||
)
|
)
|
||||||
|
@ -91,9 +91,10 @@ public final class AccountGroupCallContextImpl: AccountGroupCallContext {
|
|||||||
return self.panelDataPromise.get()
|
return self.panelDataPromise.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(account: Account, engine: TelegramEngine, peerId: PeerId, call: EngineGroupCallDescription) {
|
public init(account: Account, engine: TelegramEngine, peerId: PeerId, isChannel: Bool, call: EngineGroupCallDescription) {
|
||||||
self.panelDataPromise.set(.single(GroupCallPanelData(
|
self.panelDataPromise.set(.single(GroupCallPanelData(
|
||||||
peerId: peerId,
|
peerId: peerId,
|
||||||
|
isChannel: isChannel,
|
||||||
info: GroupCallInfo(
|
info: GroupCallInfo(
|
||||||
id: call.id,
|
id: call.id,
|
||||||
accessHash: call.accessHash,
|
accessHash: call.accessHash,
|
||||||
@ -114,12 +115,17 @@ public final class AccountGroupCallContextImpl: AccountGroupCallContext {
|
|||||||
groupCall: nil
|
groupCall: nil
|
||||||
)))
|
)))
|
||||||
|
|
||||||
self.disposable = (engine.calls.getGroupCallParticipants(callId: call.id, accessHash: call.accessHash, offset: "", ssrcs: [], limit: 100, sortAscending: nil)
|
let state = engine.calls.getGroupCallParticipants(callId: call.id, accessHash: call.accessHash, offset: "", ssrcs: [], limit: 100, sortAscending: nil)
|
||||||
|> map(Optional.init)
|
|> map(Optional.init)
|
||||||
|> `catch` { _ -> Signal<GroupCallParticipantsContext.State?, NoError> in
|
|> `catch` { _ -> Signal<GroupCallParticipantsContext.State?, NoError> in
|
||||||
return .single(nil)
|
return .single(nil)
|
||||||
}
|
}
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] state in
|
|
||||||
|
self.disposable = (combineLatest(queue: .mainQueue(),
|
||||||
|
state,
|
||||||
|
engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|
||||||
|
)
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] state, peer in
|
||||||
guard let strongSelf = self, let state = state else {
|
guard let strongSelf = self, let state = state else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -145,8 +151,15 @@ public final class AccountGroupCallContextImpl: AccountGroupCallContext {
|
|||||||
}
|
}
|
||||||
topParticipants.append(participant)
|
topParticipants.append(participant)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isChannel = false
|
||||||
|
if let peer = peer, case let .channel(channel) = peer, case .broadcast = channel.info {
|
||||||
|
isChannel = true
|
||||||
|
}
|
||||||
|
|
||||||
return GroupCallPanelData(
|
return GroupCallPanelData(
|
||||||
peerId: peerId,
|
peerId: peerId,
|
||||||
|
isChannel: isChannel,
|
||||||
info: GroupCallInfo(id: call.id, accessHash: call.accessHash, participantCount: state.totalCount, streamDcId: nil, title: state.title, scheduleTimestamp: state.scheduleTimestamp, subscribedToScheduled: state.subscribedToScheduled, recordingStartTimestamp: nil, sortAscending: state.sortAscending, defaultParticipantsAreMuted: state.defaultParticipantsAreMuted, isVideoEnabled: state.isVideoEnabled, unmutedVideoLimit: state.unmutedVideoLimit),
|
info: GroupCallInfo(id: call.id, accessHash: call.accessHash, participantCount: state.totalCount, streamDcId: nil, title: state.title, scheduleTimestamp: state.scheduleTimestamp, subscribedToScheduled: state.subscribedToScheduled, recordingStartTimestamp: nil, sortAscending: state.sortAscending, defaultParticipantsAreMuted: state.defaultParticipantsAreMuted, isVideoEnabled: state.isVideoEnabled, unmutedVideoLimit: state.unmutedVideoLimit),
|
||||||
topParticipants: topParticipants,
|
topParticipants: topParticipants,
|
||||||
participantCount: state.totalCount,
|
participantCount: state.totalCount,
|
||||||
@ -183,12 +196,12 @@ public final class AccountGroupCallContextCacheImpl: AccountGroupCallContextCach
|
|||||||
self.queue = queue
|
self.queue = queue
|
||||||
}
|
}
|
||||||
|
|
||||||
public func get(account: Account, engine: TelegramEngine, peerId: PeerId, call: EngineGroupCallDescription) -> AccountGroupCallContextImpl.Proxy {
|
public func get(account: Account, engine: TelegramEngine, peerId: PeerId, isChannel: Bool, call: EngineGroupCallDescription) -> AccountGroupCallContextImpl.Proxy {
|
||||||
let result: Record
|
let result: Record
|
||||||
if let current = self.contexts[call.id] {
|
if let current = self.contexts[call.id] {
|
||||||
result = current
|
result = current
|
||||||
} else {
|
} else {
|
||||||
let context = AccountGroupCallContextImpl(account: account, engine: engine, peerId: peerId, call: call)
|
let context = AccountGroupCallContextImpl(account: account, engine: engine, peerId: peerId, isChannel: isChannel, call: call)
|
||||||
result = Record(context: context)
|
result = Record(context: context)
|
||||||
self.contexts[call.id] = result
|
self.contexts[call.id] = result
|
||||||
}
|
}
|
||||||
@ -624,6 +637,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
initialCall: EngineGroupCallDescription?,
|
initialCall: EngineGroupCallDescription?,
|
||||||
internalId: CallSessionInternalId,
|
internalId: CallSessionInternalId,
|
||||||
peerId: PeerId,
|
peerId: PeerId,
|
||||||
|
isChannel: Bool,
|
||||||
invite: String?,
|
invite: String?,
|
||||||
joinAsPeerId: PeerId?
|
joinAsPeerId: PeerId?
|
||||||
) {
|
) {
|
||||||
@ -822,7 +836,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if let initialCall = initialCall, let temporaryParticipantsContext = (self.accountContext.cachedGroupCallContexts as? AccountGroupCallContextCacheImpl)?.impl.syncWith({ impl in
|
if let initialCall = initialCall, let temporaryParticipantsContext = (self.accountContext.cachedGroupCallContexts as? AccountGroupCallContextCacheImpl)?.impl.syncWith({ impl in
|
||||||
impl.get(account: accountContext.account, engine: accountContext.engine, peerId: peerId, call: EngineGroupCallDescription(id: initialCall.id, accessHash: initialCall.accessHash, title: initialCall.title, scheduleTimestamp: initialCall.scheduleTimestamp, subscribedToScheduled: initialCall.subscribedToScheduled))
|
impl.get(account: accountContext.account, engine: accountContext.engine, peerId: peerId, isChannel: isChannel, call: EngineGroupCallDescription(id: initialCall.id, accessHash: initialCall.accessHash, title: initialCall.title, scheduleTimestamp: initialCall.scheduleTimestamp, subscribedToScheduled: initialCall.subscribedToScheduled))
|
||||||
}) {
|
}) {
|
||||||
self.switchToTemporaryParticipantsContext(sourceContext: temporaryParticipantsContext.context.participantsContext, oldMyPeerId: self.joinAsPeerId)
|
self.switchToTemporaryParticipantsContext(sourceContext: temporaryParticipantsContext.context.participantsContext, oldMyPeerId: self.joinAsPeerId)
|
||||||
} else {
|
} else {
|
||||||
|
@ -3920,16 +3920,24 @@ public final class VoiceChatController: ViewController {
|
|||||||
|
|
||||||
var title = self.currentTitle
|
var title = self.currentTitle
|
||||||
if self.isScheduling {
|
if self.isScheduling {
|
||||||
|
if let peer = self.peer as? TelegramChannel, case .broadcast = peer.info {
|
||||||
|
title = self.presentationData.strings.ScheduleVoiceChatChannel_Title
|
||||||
|
} else {
|
||||||
title = self.presentationData.strings.ScheduleVoiceChat_Title
|
title = self.presentationData.strings.ScheduleVoiceChat_Title
|
||||||
|
}
|
||||||
} else if case .modal(_, false) = self.displayMode, !self.currentTitleIsCustom {
|
} else if case .modal(_, false) = self.displayMode, !self.currentTitleIsCustom {
|
||||||
if let navigationController = self.controller?.navigationController as? NavigationController {
|
if let navigationController = self.controller?.navigationController as? NavigationController {
|
||||||
for controller in navigationController.viewControllers.reversed() {
|
for controller in navigationController.viewControllers.reversed() {
|
||||||
if let controller = controller as? ChatController, case let .peer(peerId) = controller.chatLocation, peerId == self.call.peerId {
|
if let controller = controller as? ChatController, case let .peer(peerId) = controller.chatLocation, peerId == self.call.peerId {
|
||||||
|
if let peer = self.peer as? TelegramChannel, case .broadcast = peer.info {
|
||||||
|
title = self.presentationData.strings.VoiceChatChannel_Title
|
||||||
|
} else {
|
||||||
title = self.presentationData.strings.VoiceChat_Title
|
title = self.presentationData.strings.VoiceChat_Title
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var subtitle = self.currentSpeakingSubtitle ?? self.currentSubtitle
|
var subtitle = self.currentSpeakingSubtitle ?? self.currentSubtitle
|
||||||
var speaking = self.currentSpeakingSubtitle != nil
|
var speaking = self.currentSpeakingSubtitle != nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user