diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 2bf37b09be..1077520e62 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -11302,3 +11302,5 @@ Sorry for the inconvenience."; "Channel.AdminLog.MessageChangedGroupEmojiPack" = "%@ changed group emoji pack"; "Channel.AdminLog.MessageRemovedGroupEmojiPack" = "%@ removed group emoji pack"; + +"Group.Appearance.EmojiPackUpdated" = "Group emoji pack updated."; diff --git a/submodules/TelegramUI/Components/GroupStickerPackSetupController/BUILD b/submodules/TelegramUI/Components/GroupStickerPackSetupController/BUILD index 8122488eeb..8b9993c933 100644 --- a/submodules/TelegramUI/Components/GroupStickerPackSetupController/BUILD +++ b/submodules/TelegramUI/Components/GroupStickerPackSetupController/BUILD @@ -23,6 +23,7 @@ swift_library( "//submodules/SearchBarNode:SearchBarNode", "//submodules/SearchUI:SearchUI", "//submodules/MergeLists:MergeLists", + "//submodules/UndoUI:UndoUI", ], visibility = [ "//visibility:public", diff --git a/submodules/TelegramUI/Components/GroupStickerPackSetupController/Sources/GroupStickerPackCurrentItem.swift b/submodules/TelegramUI/Components/GroupStickerPackSetupController/Sources/GroupStickerPackCurrentItem.swift index d85f62ab60..cc3e992b8c 100644 --- a/submodules/TelegramUI/Components/GroupStickerPackSetupController/Sources/GroupStickerPackCurrentItem.swift +++ b/submodules/TelegramUI/Components/GroupStickerPackSetupController/Sources/GroupStickerPackCurrentItem.swift @@ -344,6 +344,7 @@ class GroupStickerPackCurrentItemNode: ItemListRevealOptionsItemNode { if case .searching = item.content { strongSelf.activityIndicator.isHidden = false + strongSelf.imageNode.isHidden = true } else { strongSelf.activityIndicator.isHidden = true } @@ -351,6 +352,7 @@ class GroupStickerPackCurrentItemNode: ItemListRevealOptionsItemNode { if case .found = item.content { strongSelf.removeButtonIcon.isHidden = false strongSelf.removeButton.isHidden = false + strongSelf.imageNode.isHidden = false } else { strongSelf.removeButtonIcon.isHidden = true strongSelf.removeButton.isHidden = true diff --git a/submodules/TelegramUI/Components/GroupStickerPackSetupController/Sources/GroupStickerPackSetupController.swift b/submodules/TelegramUI/Components/GroupStickerPackSetupController/Sources/GroupStickerPackSetupController.swift index 7a925433d1..3c0dd74cdc 100644 --- a/submodules/TelegramUI/Components/GroupStickerPackSetupController/Sources/GroupStickerPackSetupController.swift +++ b/submodules/TelegramUI/Components/GroupStickerPackSetupController/Sources/GroupStickerPackSetupController.swift @@ -11,6 +11,7 @@ import PresentationDataUtils import AccountContext import StickerPackPreviewUI import ItemListStickerPackItem +import UndoUI private final class GroupStickerPackSetupControllerArguments { let context: AccountContext @@ -343,6 +344,20 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres initialData.set(.single(.noData)) } + var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments?) -> Void)? + + var completionImpl: ((StickerPackCollectionInfo?) -> Void)? + if let completion { + completionImpl = { value in + completion(value) + if let _ = value { + let presentationData = context.sharedContext.currentPresentationData.with { $0 } + let controller = UndoOverlayController(presentationData: presentationData, content: .actionSucceeded(title: nil, text: presentationData.strings.Group_Appearance_EmojiPackUpdated, cancel: nil, destructive: false), elevatedLayout: false, action: { _ in return true }) + presentControllerImpl?(controller, nil) + } + } + } + let stickerPacks = Promise() stickerPacks.set(context.account.postbox.combinedView(keys: [.itemCollectionInfos(namespaces: [isEmoji ? Namespaces.ItemCollection.CloudEmojiPacks : Namespaces.ItemCollection.CloudStickerPacks])])) @@ -353,6 +368,9 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres if searchText.isEmpty { return .single((searchText, .none)) } else if case let .data(data) = initialData, searchText.lowercased() == data.info.shortName { + Queue.mainQueue().async { + completionImpl?(data.info) + } return .single((searchText, .found(StickerPackData(info: data.info, item: data.item)))) } else { let namespace = isEmoji ? Namespaces.ItemCollection.CloudEmojiPacks : Namespaces.ItemCollection.CloudStickerPacks @@ -378,6 +396,13 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres case let .result(info, items, _): return .single((searchText, .found(StickerPackData(info: info, item: items.first)))) } + } + |> afterNext { value in + if case let .found(data) = value.1 { + Queue.mainQueue().async { + completionImpl?(data.info) + } + } }) } } else { @@ -385,7 +410,6 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres } }) - var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments?) -> Void)? var navigateToChatControllerImpl: ((PeerId) -> Void)? var dismissInputImpl: (() -> Void)? var dismissImpl: (() -> Void)? @@ -402,15 +426,13 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres let arguments = GroupStickerPackSetupControllerArguments(context: context, selectStickerPack: { info in searchText.set(info.shortName) - if let completion { - completion(info) - } + completionImpl?(info) }, openStickerPack: { info in presentStickerPackController?(info) }, updateSearchText: { text in searchText.set(text) - if text == "", let completion { - completion(nil) + if text == "" { + completionImpl?(nil) } }, openStickersBot: { resolveDisposable.set((context.engine.peers.resolvePeerByName(name: "stickers") @@ -473,29 +495,24 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres info = data.info } rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Done), style: .bold, enabled: enabled, action: { - if let completion { - completion(info) + if info?.id == currentPackInfo?.id { dismissImpl?() } else { - if info?.id == currentPackInfo?.id { - dismissImpl?() - } else { + updateState { state in + var state = state + state.isSaving = true + return state + } + saveDisposable.set((context.engine.peers.updateGroupSpecificStickerset(peerId: peerId, info: info) + |> deliverOnMainQueue).start(error: { _ in updateState { state in var state = state - state.isSaving = true + state.isSaving = false return state } - saveDisposable.set((context.engine.peers.updateGroupSpecificStickerset(peerId: peerId, info: info) - |> deliverOnMainQueue).start(error: { _ in - updateState { state in - var state = state - state.isSaving = false - return state - } - }, completed: { - dismissImpl?() - })) - } + }, completed: { + dismissImpl?() + })) } }) } @@ -537,6 +554,14 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres presentControllerImpl = { [weak controller] c, p in if let controller = controller { + if c is UndoOverlayController { + controller.window?.forEachController { c in + if let controller = c as? UndoOverlayController { + controller.dismiss() + } + } + } + controller.present(c, in: .window(.root), with: p) } } diff --git a/submodules/WebUI/Sources/WebAppController.swift b/submodules/WebUI/Sources/WebAppController.swift index d3f5cc434d..642b3d682d 100644 --- a/submodules/WebUI/Sources/WebAppController.swift +++ b/submodules/WebUI/Sources/WebAppController.swift @@ -291,6 +291,8 @@ public final class WebAppController: ViewController, AttachmentContainable { private var paymentDisposable: Disposable? + private var lastExpansionTimestamp: Double? + private var didTransitionIn = false private var dismissed = false @@ -739,7 +741,7 @@ public final class WebAppController: ViewController, AttachmentContainable { guard let eventName = body["eventName"] as? String else { return } - + let currentTimestamp = CACurrentMediaTime() let eventData = (body["eventData"] as? String)?.data(using: .utf8) let json = try? JSONSerialization.jsonObject(with: eventData ?? Data(), options: []) as? [String: Any] @@ -804,7 +806,12 @@ public final class WebAppController: ViewController, AttachmentContainable { case "web_app_request_theme": self.sendThemeChangedEvent() case "web_app_expand": - controller.requestAttachmentMenuExpansion() + if let lastExpansionTimestamp = self.lastExpansionTimestamp, currentTimestamp < lastExpansionTimestamp + 1.0 { + + } else { + self.lastExpansionTimestamp = currentTimestamp + controller.requestAttachmentMenuExpansion() + } case "web_app_close": controller.dismiss() case "web_app_open_tg_link": @@ -846,7 +853,6 @@ public final class WebAppController: ViewController, AttachmentContainable { case "web_app_open_link": if let json = json, let url = json["url"] as? String { let tryInstantView = json["try_instant_view"] as? Bool ?? false - let currentTimestamp = CACurrentMediaTime() if let lastTouchTimestamp = self.webView?.lastTouchTimestamp, currentTimestamp < lastTouchTimestamp + 10.0 { self.webView?.lastTouchTimestamp = nil if tryInstantView {