diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 2dbf0e08e9..fda6b2b4a3 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -10119,6 +10119,7 @@ Sorry for the inconvenience."; "Channel.AdminLog.MessageChangedNameColorSet" = "%1$@ set name color to %2$@"; "Channel.AdminLog.MessageChangedBackgroundEmojiSet" = "%1$@ set background emoji to %2$@"; +"Channel.AdminLog.MessageChangedBackgroundEmojiRemoved" = "%1$@ removed background emoji"; "Appearance.NameColor" = "Your Name Color"; @@ -10277,7 +10278,8 @@ Sorry for the inconvenience."; "BoostGift.Channels.Save" = "Save Channels"; "Stats.Boosts.PrepaidGiveawaysTitle" = "PREPAID GIVEAWAYS"; -"Stats.Boosts.PrepaidGiveawayCount_any" = "%@ Telegram Premium"; +"Stats.Boosts.PrepaidGiveawayCount_1" = "%@ Telegram Premium"; +"Stats.Boosts.PrepaidGiveawayCount_any" = "%@ Telegram Premiums"; "Stats.Boosts.PrepaidGiveawayMonths" = "%@-month subscriptions"; "Stats.Boosts.PrepaidGiveawaysInfo" = "Select a giveaway you already paid for to set it up."; "Stats.Boosts.ShortMonth" = "%@m"; @@ -10361,9 +10363,9 @@ Sorry for the inconvenience."; "Chat.Giveaway.Message.PrizeTitle" = "Giveaway Prizes"; "Chat.Giveaway.Message.PrizeText" = "%1$@ for %2$@."; "Chat.Giveaway.Message.Subscriptions_1" = "**%@** Telegram Premium Subscription"; -"Chat.Giveaway.Message.Subscriptions_many" = "**%@** Telegram Premium Subscriptions"; +"Chat.Giveaway.Message.Subscriptions_any" = "**%@** Telegram Premium Subscriptions"; "Chat.Giveaway.Message.Months_1" = "**%@** month"; -"Chat.Giveaway.Message.Months_many" = "**%@** months"; +"Chat.Giveaway.Message.Months_any" = "**%@** months"; "Chat.Giveaway.Message.ParticipantsTitle" = "Participants"; "Chat.Giveaway.Message.ParticipantsNewMany" = "All users who join the channels below after this date:"; "Chat.Giveaway.Message.ParticipantsNew" = "All users who join this channel after this date:"; diff --git a/submodules/PremiumUI/Sources/PremiumGiftCodeScreen.swift b/submodules/PremiumUI/Sources/PremiumGiftCodeScreen.swift index 2483913cea..05735b2d65 100644 --- a/submodules/PremiumUI/Sources/PremiumGiftCodeScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumGiftCodeScreen.swift @@ -76,6 +76,8 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent { var cachedCloseImage: (UIImage, PresentationTheme)? + var inProgress = false + init(context: AccountContext, subject: PremiumGiftCodeScreen.Subject) { self.context = context @@ -426,9 +428,14 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent { iconName: nil, animationName: nil, iconPosition: .left, - action: { + isLoading: state.inProgress, + action: { [weak state] in if gloss { component.action() + if let state { + state.inProgress = true + state.updated() + } } else { component.cancel(true) } @@ -559,6 +566,7 @@ private final class PremiumGiftCodeSheetComponent: CombinedComponent { displayHiddenTooltip: context.component.displayHiddenTooltip )), backgroundColor: .color(environment.theme.actionSheet.opaqueItemBackgroundColor), + followContentSizeChanges: true, animateOut: animateOut ), environment: { @@ -685,6 +693,12 @@ public class PremiumGiftCodeScreen: ViewControllerComponentContainer { self.dismissAllTooltips() } + public func dismissAnimated() { + if let view = self.node.hostView.findTaggedView(tag: SheetComponent.View.Tag()) as? SheetComponent.View { + view.dismissAnimated() + } + } + fileprivate func dismissAllTooltips() { self.window?.forEachController({ controller in if let controller = controller as? UndoOverlayController { diff --git a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift index 7f5efd8006..e09ac732c2 100644 --- a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift @@ -2915,8 +2915,8 @@ public final class PremiumIntroScreen: ViewControllerComponentContainer { } completionImpl = { [weak self] in - if let strongSelf = self { - strongSelf.view.addSubview(ConfettiView(frame: strongSelf.view.bounds)) + if let self { + self.animateSuccess() } } } @@ -2930,6 +2930,10 @@ public final class PremiumIntroScreen: ViewControllerComponentContainer { self.wasDismissed?() } + public func animateSuccess() { + self.view.addSubview(ConfettiView(frame: self.view.bounds)) + } + public override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { super.containerLayoutUpdated(layout, transition: transition) diff --git a/submodules/TelegramCore/Sources/State/ChannelBoost.swift b/submodules/TelegramCore/Sources/State/ChannelBoost.swift index d8f029873a..f1dc466a55 100644 --- a/submodules/TelegramCore/Sources/State/ChannelBoost.swift +++ b/submodules/TelegramCore/Sources/State/ChannelBoost.swift @@ -219,7 +219,7 @@ private final class ChannelBoostersContextImpl { } func loadMore() { - if self.isLoadingMore { + if self.isLoadingMore || !self.canLoadMore { return } self.isLoadingMore = true @@ -312,11 +312,19 @@ private final class ChannelBoostersContextImpl { } strongSelf.isLoadingMore = false strongSelf.hasLoadedOnce = true - strongSelf.canLoadMore = !boosters.isEmpty + strongSelf.canLoadMore = !boosters.isEmpty && nextOffset != nil if strongSelf.canLoadMore { - strongSelf.count = max(updatedCount, Int32(strongSelf.results.count)) + var resultsCount: Int32 = 0 + for result in strongSelf.results { + resultsCount += result.multiplier + } + strongSelf.count = max(updatedCount, resultsCount) } else { - strongSelf.count = Int32(strongSelf.results.count) + var resultsCount: Int32 = 0 + for result in strongSelf.results { + resultsCount += result.multiplier + } + strongSelf.count = resultsCount } strongSelf.updateState() })) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift index 9db5461bc0..924d47c179 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift @@ -348,12 +348,10 @@ func channelAdminLogEvents(accountPeerId: PeerId, postbox: Postbox, network: Net action = .toggleForum(isForum: newValue == .boolTrue) case let .channelAdminLogEventActionToggleAntiSpam(newValue): action = .toggleAntiSpam(isEnabled: newValue == .boolTrue) - default: - action = .toggleInvites(false) -// case let .channelAdminLogEventActionChangeColor(prevValue, newValue): -// action = .changeNameColor(prev: PeerNameColor(rawValue: prevValue), new: PeerNameColor(rawValue: newValue)) -// case let .channelAdminLogEventActionChangeBackgroundEmoji(prevValue, newValue): -// action = .changeBackgroundEmojiId(prev: prevValue, new: newValue) + case let .channelAdminLogEventActionChangeColor(prevValue, newValue): + action = .changeNameColor(prev: PeerNameColor(rawValue: prevValue), new: PeerNameColor(rawValue: newValue)) + case let .channelAdminLogEventActionChangeBackgroundEmoji(prevValue, newValue): + action = .changeBackgroundEmojiId(prev: prevValue, new: newValue) } let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) if let action = action { diff --git a/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsHistoryTransition.swift b/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsHistoryTransition.swift index 5befa727b0..664f73eab7 100644 --- a/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsHistoryTransition.swift +++ b/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsHistoryTransition.swift @@ -1873,7 +1873,9 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { var text: String = "" var entities: [MessageTextEntity] = [] - let rawText = self.presentationData.strings.Channel_AdminLog_MessageChangedNameColorSet(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", "\(updatedValue)") + let _ = updatedValue + + let rawText = self.presentationData.strings.Channel_AdminLog_MessageChangedNameColorSet(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", "●") appendAttributedText(text: rawText, generateEntities: { index in if index == 0, let author = author { @@ -1899,17 +1901,26 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { var text: String = "" var entities: [MessageTextEntity] = [] - let rawText = self.presentationData.strings.Channel_AdminLog_MessageChangedBackgroundEmojiSet(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", "\(updatedValue ?? 0)") - - appendAttributedText(text: rawText, generateEntities: { index in - if index == 0, let author = author { - return [.TextMention(peerId: author.id)] - } else if index == 1 { - return [.Bold] - } - return [] - }, to: &text, entities: &entities) - + if let updatedValue, updatedValue != 0 { + appendAttributedText(text: self.presentationData.strings.Channel_AdminLog_MessageChangedBackgroundEmojiSet(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", "."), generateEntities: { index in + if index == 0, let author = author { + return [.TextMention(peerId: author.id)] + } else if index == 1 { + return [.CustomEmoji(stickerPack: nil, fileId: updatedValue)] + } + return [] + }, to: &text, entities: &entities) + } else { + let rawText = self.presentationData.strings.Channel_AdminLog_MessageChangedBackgroundEmojiRemoved(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "") + + appendAttributedText(text: rawText, generateEntities: { index in + if index == 0, let author = author { + return [.TextMention(peerId: author.id)] + } + return [] + }, to: &text, entities: &entities) + } + let action = TelegramMediaActionType.customText(text: text, entities: entities) let message = Message(stableId: self.entry.stableId, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: Int32(bitPattern: self.entry.stableId)), globallyUniqueId: self.entry.event.id, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: self.entry.event.date, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: author, text: "", attributes: [], media: [TelegramMediaAction(action: action)], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]) diff --git a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift index f87ae12873..cb9ddd4ba5 100644 --- a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift +++ b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift @@ -891,17 +891,26 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur forceDark = true } let _ = (context.engine.payments.checkPremiumGiftCode(slug: slug) - |> deliverOnMainQueue).startStandalone(next: { giftCode in + |> deliverOnMainQueue).startStandalone(next: { [weak navigationController] giftCode in if let giftCode { var dismissImpl: (() -> Void)? let controller = PremiumGiftCodeScreen( context: context, subject: .giftCode(giftCode), forceDark: forceDark, - action: { - dismissImpl?() - - let _ = context.engine.payments.applyPremiumGiftCode(slug: slug).startStandalone() + action: { [weak navigationController] in + let _ = (context.engine.payments.applyPremiumGiftCode(slug: slug) + |> deliverOnMainQueue).startStandalone(completed: { + dismissImpl?() + + let controller = context.sharedContext.makePremiumIntroController(context: context, source: .settings, forceDark: forceDark, dismissed: nil) + navigationController?.pushViewController(controller) + if let controller = controller as? PremiumIntroScreen { + Queue.mainQueue().after(0.3, { + controller.animateSuccess() + }) + } + }) }, openPeer: { peer in if peer.id != context.account.peerId { @@ -941,7 +950,7 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur } ) dismissImpl = { [weak controller] in - controller?.dismiss() + controller?.dismissAnimated() } navigationController?.pushViewController(controller) } else {