From cd7c9ea73c91cbb30b21922b19d53018d918a9d2 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 9 Feb 2024 13:12:17 +0400 Subject: [PATCH] Group boosts --- .../Sources/PremiumBoostLevelsScreen.swift | 23 ++++++++++--------- .../Sources/ChannelAppearanceScreen.swift | 12 +++++----- .../TelegramUI/Sources/ChatController.swift | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift b/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift index 0f6d306bbf..0a4a5c9396 100644 --- a/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift @@ -601,6 +601,8 @@ private final class SheetContent: CombinedComponent { var needsSecondParagraph = true if let subject { + let requiredLevel = subject.requiredLevel(group: isGroup, context: context.component.context, configuration: premiumConfiguration) + let storiesString = strings.ChannelBoost_StoriesPerDay(Int32(level) + 1) let valueString = strings.ChannelBoost_MoreBoosts(Int32(remaining)) switch subject { @@ -615,24 +617,23 @@ private final class SheetContent: CombinedComponent { textString = strings.ChannelBoost_CustomReactionsText("\(reactionCount)", "\(reactionCount)").string needsSecondParagraph = false case .nameColors: - let colorLevel = subject.requiredLevel(group: isGroup, context: context.component.context, configuration: premiumConfiguration) - textString = strings.ChannelBoost_EnableNameColorLevelText("\(colorLevel)").string + textString = strings.ChannelBoost_EnableNameColorLevelText("\(requiredLevel)").string case .nameIcon: - textString = strings.ChannelBoost_EnableNameIconLevelText("\(premiumConfiguration.minChannelNameIconLevel)").string + textString = strings.ChannelBoost_EnableNameIconLevelText("\(requiredLevel)").string case .profileColors: - textString = isGroup ? strings.GroupBoost_EnableProfileColorLevelText("\(premiumConfiguration.minChannelProfileColorLevel)").string : strings.ChannelBoost_EnableProfileColorLevelText("\(premiumConfiguration.minChannelProfileColorLevel)").string + textString = isGroup ? strings.GroupBoost_EnableProfileColorLevelText("\(requiredLevel)").string : strings.ChannelBoost_EnableProfileColorLevelText("\(requiredLevel)").string case .profileIcon: - textString = isGroup ? strings.GroupBoost_EnableProfileIconLevelText("\(premiumConfiguration.minChannelProfileIconLevel)").string : strings.ChannelBoost_EnableProfileIconLevelText("\(premiumConfiguration.minChannelProfileIconLevel)").string + textString = isGroup ? strings.GroupBoost_EnableProfileIconLevelText("\(requiredLevel)").string : strings.ChannelBoost_EnableProfileIconLevelText("\(premiumConfiguration.minChannelProfileIconLevel)").string case .emojiStatus: - textString = isGroup ? strings.GroupBoost_EnableEmojiStatusLevelText("\(premiumConfiguration.minChannelEmojiStatusLevel)").string : strings.ChannelBoost_EnableEmojiStatusLevelText("\(premiumConfiguration.minChannelEmojiStatusLevel)").string + textString = isGroup ? strings.GroupBoost_EnableEmojiStatusLevelText("\(requiredLevel)").string : strings.ChannelBoost_EnableEmojiStatusLevelText("\(requiredLevel)").string case .wallpaper: - textString = isGroup ? strings.GroupBoost_EnableWallpaperLevelText("\(premiumConfiguration.minChannelWallpaperLevel)").string : strings.ChannelBoost_EnableWallpaperLevelText("\(premiumConfiguration.minChannelWallpaperLevel)").string + textString = isGroup ? strings.GroupBoost_EnableWallpaperLevelText("\(requiredLevel)").string : strings.ChannelBoost_EnableWallpaperLevelText("\(requiredLevel)").string case .customWallpaper: - textString = isGroup ? strings.GroupBoost_EnableCustomWallpaperLevelText("\(premiumConfiguration.minChannelCustomWallpaperLevel)").string : strings.ChannelBoost_EnableCustomWallpaperLevelText("\(premiumConfiguration.minChannelCustomWallpaperLevel)").string + textString = isGroup ? strings.GroupBoost_EnableCustomWallpaperLevelText("\(requiredLevel)").string : strings.ChannelBoost_EnableCustomWallpaperLevelText("\(requiredLevel)").string case .audioTranscription: textString = "" case .emojiPack: - textString = strings.GroupBoost_EnableEmojiPackLevelText("\(premiumConfiguration.minGroupEmojiPackLevel)").string + textString = strings.GroupBoost_EnableEmojiPackLevelText("\(requiredLevel)").string } } else { let boostsString = strings.ChannelBoost_MoreBoostsNeeded_Boosts(Int32(remaining)) @@ -2296,7 +2297,7 @@ public class PremiumBoostLevelsScreen: ViewController { sharedContext: context.sharedContext, updatedPresentationData: nil, title: presentationData.strings.ChannelBoost_Error_BoostTooOftenTitle, - text: presentationData.strings.ChannelBoost_Error_BoostTooOftenText(valueText).string, + text: self.containerExternalState.isGroup ? presentationData.strings.GroupBoost_Error_BoostTooOftenText(valueText).string : presentationData.strings.ChannelBoost_Error_BoostTooOftenText(valueText).string, actions: [ TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {}) ], @@ -2375,7 +2376,7 @@ public class PremiumBoostLevelsScreen: ViewController { sharedContext: context.sharedContext, updatedPresentationData: nil, title: presentationData.strings.ChannelBoost_Error_PremiumNeededTitle, - text: presentationData.strings.ChannelBoost_Error_PremiumNeededText, + text: self.containerExternalState.isGroup ? presentationData.strings.GroupBoost_Error_PremiumNeededText : presentationData.strings.ChannelBoost_Error_PremiumNeededText, actions: [ TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Yes, action: { [weak controller] in diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift index 54b8809c26..95a9e20f45 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift @@ -941,8 +941,12 @@ final class ChannelAppearanceScreenComponent: Component { return availableSize } - var requiredBoostSubjects: [BoostSubject] = [.nameColors(colors: resolvedState.nameColor)] - + let isGroup = self.isGroup + + var requiredBoostSubjects: [BoostSubject] = [] + if !isGroup { + requiredBoostSubjects.append(.nameColors(colors: resolvedState.nameColor)) + } let replyFileId = resolvedState.replyFileId if replyFileId != nil { requiredBoostSubjects.append(.nameIcon) @@ -1025,7 +1029,6 @@ final class ChannelAppearanceScreenComponent: Component { } } - var isGroup = false if case let .user(user) = peer { peer = .user(user .withUpdatedNameColor(resolvedState.nameColor) @@ -1042,9 +1045,6 @@ final class ChannelAppearanceScreenComponent: Component { .withUpdatedBackgroundEmojiId(replyFileId) .withUpdatedProfileBackgroundEmojiId(backgroundFileId) ) - if case .group = channel.info { - isGroup = true - } } let replyIconLevel = Int(BoostSubject.nameIcon.requiredLevel(group: isGroup, context: component.context, configuration: premiumConfiguration)) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 9edd072f24..7bd7a07d20 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -9598,7 +9598,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } } - if let boostsToUnrestrict = (strongSelf.peerView?.cachedData as? CachedChannelData)?.boostsToUnrestrict, boostsToUnrestrict > 0, bannedPermission == nil { + if let boostsToUnrestrict = (strongSelf.peerView?.cachedData as? CachedChannelData)?.boostsToUnrestrict, boostsToUnrestrict > 0, let bannedPermission, !bannedPermission.1 { strongSelf.interfaceInteraction?.openBoostToUnrestrict() return }