mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
Group boosts
This commit is contained in:
parent
2718703ebb
commit
50c186b566
@ -232,6 +232,7 @@ private struct ApplicationSpecificNoticeKeys {
|
|||||||
private static let botGameNoticeNamespace: Int32 = 7
|
private static let botGameNoticeNamespace: Int32 = 7
|
||||||
private static let peerInviteRequestsNamespace: Int32 = 8
|
private static let peerInviteRequestsNamespace: Int32 = 8
|
||||||
private static let dismissedPremiumGiftNamespace: Int32 = 9
|
private static let dismissedPremiumGiftNamespace: Int32 = 9
|
||||||
|
private static let groupEmojiPackNamespace: Int32 = 9
|
||||||
|
|
||||||
static func inlineBotLocationRequestNotice(peerId: PeerId) -> NoticeEntryKey {
|
static func inlineBotLocationRequestNotice(peerId: PeerId) -> NoticeEntryKey {
|
||||||
return NoticeEntryKey(namespace: noticeNamespace(namespace: inlineBotLocationRequestNamespace), key: noticeKey(peerId: peerId, key: 0))
|
return NoticeEntryKey(namespace: noticeNamespace(namespace: inlineBotLocationRequestNamespace), key: noticeKey(peerId: peerId, key: 0))
|
||||||
@ -253,6 +254,10 @@ private struct ApplicationSpecificNoticeKeys {
|
|||||||
return NoticeEntryKey(namespace: noticeNamespace(namespace: dismissedPremiumGiftNamespace), key: noticeKey(peerId: peerId, key: 0))
|
return NoticeEntryKey(namespace: noticeNamespace(namespace: dismissedPremiumGiftNamespace), key: noticeKey(peerId: peerId, key: 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func groupEmojiPackNotice(peerId: PeerId) -> NoticeEntryKey {
|
||||||
|
return NoticeEntryKey(namespace: noticeNamespace(namespace: groupEmojiPackNamespace), key: noticeKey(peerId: peerId, key: 0))
|
||||||
|
}
|
||||||
|
|
||||||
static func forcedPasswordSetup() -> NoticeEntryKey {
|
static func forcedPasswordSetup() -> NoticeEntryKey {
|
||||||
return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.secretChatInlineBotUsage.key)
|
return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.secretChatInlineBotUsage.key)
|
||||||
}
|
}
|
||||||
@ -1582,6 +1587,33 @@ public struct ApplicationSpecificNotice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static func groupEmojiPackSuggestion(accountManager: AccountManager<TelegramAccountManagerTypes>, peerId: PeerId) -> Signal<Int32, NoError> {
|
||||||
|
return accountManager.noticeEntry(key: ApplicationSpecificNoticeKeys.groupEmojiPackNotice(peerId: peerId))
|
||||||
|
|> map { view -> Int32 in
|
||||||
|
if let value = view.value?.get(ApplicationSpecificCounterNotice.self) {
|
||||||
|
return value.value
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func incrementGroupEmojiPackSuggestion(accountManager: AccountManager<TelegramAccountManagerTypes>, peerId: PeerId, count: Int32 = 1) -> Signal<Int32, NoError> {
|
||||||
|
return accountManager.transaction { transaction -> Int32 in
|
||||||
|
var currentValue: Int32 = 0
|
||||||
|
if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.groupEmojiPackNotice(peerId: peerId))?.get(ApplicationSpecificCounterNotice.self) {
|
||||||
|
currentValue = value.value
|
||||||
|
}
|
||||||
|
let previousValue = currentValue
|
||||||
|
currentValue += count
|
||||||
|
|
||||||
|
if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) {
|
||||||
|
transaction.setNotice(ApplicationSpecificNoticeKeys.groupEmojiPackNotice(peerId: peerId), entry)
|
||||||
|
}
|
||||||
|
return previousValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static func getSendWhenOnlineTip(accountManager: AccountManager<TelegramAccountManagerTypes>) -> Signal<Int32, NoError> {
|
public static func getSendWhenOnlineTip(accountManager: AccountManager<TelegramAccountManagerTypes>) -> Signal<Int32, NoError> {
|
||||||
return accountManager.transaction { transaction -> Int32 in
|
return accountManager.transaction { transaction -> Int32 in
|
||||||
if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.sendWhenOnlineTip())?.get(ApplicationSpecificCounterNotice.self) {
|
if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.sendWhenOnlineTip())?.get(ApplicationSpecificCounterNotice.self) {
|
||||||
|
@ -15714,42 +15714,52 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
guard let rect = self.chatDisplayNode.frameForEmojiButton(), self.effectiveNavigationController?.topViewController === self else {
|
guard let rect = self.chatDisplayNode.frameForEmojiButton(), self.effectiveNavigationController?.topViewController === self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let emojiPack = (self.peerView?.cachedData as? CachedChannelData)?.emojiPack, let thumbnailFileId = emojiPack.thumbnailFileId else {
|
guard let peerId = self.chatLocation.peerId, let emojiPack = (self.peerView?.cachedData as? CachedChannelData)?.emojiPack, let thumbnailFileId = emojiPack.thumbnailFileId else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let _ = (self.context.engine.stickers.resolveInlineStickers(fileIds: [thumbnailFileId])
|
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] files in
|
let _ = (ApplicationSpecificNotice.groupEmojiPackSuggestion(accountManager: self.context.sharedContext.accountManager, peerId: peerId)
|
||||||
guard let self, let emojiFile = files.values.first else {
|
|> deliverOnMainQueue).start(next: { [weak self] counter in
|
||||||
|
guard let self, counter == 0 else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let textFont = Font.regular(self.presentationData.listsFontSize.baseDisplaySize * 14.0 / 17.0)
|
let _ = (self.context.engine.stickers.resolveInlineStickers(fileIds: [thumbnailFileId])
|
||||||
let boldTextFont = Font.bold(self.presentationData.listsFontSize.baseDisplaySize * 14.0 / 17.0)
|
|> deliverOnMainQueue).start(next: { [weak self] files in
|
||||||
let textColor = UIColor.white
|
guard let self, let emojiFile = files.values.first else {
|
||||||
let markdownAttributes = MarkdownAttributes(body: MarkdownAttributeSet(font: textFont, textColor: textColor), bold: MarkdownAttributeSet(font: boldTextFont, textColor: textColor), link: MarkdownAttributeSet(font: textFont, textColor: textColor), linkAttribute: { _ in
|
return
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
let text = NSMutableAttributedString(attributedString: parseMarkdownIntoAttributedString(self.presentationData.strings.Chat_GroupEmojiTooltip(emojiPack.title).string, attributes: markdownAttributes))
|
|
||||||
|
|
||||||
let range = (text.string as NSString).range(of: "#")
|
|
||||||
if range.location != NSNotFound {
|
|
||||||
text.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: emojiFile.fileId.id, file: emojiFile), range: range)
|
|
||||||
}
|
|
||||||
|
|
||||||
let tooltipScreen = TooltipScreen(
|
|
||||||
context: self.context,
|
|
||||||
account: self.context.account,
|
|
||||||
sharedContext: self.context.sharedContext,
|
|
||||||
text: .attributedString(text: text),
|
|
||||||
location: .point(rect.offsetBy(dx: 0.0, dy: -3.0), .bottom),
|
|
||||||
displayDuration: .default,
|
|
||||||
cornerRadius: 10.0,
|
|
||||||
shouldDismissOnTouch: { _, _ in
|
|
||||||
return .ignore
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
self.present(tooltipScreen, in: .current)
|
let textFont = Font.regular(self.presentationData.listsFontSize.baseDisplaySize * 14.0 / 17.0)
|
||||||
|
let boldTextFont = Font.bold(self.presentationData.listsFontSize.baseDisplaySize * 14.0 / 17.0)
|
||||||
|
let textColor = UIColor.white
|
||||||
|
let markdownAttributes = MarkdownAttributes(body: MarkdownAttributeSet(font: textFont, textColor: textColor), bold: MarkdownAttributeSet(font: boldTextFont, textColor: textColor), link: MarkdownAttributeSet(font: textFont, textColor: textColor), linkAttribute: { _ in
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
let text = NSMutableAttributedString(attributedString: parseMarkdownIntoAttributedString(self.presentationData.strings.Chat_GroupEmojiTooltip(emojiPack.title).string, attributes: markdownAttributes))
|
||||||
|
|
||||||
|
let range = (text.string as NSString).range(of: "#")
|
||||||
|
if range.location != NSNotFound {
|
||||||
|
text.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: emojiFile.fileId.id, file: emojiFile), range: range)
|
||||||
|
}
|
||||||
|
|
||||||
|
let tooltipScreen = TooltipScreen(
|
||||||
|
context: self.context,
|
||||||
|
account: self.context.account,
|
||||||
|
sharedContext: self.context.sharedContext,
|
||||||
|
text: .attributedString(text: text),
|
||||||
|
location: .point(rect.offsetBy(dx: 0.0, dy: -3.0), .bottom),
|
||||||
|
displayDuration: .default,
|
||||||
|
cornerRadius: 10.0,
|
||||||
|
shouldDismissOnTouch: { _, _ in
|
||||||
|
return .ignore
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.present(tooltipScreen, in: .current)
|
||||||
|
|
||||||
|
let _ = ApplicationSpecificNotice.incrementGroupEmojiPackSuggestion(accountManager: self.context.sharedContext.accountManager, peerId: peerId).startStandalone()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user