mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Web Search improvements
This commit is contained in:
@@ -1203,9 +1203,9 @@ public func groupInfoController(account: Account, peerId: PeerId) -> ViewControl
|
||||
}))
|
||||
})
|
||||
}, changeProfilePhoto: {
|
||||
let _ = (account.postbox.transaction { transaction -> Peer? in
|
||||
return transaction.getPeer(peerId)
|
||||
} |> deliverOnMainQueue).start(next: { peer in
|
||||
let _ = (account.postbox.transaction { transaction -> (Peer?, SearchBotsConfiguration) in
|
||||
return (transaction.getPeer(peerId), currentSearchBotsConfiguration(transaction: transaction))
|
||||
} |> deliverOnMainQueue).start(next: { peer, searchBotsConfiguration in
|
||||
let presentationData = account.telegramApplicationContext.currentPresentationData.with { $0 }
|
||||
|
||||
let legacyController = LegacyController(presentation: .custom, theme: presentationData.theme)
|
||||
@@ -1225,28 +1225,38 @@ public func groupInfoController(account: Account, peerId: PeerId) -> ViewControl
|
||||
hasPhotos = true
|
||||
}
|
||||
|
||||
let mixin = TGMediaAvatarMenuMixin(context: legacyController.context, parentController: emptyController, hasDeleteButton: hasPhotos, personalPhoto: false, saveEditedPhotos: false, saveCapturedMedia: false)!
|
||||
let completedImpl: (UIImage) -> Void = { image in
|
||||
if let data = UIImageJPEGRepresentation(image, 0.6) {
|
||||
let resource = LocalFileMediaResource(fileId: arc4random64())
|
||||
account.postbox.mediaBox.storeResourceData(resource.id, data: data)
|
||||
let representation = TelegramMediaImageRepresentation(dimensions: CGSize(width: 640.0, height: 640.0), resource: resource)
|
||||
updateState {
|
||||
$0.withUpdatedUpdatingAvatar(.image(representation, true))
|
||||
}
|
||||
updateAvatarDisposable.set((updatePeerPhoto(postbox: account.postbox, network: account.network, stateManager: account.stateManager, accountPeerId: account.peerId, peerId: peerId, photo: uploadedPeerPhoto(postbox: account.postbox, network: account.network, resource: resource)) |> deliverOnMainQueue).start(next: { result in
|
||||
switch result {
|
||||
case .complete:
|
||||
updateState {
|
||||
$0.withUpdatedUpdatingAvatar(nil)
|
||||
}
|
||||
case .progress:
|
||||
break
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
let mixin = TGMediaAvatarMenuMixin(context: legacyController.context, parentController: emptyController, hasSearchButton: true, hasDeleteButton: hasPhotos, hasViewButton: false, personalPhoto: false, saveEditedPhotos: false, saveCapturedMedia: false, signup: false)!
|
||||
let _ = currentAvatarMixin.swap(mixin)
|
||||
mixin.requestSearchController = { _ in
|
||||
let controller = WebSearchController(account: account, peer: peer, configuration: searchBotsConfiguration, mode: .avatar(completion: { result in
|
||||
completedImpl(result)
|
||||
}))
|
||||
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
}
|
||||
mixin.didFinishWithImage = { image in
|
||||
if let image = image {
|
||||
if let data = UIImageJPEGRepresentation(image, 0.6) {
|
||||
let resource = LocalFileMediaResource(fileId: arc4random64())
|
||||
account.postbox.mediaBox.storeResourceData(resource.id, data: data)
|
||||
let representation = TelegramMediaImageRepresentation(dimensions: CGSize(width: 640.0, height: 640.0), resource: resource)
|
||||
updateState {
|
||||
$0.withUpdatedUpdatingAvatar(.image(representation, true))
|
||||
}
|
||||
updateAvatarDisposable.set((updatePeerPhoto(postbox: account.postbox, network: account.network, stateManager: account.stateManager, accountPeerId: account.peerId, peerId: peerId, photo: uploadedPeerPhoto(postbox: account.postbox, network: account.network, resource: resource)) |> deliverOnMainQueue).start(next: { result in
|
||||
switch result {
|
||||
case .complete:
|
||||
updateState {
|
||||
$0.withUpdatedUpdatingAvatar(nil)
|
||||
}
|
||||
case .progress:
|
||||
break
|
||||
}
|
||||
}))
|
||||
}
|
||||
completedImpl(image)
|
||||
}
|
||||
}
|
||||
mixin.didFinishWithDelete = {
|
||||
@@ -1361,9 +1371,25 @@ public func groupInfoController(account: Account, peerId: PeerId) -> ViewControl
|
||||
var options: [ContactListAdditionalOption] = []
|
||||
let presentationData = account.telegramApplicationContext.currentPresentationData.with { $0 }
|
||||
var inviteByLinkImpl: (() -> Void)?
|
||||
options.append(ContactListAdditionalOption(title: presentationData.strings.GroupInfo_InviteByLink, icon: generateTintedImage(image: UIImage(bundleImageName: "Contact List/LinkActionIcon"), color: presentationData.theme.list.itemAccentColor), action: {
|
||||
inviteByLinkImpl?()
|
||||
}))
|
||||
|
||||
var canCreateInviteLink = false
|
||||
if let group = groupPeer as? TelegramGroup {
|
||||
if case .creator = group.role {
|
||||
canCreateInviteLink = true
|
||||
}
|
||||
} else if let channel = groupPeer as? TelegramChannel {
|
||||
if channel.hasAdminRights(.canInviteUsers) {
|
||||
canCreateInviteLink = true
|
||||
} else if case let .group(info) = channel.info, info.flags.contains(.everyMemberCanInviteMembers) {
|
||||
canCreateInviteLink = true
|
||||
}
|
||||
}
|
||||
|
||||
if canCreateInviteLink {
|
||||
options.append(ContactListAdditionalOption(title: presentationData.strings.GroupInfo_InviteByLink, icon: generateTintedImage(image: UIImage(bundleImageName: "Contact List/LinkActionIcon"), color: presentationData.theme.list.itemAccentColor), action: {
|
||||
inviteByLinkImpl?()
|
||||
}))
|
||||
}
|
||||
|
||||
let contactsController: ViewController
|
||||
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
|
||||
Reference in New Issue
Block a user