mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Web app improvements
This commit is contained in:
parent
05241e3b0a
commit
f13b1da0bb
@ -581,7 +581,7 @@ public func channelAdminsController(context: AccountContext, updatedPresentation
|
|||||||
guard let peer = peer, let user = user else {
|
guard let peer = peer, let user = user else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
presentControllerImpl?(UndoOverlayController(presentationData: context.sharedContext.currentPresentationData.with { $0 }, content: .succeed(text: presentationData.strings.Channel_OwnershipTransfer_TransferCompleted(user.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string), elevatedLayout: false, action: { _ in return false }), nil)
|
presentControllerImpl?(UndoOverlayController(presentationData: context.sharedContext.currentPresentationData.with { $0 }, content: .succeed(text: presentationData.strings.Channel_OwnershipTransfer_TransferCompleted(user.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string, timeout: nil), elevatedLayout: false, action: { _ in return false }), nil)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ public func dataPrivacyController(context: AccountContext) -> ViewController {
|
|||||||
text = nil
|
text = nil
|
||||||
}
|
}
|
||||||
if let text = text {
|
if let text = text {
|
||||||
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .succeed(text: text), elevatedLayout: false, action: { _ in return false }))
|
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .succeed(text: text, timeout: nil), elevatedLayout: false, action: { _ in return false }))
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -426,7 +426,7 @@ public func dataPrivacyController(context: AccountContext) -> ViewController {
|
|||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.Privacy_ContactsReset_ContactsDeleted), elevatedLayout: false, action: { _ in return false }))
|
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.Privacy_ContactsReset_ContactsDeleted, timeout: nil), elevatedLayout: false, action: { _ in return false }))
|
||||||
}))
|
}))
|
||||||
}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {})]))
|
}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {})]))
|
||||||
}
|
}
|
||||||
@ -476,7 +476,7 @@ public func dataPrivacyController(context: AccountContext) -> ViewController {
|
|||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.Privacy_DeleteDrafts_DraftsDeleted), elevatedLayout: false, action: { _ in return false }))
|
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.Privacy_DeleteDrafts_DraftsDeleted, timeout: nil), elevatedLayout: false, action: { _ in return false }))
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
dismissAction()
|
dismissAction()
|
||||||
|
@ -426,6 +426,8 @@ func _internal_addBotToAttachMenu(accountPeerId: PeerId, postbox: Postbox, netwo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func _internal_removeBotFromAttachMenu(accountPeerId: PeerId, postbox: Postbox, network: Network, botId: PeerId) -> Signal<Bool, NoError> {
|
func _internal_removeBotFromAttachMenu(accountPeerId: PeerId, postbox: Postbox, network: Network, botId: PeerId) -> Signal<Bool, NoError> {
|
||||||
|
let _ = removeCachedAttachMenuBot(postbox: postbox, botId: botId).start()
|
||||||
|
|
||||||
return postbox.transaction { transaction -> Signal<Bool, NoError> in
|
return postbox.transaction { transaction -> Signal<Bool, NoError> in
|
||||||
guard let peer = transaction.getPeer(botId), let inputUser = apiInputUser(peer) else {
|
guard let peer = transaction.getPeer(botId), let inputUser = apiInputUser(peer) else {
|
||||||
return .complete()
|
return .complete()
|
||||||
@ -445,7 +447,7 @@ func _internal_removeBotFromAttachMenu(accountPeerId: PeerId, postbox: Postbox,
|
|||||||
|> afterCompleted {
|
|> afterCompleted {
|
||||||
let _ = (managedSynchronizeAttachMenuBots(accountPeerId: accountPeerId, postbox: postbox, network: network, force: true)
|
let _ = (managedSynchronizeAttachMenuBots(accountPeerId: accountPeerId, postbox: postbox, network: network, force: true)
|
||||||
|> take(1)).start(completed: {
|
|> take(1)).start(completed: {
|
||||||
let _ = removeCachedAttachMenuBot(postbox: postbox, botId: botId)
|
let _ = removeCachedAttachMenuBot(postbox: postbox, botId: botId).start()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class LegacyMessageInputPanelNode: ASDisplayNode, TGCaptionPanelView {
|
|||||||
if let view = self.inputPanel.view as? MessageInputPanelComponent.View {
|
if let view = self.inputPanel.view as? MessageInputPanelComponent.View {
|
||||||
self.isEmojiKeyboardActive = false
|
self.isEmojiKeyboardActive = false
|
||||||
self.inputView = nil
|
self.inputView = nil
|
||||||
view.deactivateInput()
|
view.deactivateInput(force: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,6 +158,8 @@ public class LegacyMessageInputPanelNode: ASDisplayNode, TGCaptionPanelView {
|
|||||||
var maxInputPanelHeight = maxHeight
|
var maxInputPanelHeight = maxHeight
|
||||||
if keyboardHeight.isZero {
|
if keyboardHeight.isZero {
|
||||||
maxInputPanelHeight = 60.0
|
maxInputPanelHeight = 60.0
|
||||||
|
} else {
|
||||||
|
maxInputPanelHeight = maxHeight - keyboardHeight - 100.0
|
||||||
}
|
}
|
||||||
|
|
||||||
var resetInputContents: MessageInputPanelComponent.SendMessageInput?
|
var resetInputContents: MessageInputPanelComponent.SendMessageInput?
|
||||||
|
@ -2276,7 +2276,7 @@ final class StorageUsageScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
|
||||||
controller.present(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.ClearCache_Success("\(dataSizeString(size, formatting: DataSizeStringFormatting(presentationData: presentationData)))", stringForDeviceType()).string), elevatedLayout: false, action: { _ in return false }), in: .current)
|
controller.present(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.ClearCache_Success("\(dataSizeString(size, formatting: DataSizeStringFormatting(presentationData: presentationData)))", stringForDeviceType()).string, timeout: nil), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func reloadStats(firstTime: Bool, completion: @escaping () -> Void) {
|
private func reloadStats(firstTime: Bool, completion: @escaping () -> Void) {
|
||||||
|
@ -1785,15 +1785,7 @@ final class StoryItemSetContainerSendMessage {
|
|||||||
//TODO:gift controller
|
//TODO:gift controller
|
||||||
break
|
break
|
||||||
case let .app(bot):
|
case let .app(bot):
|
||||||
var payload: String?
|
let params = WebAppParameters(source: .attachMenu, peerId: peer.id, botId: bot.peer.id, botName: bot.shortName, url: nil, queryId: nil, payload: nil, buttonText: nil, keepAliveSignal: nil, forceHasSettings: false)
|
||||||
var fromAttachMenu = true
|
|
||||||
/*if case let .bot(_, botPayload, _) = subject {
|
|
||||||
payload = botPayload
|
|
||||||
fromAttachMenu = false
|
|
||||||
}*/
|
|
||||||
payload = nil
|
|
||||||
fromAttachMenu = true
|
|
||||||
let params = WebAppParameters(peerId: peer.id, botId: bot.peer.id, botName: bot.shortName, url: nil, queryId: nil, payload: payload, buttonText: nil, keepAliveSignal: nil, fromMenu: false, fromAttachMenu: fromAttachMenu, isInline: false, isSimple: false, forceHasSettings: false)
|
|
||||||
let theme = component.theme
|
let theme = component.theme
|
||||||
let updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>) = (component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: theme), component.context.sharedContext.presentationData |> map { $0.withUpdated(theme: theme) })
|
let updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>) = (component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: theme), component.context.sharedContext.presentationData |> map { $0.withUpdated(theme: theme) })
|
||||||
let controller = WebAppController(context: component.context, updatedPresentationData: updatedPresentationData, params: params, replyToMessageId: nil, threadId: nil)
|
let controller = WebAppController(context: component.context, updatedPresentationData: updatedPresentationData, params: params, replyToMessageId: nil, threadId: nil)
|
||||||
|
@ -4220,7 +4220,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
return state.updatedShowWebView(true).updatedForceInputCommandsHidden(true)
|
return state.updatedShowWebView(true).updatedForceInputCommandsHidden(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, fromMenu: true, fromAttachMenu: false, isInline: false, isSimple: false, forceHasSettings: false)
|
let params = WebAppParameters(source: .menu, peerId: peerId, botId: peerId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, forceHasSettings: false)
|
||||||
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
||||||
self?.openUrl(url, concealed: concealed, forceExternal: true, commit: commit)
|
self?.openUrl(url, concealed: concealed, forceExternal: true, commit: commit)
|
||||||
}, requestSwitchInline: { [weak self] query, chatTypes, completion in
|
}, requestSwitchInline: { [weak self] query, chatTypes, completion in
|
||||||
@ -4291,7 +4291,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let params = WebAppParameters(peerId: peerId, botId: botId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, fromMenu: false, fromAttachMenu: false, isInline: isInline, isSimple: true, forceHasSettings: false)
|
let params = WebAppParameters(source: isInline ? .inline : .simple, peerId: peerId, botId: botId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, forceHasSettings: false)
|
||||||
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
||||||
self?.openUrl(url, concealed: concealed, forceExternal: true, commit: commit)
|
self?.openUrl(url, concealed: concealed, forceExternal: true, commit: commit)
|
||||||
}, requestSwitchInline: { [weak self] query, chatTypes, completion in
|
}, requestSwitchInline: { [weak self] query, chatTypes, completion in
|
||||||
@ -4331,7 +4331,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: result.url, queryId: result.queryId, payload: nil, buttonText: buttonText, keepAliveSignal: result.keepAliveSignal, fromMenu: false, fromAttachMenu: false, isInline: false, isSimple: false, forceHasSettings: false)
|
let params = WebAppParameters(source: .generic, peerId: peerId, botId: peerId, botName: botName, url: result.url, queryId: result.queryId, payload: nil, buttonText: buttonText, keepAliveSignal: result.keepAliveSignal, forceHasSettings: false)
|
||||||
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
||||||
self?.openUrl(url, concealed: concealed, forceExternal: true, commit: commit)
|
self?.openUrl(url, concealed: concealed, forceExternal: true, commit: commit)
|
||||||
}, completion: { [weak self] in
|
}, completion: { [weak self] in
|
||||||
@ -10453,7 +10453,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
unarchiveAutomaticallyArchivedPeer(account: strongSelf.context.account, peerId: peerId)
|
unarchiveAutomaticallyArchivedPeer(account: strongSelf.context.account, peerId: peerId)
|
||||||
|
|
||||||
strongSelf.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .succeed(text: strongSelf.presentationData.strings.Conversation_UnarchiveDone), elevatedLayout: false, action: { _ in return false }), in: .current)
|
strongSelf.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .succeed(text: strongSelf.presentationData.strings.Conversation_UnarchiveDone, timeout: nil), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||||
}, scrollToTop: { [weak self] in
|
}, scrollToTop: { [weak self] in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
@ -12937,7 +12937,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
disposable.set((signal
|
disposable.set((signal
|
||||||
|> deliverOnMainQueue).start(completed: { [weak self] in
|
|> deliverOnMainQueue).start(completed: { [weak self] in
|
||||||
if let strongSelf = self, let _ = strongSelf.validLayout {
|
if let strongSelf = self, let _ = strongSelf.validLayout {
|
||||||
strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.ClearCache_Success("\(dataSizeString(selectedSize, formatting: DataSizeStringFormatting(presentationData: presentationData)))", stringForDeviceType()).string), elevatedLayout: false, action: { _ in return false }), in: .current)
|
strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.ClearCache_Success("\(dataSizeString(selectedSize, formatting: DataSizeStringFormatting(presentationData: presentationData)))", stringForDeviceType()).string, timeout: nil), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@ -13185,7 +13185,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botApp.title, url: url, queryId: 0, payload: payload, buttonText: "", keepAliveSignal: nil, fromMenu: false, fromAttachMenu: false, isInline: false, isSimple: false, forceHasSettings: false)
|
let params = WebAppParameters(source: .generic, peerId: peerId, botId: peerId, botName: botApp.title, url: url, queryId: 0, payload: payload, buttonText: "", keepAliveSignal: nil, forceHasSettings: false)
|
||||||
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
||||||
self?.openUrl(url, concealed: concealed, forceExternal: true, commit: commit)
|
self?.openUrl(url, concealed: concealed, forceExternal: true, commit: commit)
|
||||||
}, requestSwitchInline: { [weak self] query, chatTypes, completion in
|
}, requestSwitchInline: { [weak self] query, chatTypes, completion in
|
||||||
@ -13421,14 +13421,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
let content: UndoOverlayContent
|
let content: UndoOverlayContent
|
||||||
if botJustInstalled {
|
if botJustInstalled {
|
||||||
if bot.flags.contains(.showInSettings) {
|
if bot.flags.contains(.showInSettings) {
|
||||||
content = .succeed(text: strongSelf.presentationData.strings.WebApp_ShortcutsSettingsAdded(bot.shortName).string)
|
content = .succeed(text: strongSelf.presentationData.strings.WebApp_ShortcutsSettingsAdded(bot.shortName).string, timeout: 5.0)
|
||||||
} else {
|
} else {
|
||||||
content = .succeed(text: strongSelf.presentationData.strings.WebApp_ShortcutsAdded(bot.shortName).string)
|
content = .succeed(text: strongSelf.presentationData.strings.WebApp_ShortcutsAdded(bot.shortName).string, timeout: 5.0)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
content = .info(title: nil, text: strongSelf.presentationData.strings.WebApp_AddToAttachmentAlreadyAddedError, timeout: nil)
|
content = .info(title: nil, text: strongSelf.presentationData.strings.WebApp_AddToAttachmentAlreadyAddedError, timeout: nil)
|
||||||
}
|
}
|
||||||
strongSelf.present(UndoOverlayController(presentationData: presentationData, content: content, elevatedLayout: false, action: { _ in return false }), in: .current)
|
strongSelf.present(UndoOverlayController(presentationData: presentationData, content: content, elevatedLayout: false, position: .top, action: { _ in return false }), in: .current)
|
||||||
} else {
|
} else {
|
||||||
let _ = (context.engine.messages.getAttachMenuBot(botId: botId)
|
let _ = (context.engine.messages.getAttachMenuBot(botId: botId)
|
||||||
|> deliverOnMainQueue).start(next: { bot in
|
|> deliverOnMainQueue).start(next: { bot in
|
||||||
@ -13584,7 +13584,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
contactsController.navigationPresentation = .modal
|
contactsController.navigationPresentation = .modal
|
||||||
completion(contactsController, contactsController.mediaPickerContext)
|
completion(contactsController, contactsController.mediaPickerContext)
|
||||||
strongSelf.controllerNavigationDisposable.set((contactsController.result
|
strongSelf.controllerNavigationDisposable.set((contactsController.result
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] peers in
|
|> deliverOnMainQueue).start(next: { [weak self] peers in
|
||||||
if let strongSelf = self, let (peers, _, silent, scheduleTime, text) = peers {
|
if let strongSelf = self, let (peers, _, silent, scheduleTime, text) = peers {
|
||||||
var textEnqueueMessage: EnqueueMessage?
|
var textEnqueueMessage: EnqueueMessage?
|
||||||
if let text = text, text.length > 0 {
|
if let text = text, text.length > 0 {
|
||||||
@ -13763,7 +13763,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
payload = botPayload
|
payload = botPayload
|
||||||
fromAttachMenu = false
|
fromAttachMenu = false
|
||||||
}
|
}
|
||||||
let params = WebAppParameters(peerId: peer.id, botId: bot.peer.id, botName: bot.shortName, url: nil, queryId: nil, payload: payload, buttonText: nil, keepAliveSignal: nil, fromMenu: false, fromAttachMenu: fromAttachMenu, isInline: false, isSimple: false, forceHasSettings: false)
|
let params = WebAppParameters(source: fromAttachMenu ? .attachMenu : .generic, peerId: peer.id, botId: bot.peer.id, botName: bot.shortName, url: nil, queryId: nil, payload: payload, buttonText: nil, keepAliveSignal: nil, forceHasSettings: false)
|
||||||
let replyMessageId = strongSelf.presentationInterfaceState.interfaceState.replyMessageId
|
let replyMessageId = strongSelf.presentationInterfaceState.interfaceState.replyMessageId
|
||||||
let controller = WebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, replyToMessageId: replyMessageId, threadId: strongSelf.chatLocation.threadId)
|
let controller = WebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, replyToMessageId: replyMessageId, threadId: strongSelf.chatLocation.threadId)
|
||||||
controller.openUrl = { [weak self] url, concealed, commit in
|
controller.openUrl = { [weak self] url, concealed, commit in
|
||||||
@ -13802,11 +13802,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
Queue.mainQueue().after(0.3) {
|
Queue.mainQueue().after(0.3) {
|
||||||
let content: UndoOverlayContent
|
let content: UndoOverlayContent
|
||||||
if bot.flags.contains(.showInSettings) {
|
if bot.flags.contains(.showInSettings) {
|
||||||
content = .succeed(text: strongSelf.presentationData.strings.WebApp_ShortcutsSettingsAdded(bot.shortName).string)
|
content = .succeed(text: strongSelf.presentationData.strings.WebApp_ShortcutsSettingsAdded(bot.shortName).string, timeout: 5.0)
|
||||||
} else {
|
} else {
|
||||||
content = .succeed(text: strongSelf.presentationData.strings.WebApp_ShortcutsAdded(bot.shortName).string)
|
content = .succeed(text: strongSelf.presentationData.strings.WebApp_ShortcutsAdded(bot.shortName).string, timeout: 5.0)
|
||||||
}
|
}
|
||||||
attachmentController.present(UndoOverlayController(presentationData: presentationData, content: content, elevatedLayout: true, action: { _ in return false }), in: .current)
|
attachmentController.present(UndoOverlayController(presentationData: presentationData, content: content, elevatedLayout: false, position: .top, action: { _ in return false }), in: .current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,8 @@ private final class PeerInfoScreenDisclosureItemNode: PeerInfoScreenItemNode {
|
|||||||
self.iconNode.image = icon
|
self.iconNode.image = icon
|
||||||
iconSize = icon.size
|
iconSize = icon.size
|
||||||
} else if let iconSignal = item.iconSignal {
|
} else if let iconSignal = item.iconSignal {
|
||||||
if previousItem == nil {
|
if previousItem?.text != item.text {
|
||||||
|
self.iconNode.image = nil
|
||||||
self.iconDisposable = (iconSignal
|
self.iconDisposable = (iconSignal
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] icon in
|
|> deliverOnMainQueue).start(next: { [weak self] icon in
|
||||||
if let self {
|
if let self {
|
||||||
|
@ -813,7 +813,7 @@ private func settingsItems(data: PeerInfoScreenData?, context: AccountContext, p
|
|||||||
} else {
|
} else {
|
||||||
iconSignal = .single(UIImage(bundleImageName: "Settings/Menu/Websites")!)
|
iconSignal = .single(UIImage(bundleImageName: "Settings/Menu/Websites")!)
|
||||||
}
|
}
|
||||||
items[.apps]!.append(PeerInfoScreenDisclosureItem(id: appIndex, text: bot.peer.compactDisplayTitle, icon: nil, iconSignal: iconSignal, action: {
|
items[.apps]!.append(PeerInfoScreenDisclosureItem(id: bot.peer.id.id._internalGetInt64Value(), text: bot.peer.compactDisplayTitle, icon: nil, iconSignal: iconSignal, action: {
|
||||||
interaction.openBotApp(bot)
|
interaction.openBotApp(bot)
|
||||||
}))
|
}))
|
||||||
appIndex += 1
|
appIndex += 1
|
||||||
@ -821,7 +821,7 @@ private func settingsItems(data: PeerInfoScreenData?, context: AccountContext, p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items[.apps]!.append(PeerInfoScreenDisclosureItem(id: appIndex, text: presentationData.strings.Settings_MyStories, icon: PresentationResourcesSettings.stories, action: {
|
items[.apps]!.append(PeerInfoScreenDisclosureItem(id: 0, text: presentationData.strings.Settings_MyStories, icon: PresentationResourcesSettings.stories, action: {
|
||||||
interaction.openSettings(.stories)
|
interaction.openSettings(.stories)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@ -4115,6 +4115,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
if let previousSuggestPasswordConfirmation = previousData?.globalSettings?.suggestPasswordConfirmation, previousSuggestPasswordConfirmation != data.globalSettings?.suggestPasswordConfirmation {
|
if let previousSuggestPasswordConfirmation = previousData?.globalSettings?.suggestPasswordConfirmation, previousSuggestPasswordConfirmation != data.globalSettings?.suggestPasswordConfirmation {
|
||||||
infoUpdated = true
|
infoUpdated = true
|
||||||
}
|
}
|
||||||
|
if let previousBots = previousData?.globalSettings?.bots, previousBots.count != (data.globalSettings?.bots ?? []).count {
|
||||||
|
infoUpdated = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if previousCallsPrivate != currentCallsPrivate || (previousVideoCallsAvailable != currentVideoCallsAvailable && currentVideoCallsAvailable != nil) {
|
if previousCallsPrivate != currentCallsPrivate || (previousVideoCallsAvailable != currentVideoCallsAvailable && currentVideoCallsAvailable != nil) {
|
||||||
infoUpdated = true
|
infoUpdated = true
|
||||||
@ -4680,7 +4683,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
guard let self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let params = WebAppParameters(peerId: self.context.account.peerId, botId: bot.peer.id, botName: bot.peer.compactDisplayTitle, url: url, queryId: nil, payload: nil, buttonText: nil, keepAliveSignal: nil, fromMenu: false, fromAttachMenu: false, isInline: false, isSimple: true, forceHasSettings: bot.flags.contains(.hasSettings))
|
let params = WebAppParameters(source: .settings, peerId: self.context.account.peerId, botId: bot.peer.id, botName: bot.peer.compactDisplayTitle, url: url, queryId: nil, payload: nil, buttonText: nil, keepAliveSignal: nil, forceHasSettings: bot.flags.contains(.hasSettings))
|
||||||
let controller = standaloneWebAppController(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, params: params, threadId: nil, openUrl: { [weak self] url, concealed, commit in
|
let controller = standaloneWebAppController(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, params: params, threadId: nil, openUrl: { [weak self] url, concealed, commit in
|
||||||
self?.openUrl(url: url, concealed: concealed, external: false, forceExternal: true, commit: commit)
|
self?.openUrl(url: url, concealed: concealed, external: false, forceExternal: true, commit: commit)
|
||||||
}, requestSwitchInline: { _, _, _ in
|
}, requestSwitchInline: { _, _, _ in
|
||||||
@ -4699,7 +4702,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
text = presentationData.strings.WebApp_ShortcutsAdded(bot.peer.compactDisplayTitle).string
|
text = presentationData.strings.WebApp_ShortcutsAdded(bot.peer.compactDisplayTitle).string
|
||||||
}
|
}
|
||||||
controller.present(
|
controller.present(
|
||||||
UndoOverlayController(presentationData: presentationData, content: .succeed(text: text), elevatedLayout: false, action: { _ in return false }),
|
UndoOverlayController(presentationData: presentationData, content: .succeed(text: text, timeout: 5.0), elevatedLayout: false, position: .top, action: { _ in return false }),
|
||||||
in: .current
|
in: .current
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -11,7 +11,7 @@ public enum UndoOverlayContent {
|
|||||||
case archivedChat(peerId: Int64, title: String, text: String, undo: Bool)
|
case archivedChat(peerId: Int64, title: String, text: String, undo: Bool)
|
||||||
case hidArchive(title: String, text: String, undo: Bool)
|
case hidArchive(title: String, text: String, undo: Bool)
|
||||||
case revealedArchive(title: String, text: String, undo: Bool)
|
case revealedArchive(title: String, text: String, undo: Bool)
|
||||||
case succeed(text: String)
|
case succeed(text: String, timeout: Double?)
|
||||||
case info(title: String?, text: String, timeout: Double?)
|
case info(title: String?, text: String, timeout: Double?)
|
||||||
case emoji(name: String, text: String)
|
case emoji(name: String, text: String)
|
||||||
case swipeToReply(title: String, text: String)
|
case swipeToReply(title: String, text: String)
|
||||||
|
@ -191,7 +191,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
|||||||
if text.contains("](") {
|
if text.contains("](") {
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
}
|
}
|
||||||
case let .succeed(text):
|
case let .succeed(text, timeout):
|
||||||
self.avatarNode = nil
|
self.avatarNode = nil
|
||||||
self.iconNode = nil
|
self.iconNode = nil
|
||||||
self.iconCheckNode = nil
|
self.iconCheckNode = nil
|
||||||
@ -204,7 +204,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
|||||||
self.textNode.attributedText = attributedText
|
self.textNode.attributedText = attributedText
|
||||||
self.textNode.maximumNumberOfLines = 5
|
self.textNode.maximumNumberOfLines = 5
|
||||||
displayUndo = false
|
displayUndo = false
|
||||||
self.originalRemainingSeconds = 3
|
self.originalRemainingSeconds = timeout ?? 3
|
||||||
case let .info(title, text, timeout):
|
case let .info(title, text, timeout):
|
||||||
self.avatarNode = nil
|
self.avatarNode = nil
|
||||||
self.iconNode = nil
|
self.iconNode = nil
|
||||||
|
@ -170,6 +170,24 @@ public class WebAppCancelButtonNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public struct WebAppParameters {
|
public struct WebAppParameters {
|
||||||
|
public enum Source {
|
||||||
|
case generic
|
||||||
|
case menu
|
||||||
|
case attachMenu
|
||||||
|
case inline
|
||||||
|
case simple
|
||||||
|
case settings
|
||||||
|
|
||||||
|
var isSimple: Bool {
|
||||||
|
if [.simple, .inline, .settings].contains(self) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let source: Source
|
||||||
let peerId: PeerId
|
let peerId: PeerId
|
||||||
let botId: PeerId
|
let botId: PeerId
|
||||||
let botName: String
|
let botName: String
|
||||||
@ -178,13 +196,10 @@ public struct WebAppParameters {
|
|||||||
let payload: String?
|
let payload: String?
|
||||||
let buttonText: String?
|
let buttonText: String?
|
||||||
let keepAliveSignal: Signal<Never, KeepWebViewError>?
|
let keepAliveSignal: Signal<Never, KeepWebViewError>?
|
||||||
let fromMenu: Bool
|
|
||||||
let fromAttachMenu: Bool
|
|
||||||
let isInline: Bool
|
|
||||||
let isSimple: Bool
|
|
||||||
let forceHasSettings: Bool
|
let forceHasSettings: Bool
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
|
source: Source,
|
||||||
peerId: PeerId,
|
peerId: PeerId,
|
||||||
botId: PeerId,
|
botId: PeerId,
|
||||||
botName: String,
|
botName: String,
|
||||||
@ -193,12 +208,9 @@ public struct WebAppParameters {
|
|||||||
payload: String?,
|
payload: String?,
|
||||||
buttonText: String?,
|
buttonText: String?,
|
||||||
keepAliveSignal: Signal<Never, KeepWebViewError>?,
|
keepAliveSignal: Signal<Never, KeepWebViewError>?,
|
||||||
fromMenu: Bool,
|
|
||||||
fromAttachMenu: Bool,
|
|
||||||
isInline: Bool,
|
|
||||||
isSimple: Bool,
|
|
||||||
forceHasSettings: Bool
|
forceHasSettings: Bool
|
||||||
) {
|
) {
|
||||||
|
self.source = source
|
||||||
self.peerId = peerId
|
self.peerId = peerId
|
||||||
self.botId = botId
|
self.botId = botId
|
||||||
self.botName = botName
|
self.botName = botName
|
||||||
@ -207,10 +219,6 @@ public struct WebAppParameters {
|
|||||||
self.payload = payload
|
self.payload = payload
|
||||||
self.buttonText = buttonText
|
self.buttonText = buttonText
|
||||||
self.keepAliveSignal = keepAliveSignal
|
self.keepAliveSignal = keepAliveSignal
|
||||||
self.fromMenu = fromMenu
|
|
||||||
self.fromAttachMenu = fromAttachMenu
|
|
||||||
self.isInline = isInline
|
|
||||||
self.isSimple = isSimple
|
|
||||||
self.forceHasSettings = forceHasSettings
|
self.forceHasSettings = forceHasSettings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -393,7 +401,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
if let url = controller.url, !controller.fromMenu {
|
if let url = controller.url, controller.source != .menu {
|
||||||
self.queryId = controller.queryId
|
self.queryId = controller.queryId
|
||||||
if let parsedUrl = URL(string: url) {
|
if let parsedUrl = URL(string: url) {
|
||||||
self.webView?.load(URLRequest(url: parsedUrl))
|
self.webView?.load(URLRequest(url: parsedUrl))
|
||||||
@ -412,7 +420,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let _ = (context.engine.messages.requestWebView(peerId: controller.peerId, botId: controller.botId, url: controller.url, payload: controller.payload, themeParams: generateWebAppThemeParams(presentationData.theme), fromMenu: controller.fromMenu, replyToMessageId: controller.replyToMessageId, threadId: controller.threadId)
|
let _ = (context.engine.messages.requestWebView(peerId: controller.peerId, botId: controller.botId, url: controller.url, payload: controller.payload, themeParams: generateWebAppThemeParams(presentationData.theme), fromMenu: controller.source == .menu, replyToMessageId: controller.replyToMessageId, threadId: controller.threadId)
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] result in
|
|> deliverOnMainQueue).start(next: { [weak self] result in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
@ -707,11 +715,11 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "web_app_data_send":
|
case "web_app_data_send":
|
||||||
if controller.isSimple, let eventData = body["eventData"] as? String {
|
if controller.source.isSimple, let eventData = body["eventData"] as? String {
|
||||||
self.handleSendData(data: eventData)
|
self.handleSendData(data: eventData)
|
||||||
}
|
}
|
||||||
case "web_app_setup_main_button":
|
case "web_app_setup_main_button":
|
||||||
if let webView = self.webView, !webView.didTouchOnce && controller.url == nil && controller.fromAttachMenu {
|
if let webView = self.webView, !webView.didTouchOnce && controller.url == nil && controller.source == .attachMenu {
|
||||||
self.delayedScriptMessage = message
|
self.delayedScriptMessage = message
|
||||||
} else if let json = json {
|
} else if let json = json {
|
||||||
if var isVisible = json["is_visible"] as? Bool {
|
if var isVisible = json["is_visible"] as? Bool {
|
||||||
@ -1301,6 +1309,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
fileprivate let moreButtonNode: MoreButtonNode
|
fileprivate let moreButtonNode: MoreButtonNode
|
||||||
|
|
||||||
private let context: AccountContext
|
private let context: AccountContext
|
||||||
|
private let source: WebAppParameters.Source
|
||||||
private let peerId: PeerId
|
private let peerId: PeerId
|
||||||
private let botId: PeerId
|
private let botId: PeerId
|
||||||
private let botName: String
|
private let botName: String
|
||||||
@ -1308,10 +1317,6 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
private let queryId: Int64?
|
private let queryId: Int64?
|
||||||
private let payload: String?
|
private let payload: String?
|
||||||
private let buttonText: String?
|
private let buttonText: String?
|
||||||
private let fromMenu: Bool
|
|
||||||
private let fromAttachMenu: Bool
|
|
||||||
private let isInline: Bool
|
|
||||||
private let isSimple: Bool
|
|
||||||
private let forceHasSettings: Bool
|
private let forceHasSettings: Bool
|
||||||
private let keepAliveSignal: Signal<Never, KeepWebViewError>?
|
private let keepAliveSignal: Signal<Never, KeepWebViewError>?
|
||||||
private let replyToMessageId: MessageId?
|
private let replyToMessageId: MessageId?
|
||||||
@ -1328,6 +1333,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
|
|
||||||
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, params: WebAppParameters, replyToMessageId: MessageId?, threadId: Int64?) {
|
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, params: WebAppParameters, replyToMessageId: MessageId?, threadId: Int64?) {
|
||||||
self.context = context
|
self.context = context
|
||||||
|
self.source = params.source
|
||||||
self.peerId = params.peerId
|
self.peerId = params.peerId
|
||||||
self.botId = params.botId
|
self.botId = params.botId
|
||||||
self.botName = params.botName
|
self.botName = params.botName
|
||||||
@ -1335,10 +1341,6 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
self.queryId = params.queryId
|
self.queryId = params.queryId
|
||||||
self.payload = params.payload
|
self.payload = params.payload
|
||||||
self.buttonText = params.buttonText
|
self.buttonText = params.buttonText
|
||||||
self.fromMenu = params.fromMenu
|
|
||||||
self.fromAttachMenu = params.fromAttachMenu
|
|
||||||
self.isInline = params.isInline
|
|
||||||
self.isSimple = params.isSimple
|
|
||||||
self.forceHasSettings = params.forceHasSettings
|
self.forceHasSettings = params.forceHasSettings
|
||||||
self.keepAliveSignal = params.keepAliveSignal
|
self.keepAliveSignal = params.keepAliveSignal
|
||||||
self.replyToMessageId = replyToMessageId
|
self.replyToMessageId = replyToMessageId
|
||||||
@ -1454,12 +1456,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
let url = self.url
|
let url = self.url
|
||||||
let forceHasSettings = self.forceHasSettings
|
let forceHasSettings = self.forceHasSettings
|
||||||
|
|
||||||
|
let source = self.source
|
||||||
|
|
||||||
let items = context.engine.messages.attachMenuBots()
|
let items = context.engine.messages.attachMenuBots()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> map { [weak self] attachMenuBots -> ContextController.Items in
|
|> map { [weak self] attachMenuBots -> ContextController.Items in
|
||||||
var items: [ContextMenuItem] = []
|
var items: [ContextMenuItem] = []
|
||||||
|
|
||||||
let attachMenuBot = attachMenuBots.first(where: { $0.peer.id == botId})
|
let attachMenuBot = attachMenuBots.first(where: { $0.peer.id == botId && !$0.flags.contains(.notActivated) })
|
||||||
|
|
||||||
let hasSettings: Bool
|
let hasSettings: Bool
|
||||||
if url == nil {
|
if url == nil {
|
||||||
@ -1517,7 +1521,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
self?.controllerNode.webView?.reload()
|
self?.controllerNode.webView?.reload()
|
||||||
})))
|
})))
|
||||||
|
|
||||||
if let _ = attachMenuBot, self?.url == nil {
|
if let _ = attachMenuBot, [.attachMenu, .settings].contains(source) {
|
||||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.WebApp_RemoveBot, textColor: .destructive, icon: { theme in
|
items.append(.action(ContextMenuActionItem(text: presentationData.strings.WebApp_RemoveBot, textColor: .destructive, icon: { theme in
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.contextMenu.destructiveColor)
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.contextMenu.destructiveColor)
|
||||||
}, action: { [weak self] c, _ in
|
}, action: { [weak self] c, _ in
|
||||||
@ -1672,7 +1676,7 @@ public func standaloneWebAppController(
|
|||||||
didDismiss: @escaping () -> Void = {},
|
didDismiss: @escaping () -> Void = {},
|
||||||
getNavigationController: @escaping () -> NavigationController? = { return nil },
|
getNavigationController: @escaping () -> NavigationController? = { return nil },
|
||||||
getSourceRect: (() -> CGRect?)? = nil) -> ViewController {
|
getSourceRect: (() -> CGRect?)? = nil) -> ViewController {
|
||||||
let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: .peer(id: params.peerId), buttons: [.standalone], initialButton: .standalone, fromMenu: params.fromMenu, hasTextInput: false, makeEntityInputView: {
|
let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: .peer(id: params.peerId), buttons: [.standalone], initialButton: .standalone, fromMenu: params.source == .menu, hasTextInput: false, makeEntityInputView: {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
controller.getInputContainerNode = getInputContainerNode
|
controller.getInputContainerNode = getInputContainerNode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user