mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Add more send link screens
This commit is contained in:
parent
f9f670c3e9
commit
e0ed54af90
@ -76,6 +76,7 @@ swift_library(
|
||||
"//submodules/PremiumUI:PremiumUI",
|
||||
"//submodules/Components/ReactionImageComponent:ReactionImageComponent",
|
||||
"//submodules/Components/LottieAnimationComponent:LottieAnimationComponent",
|
||||
"//submodules/TelegramUI/Components/SendInviteLinkScreen",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -14,6 +14,7 @@ import ItemListAvatarAndNameInfoItem
|
||||
import Emoji
|
||||
import LocalizedPeerData
|
||||
import Markdown
|
||||
import SendInviteLinkScreen
|
||||
|
||||
private let rankMaxLength: Int32 = 16
|
||||
|
||||
@ -975,10 +976,13 @@ public func channelAdminController(context: AccountContext, updatedPresentationD
|
||||
TelegramEngine.EngineData.Item.Peer.Peer(id: peerId),
|
||||
TelegramEngine.EngineData.Item.Peer.Peer(id: adminId),
|
||||
TelegramEngine.EngineData.Item.Peer.Presence(id: adminId)
|
||||
),
|
||||
context.engine.data.subscribe(
|
||||
TelegramEngine.EngineData.Item.Peer.ExportedInvitation(id: peerId)
|
||||
)
|
||||
)
|
||||
|> deliverOnMainQueue
|
||||
|> map { presentationData, state, peerInfoData -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
|> map { presentationData, state, peerInfoData, exportedInvitation -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
let channelPeer = peerInfoData.0.flatMap { $0 }
|
||||
let adminPeer = peerInfoData.1.flatMap { $0 }
|
||||
let adminPresence = peerInfoData.2
|
||||
@ -1011,6 +1015,15 @@ public func channelAdminController(context: AccountContext, updatedPresentationD
|
||||
updateState { current in
|
||||
return current.withUpdatedUpdating(false)
|
||||
}
|
||||
|
||||
if let adminPeer, let exportedInvitation, let link = exportedInvitation.link {
|
||||
let inviteScreen = SendInviteLinkScreen(context: context, link: link, peers: [adminPeer])
|
||||
pushControllerImpl?(inviteScreen)
|
||||
|
||||
dismissImpl?()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
var text = presentationData.strings.Login_UnknownError
|
||||
@ -1193,6 +1206,15 @@ 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
|
||||
if case let .addMemberError(addMemberError) = error, let admin = adminPeer {
|
||||
if let exportedInvitation, let link = exportedInvitation.link {
|
||||
let inviteScreen = SendInviteLinkScreen(context: context, link: link, peers: [admin])
|
||||
pushControllerImpl?(inviteScreen)
|
||||
|
||||
dismissImpl?()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
var text = presentationData.strings.Login_UnknownError
|
||||
switch addMemberError {
|
||||
case .tooMuchJoined:
|
||||
|
@ -15,6 +15,7 @@ import ItemListPeerItem
|
||||
import ItemListPeerActionItem
|
||||
import InviteLinksUI
|
||||
import UndoUI
|
||||
import SendInviteLinkScreen
|
||||
|
||||
private final class ChannelMembersControllerArguments {
|
||||
let context: AccountContext
|
||||
@ -510,16 +511,18 @@ public func channelMembersController(context: AccountContext, updatedPresentatio
|
||||
let contactsPromise = Promise<[RenderedChannelParticipant]?>(nil)
|
||||
|
||||
let arguments = ChannelMembersControllerArguments(context: context, addMember: {
|
||||
actionsDisposable.add((peersPromise.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { members in
|
||||
actionsDisposable.add((combineLatest(
|
||||
context.engine.data.get(TelegramEngine.EngineData.Item.Peer.ExportedInvitation(id: peerId)),
|
||||
peersPromise.get() |> take(1)
|
||||
)
|
||||
|> deliverOnMainQueue).start(next: { exportedInvitation, members in
|
||||
let disabledIds = members?.compactMap({$0.peer.id}) ?? []
|
||||
let contactsController = context.sharedContext.makeContactMultiselectionController(ContactMultiselectionControllerParams(context: context, updatedPresentationData: updatedPresentationData, mode: .peerSelection(searchChatList: false, searchGroups: false, searchChannels: false), options: [], filters: [.excludeSelf, .disable(disabledIds)]))
|
||||
|
||||
addMembersDisposable.set((contactsController.result
|
||||
addMembersDisposable.set((
|
||||
contactsController.result
|
||||
|> deliverOnMainQueue
|
||||
|> castError(AddChannelMemberError.self)
|
||||
|> mapToSignal { [weak contactsController] result -> Signal<Never, AddChannelMemberError> in
|
||||
|> mapToSignal { [weak contactsController] result -> Signal<[(PeerId, AddChannelMemberError)], NoError> in
|
||||
contactsController?.displayProgress = true
|
||||
|
||||
var contacts: [ContactListPeerId] = []
|
||||
@ -527,7 +530,7 @@ public func channelMembersController(context: AccountContext, updatedPresentatio
|
||||
contacts = peerIdsValue
|
||||
}
|
||||
|
||||
let signal = context.peerChannelMemberCategoriesContextsManager.addMembers(engine: context.engine, peerId: peerId, memberIds: contacts.compactMap({ contact -> PeerId? in
|
||||
let signal = context.peerChannelMemberCategoriesContextsManager.addMembersAllowPartial(engine: context.engine, peerId: peerId, memberIds: contacts.compactMap({ contact -> PeerId? in
|
||||
switch contact {
|
||||
case let .peer(contactId):
|
||||
return contactId
|
||||
@ -537,17 +540,43 @@ public func channelMembersController(context: AccountContext, updatedPresentatio
|
||||
}))
|
||||
|
||||
return signal
|
||||
|> ignoreValues
|
||||
|> deliverOnMainQueue
|
||||
|> afterCompleted {
|
||||
contactsController?.dismiss()
|
||||
}
|
||||
}).start(error: { [weak contactsController] error in
|
||||
}).start(next: { [weak contactsController] failedPeerIds in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
let text: String
|
||||
switch error {
|
||||
|
||||
if failedPeerIds.isEmpty {
|
||||
contactsController?.dismiss()
|
||||
} else {
|
||||
if let exportedInvitation, let link = exportedInvitation.link {
|
||||
let _ = (context.engine.data.get(
|
||||
EngineDataList(failedPeerIds.compactMap { item -> EnginePeer.Id? in
|
||||
return item.0
|
||||
}.map(TelegramEngine.EngineData.Item.Peer.Peer.init(id:)))
|
||||
)
|
||||
|> deliverOnMainQueue).start(next: { peerItems in
|
||||
let peers = peerItems.compactMap { $0 }
|
||||
if !peers.isEmpty, let contactsController, let navigationController = contactsController.navigationController as? NavigationController {
|
||||
var viewControllers = navigationController.viewControllers
|
||||
if let index = viewControllers.firstIndex(where: { $0 === contactsController }) {
|
||||
let inviteScreen = SendInviteLinkScreen(context: context, link: link, peers: peers)
|
||||
viewControllers.remove(at: index)
|
||||
viewControllers.append(inviteScreen)
|
||||
navigationController.setViewControllers(viewControllers, animated: true)
|
||||
}
|
||||
} else {
|
||||
contactsController?.dismiss()
|
||||
}
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
contactsController?.dismiss()
|
||||
|
||||
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
let text: String
|
||||
switch failedPeerIds[0].1 {
|
||||
case .limitExceeded:
|
||||
text = presentationData.strings.Channel_ErrorAddTooMuch
|
||||
case .tooMuchJoined:
|
||||
@ -557,13 +586,13 @@ public func channelMembersController(context: AccountContext, updatedPresentatio
|
||||
case .restricted:
|
||||
text = presentationData.strings.Channel_ErrorAddBlocked
|
||||
case .notMutualContact:
|
||||
if case let .channel(peer) = peer, case .broadcast = peer.info {
|
||||
if case let .channel(peer) = peer, case .broadcast = peer.info {
|
||||
text = presentationData.strings.Channel_AddUserLeftError
|
||||
} else {
|
||||
text = presentationData.strings.GroupInfo_AddUserLeftError
|
||||
}
|
||||
case let .bot(memberId):
|
||||
guard case let .channel(peer) = peer else {
|
||||
guard case let .channel(peer) = peer else {
|
||||
presentControllerImpl?(textAlertController(context: context, updatedPresentationData: updatedPresentationData, title: nil, text: presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
contactsController?.dismiss()
|
||||
return
|
||||
@ -589,10 +618,11 @@ public func channelMembersController(context: AccountContext, updatedPresentatio
|
||||
text = presentationData.strings.Channel_TooMuchBots
|
||||
case .kicked:
|
||||
text = presentationData.strings.Channel_AddUserKickedError
|
||||
}
|
||||
presentControllerImpl?(textAlertController(context: context, updatedPresentationData: updatedPresentationData, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
contactsController?.dismiss()
|
||||
})
|
||||
}
|
||||
presentControllerImpl?(textAlertController(context: context, updatedPresentationData: updatedPresentationData, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
contactsController?.dismiss()
|
||||
})
|
||||
}
|
||||
}))
|
||||
|
||||
presentControllerImpl?(contactsController, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
|
Loading…
x
Reference in New Issue
Block a user