mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Group boosts
This commit is contained in:
@@ -11302,3 +11302,5 @@ Sorry for the inconvenience.";
|
|||||||
|
|
||||||
"Channel.AdminLog.MessageChangedGroupEmojiPack" = "%@ changed group emoji pack";
|
"Channel.AdminLog.MessageChangedGroupEmojiPack" = "%@ changed group emoji pack";
|
||||||
"Channel.AdminLog.MessageRemovedGroupEmojiPack" = "%@ removed group emoji pack";
|
"Channel.AdminLog.MessageRemovedGroupEmojiPack" = "%@ removed group emoji pack";
|
||||||
|
|
||||||
|
"Group.Appearance.EmojiPackUpdated" = "Group emoji pack updated.";
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ swift_library(
|
|||||||
"//submodules/SearchBarNode:SearchBarNode",
|
"//submodules/SearchBarNode:SearchBarNode",
|
||||||
"//submodules/SearchUI:SearchUI",
|
"//submodules/SearchUI:SearchUI",
|
||||||
"//submodules/MergeLists:MergeLists",
|
"//submodules/MergeLists:MergeLists",
|
||||||
|
"//submodules/UndoUI:UndoUI",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
|||||||
@@ -344,6 +344,7 @@ class GroupStickerPackCurrentItemNode: ItemListRevealOptionsItemNode {
|
|||||||
|
|
||||||
if case .searching = item.content {
|
if case .searching = item.content {
|
||||||
strongSelf.activityIndicator.isHidden = false
|
strongSelf.activityIndicator.isHidden = false
|
||||||
|
strongSelf.imageNode.isHidden = true
|
||||||
} else {
|
} else {
|
||||||
strongSelf.activityIndicator.isHidden = true
|
strongSelf.activityIndicator.isHidden = true
|
||||||
}
|
}
|
||||||
@@ -351,6 +352,7 @@ class GroupStickerPackCurrentItemNode: ItemListRevealOptionsItemNode {
|
|||||||
if case .found = item.content {
|
if case .found = item.content {
|
||||||
strongSelf.removeButtonIcon.isHidden = false
|
strongSelf.removeButtonIcon.isHidden = false
|
||||||
strongSelf.removeButton.isHidden = false
|
strongSelf.removeButton.isHidden = false
|
||||||
|
strongSelf.imageNode.isHidden = false
|
||||||
} else {
|
} else {
|
||||||
strongSelf.removeButtonIcon.isHidden = true
|
strongSelf.removeButtonIcon.isHidden = true
|
||||||
strongSelf.removeButton.isHidden = true
|
strongSelf.removeButton.isHidden = true
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import PresentationDataUtils
|
|||||||
import AccountContext
|
import AccountContext
|
||||||
import StickerPackPreviewUI
|
import StickerPackPreviewUI
|
||||||
import ItemListStickerPackItem
|
import ItemListStickerPackItem
|
||||||
|
import UndoUI
|
||||||
|
|
||||||
private final class GroupStickerPackSetupControllerArguments {
|
private final class GroupStickerPackSetupControllerArguments {
|
||||||
let context: AccountContext
|
let context: AccountContext
|
||||||
@@ -343,6 +344,20 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres
|
|||||||
initialData.set(.single(.noData))
|
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<CombinedView>()
|
let stickerPacks = Promise<CombinedView>()
|
||||||
stickerPacks.set(context.account.postbox.combinedView(keys: [.itemCollectionInfos(namespaces: [isEmoji ? Namespaces.ItemCollection.CloudEmojiPacks : Namespaces.ItemCollection.CloudStickerPacks])]))
|
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 {
|
if searchText.isEmpty {
|
||||||
return .single((searchText, .none))
|
return .single((searchText, .none))
|
||||||
} else if case let .data(data) = initialData, searchText.lowercased() == data.info.shortName {
|
} 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))))
|
return .single((searchText, .found(StickerPackData(info: data.info, item: data.item))))
|
||||||
} else {
|
} else {
|
||||||
let namespace = isEmoji ? Namespaces.ItemCollection.CloudEmojiPacks : Namespaces.ItemCollection.CloudStickerPacks
|
let namespace = isEmoji ? Namespaces.ItemCollection.CloudEmojiPacks : Namespaces.ItemCollection.CloudStickerPacks
|
||||||
@@ -378,6 +396,13 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres
|
|||||||
case let .result(info, items, _):
|
case let .result(info, items, _):
|
||||||
return .single((searchText, .found(StickerPackData(info: info, item: items.first))))
|
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 {
|
} else {
|
||||||
@@ -385,7 +410,6 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments?) -> Void)?
|
|
||||||
var navigateToChatControllerImpl: ((PeerId) -> Void)?
|
var navigateToChatControllerImpl: ((PeerId) -> Void)?
|
||||||
var dismissInputImpl: (() -> Void)?
|
var dismissInputImpl: (() -> Void)?
|
||||||
var dismissImpl: (() -> Void)?
|
var dismissImpl: (() -> Void)?
|
||||||
@@ -402,15 +426,13 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres
|
|||||||
|
|
||||||
let arguments = GroupStickerPackSetupControllerArguments(context: context, selectStickerPack: { info in
|
let arguments = GroupStickerPackSetupControllerArguments(context: context, selectStickerPack: { info in
|
||||||
searchText.set(info.shortName)
|
searchText.set(info.shortName)
|
||||||
if let completion {
|
completionImpl?(info)
|
||||||
completion(info)
|
|
||||||
}
|
|
||||||
}, openStickerPack: { info in
|
}, openStickerPack: { info in
|
||||||
presentStickerPackController?(info)
|
presentStickerPackController?(info)
|
||||||
}, updateSearchText: { text in
|
}, updateSearchText: { text in
|
||||||
searchText.set(text)
|
searchText.set(text)
|
||||||
if text == "", let completion {
|
if text == "" {
|
||||||
completion(nil)
|
completionImpl?(nil)
|
||||||
}
|
}
|
||||||
}, openStickersBot: {
|
}, openStickersBot: {
|
||||||
resolveDisposable.set((context.engine.peers.resolvePeerByName(name: "stickers")
|
resolveDisposable.set((context.engine.peers.resolvePeerByName(name: "stickers")
|
||||||
@@ -473,29 +495,24 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres
|
|||||||
info = data.info
|
info = data.info
|
||||||
}
|
}
|
||||||
rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Done), style: .bold, enabled: enabled, action: {
|
rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Done), style: .bold, enabled: enabled, action: {
|
||||||
if let completion {
|
if info?.id == currentPackInfo?.id {
|
||||||
completion(info)
|
|
||||||
dismissImpl?()
|
dismissImpl?()
|
||||||
} else {
|
} else {
|
||||||
if info?.id == currentPackInfo?.id {
|
updateState { state in
|
||||||
dismissImpl?()
|
var state = state
|
||||||
} else {
|
state.isSaving = true
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
saveDisposable.set((context.engine.peers.updateGroupSpecificStickerset(peerId: peerId, info: info)
|
||||||
|
|> deliverOnMainQueue).start(error: { _ in
|
||||||
updateState { state in
|
updateState { state in
|
||||||
var state = state
|
var state = state
|
||||||
state.isSaving = true
|
state.isSaving = false
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
saveDisposable.set((context.engine.peers.updateGroupSpecificStickerset(peerId: peerId, info: info)
|
}, completed: {
|
||||||
|> deliverOnMainQueue).start(error: { _ in
|
dismissImpl?()
|
||||||
updateState { state in
|
}))
|
||||||
var state = state
|
|
||||||
state.isSaving = false
|
|
||||||
return state
|
|
||||||
}
|
|
||||||
}, completed: {
|
|
||||||
dismissImpl?()
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -537,6 +554,14 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres
|
|||||||
|
|
||||||
presentControllerImpl = { [weak controller] c, p in
|
presentControllerImpl = { [weak controller] c, p in
|
||||||
if let controller = controller {
|
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)
|
controller.present(c, in: .window(.root), with: p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,6 +291,8 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
|
|
||||||
private var paymentDisposable: Disposable?
|
private var paymentDisposable: Disposable?
|
||||||
|
|
||||||
|
private var lastExpansionTimestamp: Double?
|
||||||
|
|
||||||
private var didTransitionIn = false
|
private var didTransitionIn = false
|
||||||
private var dismissed = false
|
private var dismissed = false
|
||||||
|
|
||||||
@@ -739,7 +741,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
guard let eventName = body["eventName"] as? String else {
|
guard let eventName = body["eventName"] as? String else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
let currentTimestamp = CACurrentMediaTime()
|
||||||
let eventData = (body["eventData"] as? String)?.data(using: .utf8)
|
let eventData = (body["eventData"] as? String)?.data(using: .utf8)
|
||||||
let json = try? JSONSerialization.jsonObject(with: eventData ?? Data(), options: []) as? [String: Any]
|
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":
|
case "web_app_request_theme":
|
||||||
self.sendThemeChangedEvent()
|
self.sendThemeChangedEvent()
|
||||||
case "web_app_expand":
|
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":
|
case "web_app_close":
|
||||||
controller.dismiss()
|
controller.dismiss()
|
||||||
case "web_app_open_tg_link":
|
case "web_app_open_tg_link":
|
||||||
@@ -846,7 +853,6 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
case "web_app_open_link":
|
case "web_app_open_link":
|
||||||
if let json = json, let url = json["url"] as? String {
|
if let json = json, let url = json["url"] as? String {
|
||||||
let tryInstantView = json["try_instant_view"] as? Bool ?? false
|
let tryInstantView = json["try_instant_view"] as? Bool ?? false
|
||||||
let currentTimestamp = CACurrentMediaTime()
|
|
||||||
if let lastTouchTimestamp = self.webView?.lastTouchTimestamp, currentTimestamp < lastTouchTimestamp + 10.0 {
|
if let lastTouchTimestamp = self.webView?.lastTouchTimestamp, currentTimestamp < lastTouchTimestamp + 10.0 {
|
||||||
self.webView?.lastTouchTimestamp = nil
|
self.webView?.lastTouchTimestamp = nil
|
||||||
if tryInstantView {
|
if tryInstantView {
|
||||||
|
|||||||
Reference in New Issue
Block a user