Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
overtake committed Mar 20, 2024
2 parents a09ea6e + 81b264f commit d0ab7fa
Show file tree
Hide file tree
Showing 383 changed files with 18,224 additions and 2,410 deletions.
43 changes: 37 additions & 6 deletions Telegram-Mac/AccountContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import InAppPurchaseManager
import ApiCredentials

let clown: String = "🤡"
let tagsGloballyEnabled = true



public struct PremiumConfiguration {
Expand All @@ -41,7 +41,13 @@ public struct PremiumConfiguration {
minChannelProfileIconLevel: 7,
minChannelEmojiStatusLevel: 8,
minChannelWallpaperLevel: 9,
minChannelCustomWallpaperLevel: 10
minChannelCustomWallpaperLevel: 10,
minGroupProfileIconLevel: 7,
minGroupEmojiStatusLevel: 8,
minGroupWallpaperLevel: 9,
minGroupCustomWallpaperLevel: 9,
minGroupEmojiPackLevel: 9,
minGroupAudioTranscriptionLevel: 9
)
}

Expand All @@ -60,6 +66,13 @@ public struct PremiumConfiguration {
public let minChannelWallpaperLevel: Int32
public let minChannelCustomWallpaperLevel: Int32

public let minGroupProfileIconLevel: Int32
public let minGroupEmojiStatusLevel: Int32
public let minGroupWallpaperLevel: Int32
public let minGroupCustomWallpaperLevel: Int32
public let minGroupEmojiPackLevel: Int32
public let minGroupAudioTranscriptionLevel: Int32

fileprivate init(
isPremiumDisabled: Bool,
showPremiumGiftInAttachMenu: Bool,
Expand All @@ -74,8 +87,13 @@ public struct PremiumConfiguration {
minChannelProfileIconLevel: Int32,
minChannelEmojiStatusLevel: Int32,
minChannelWallpaperLevel: Int32,
minChannelCustomWallpaperLevel: Int32

minChannelCustomWallpaperLevel: Int32,
minGroupProfileIconLevel: Int32,
minGroupEmojiStatusLevel: Int32,
minGroupWallpaperLevel: Int32,
minGroupCustomWallpaperLevel: Int32,
minGroupEmojiPackLevel: Int32,
minGroupAudioTranscriptionLevel: Int32
) {
self.isPremiumDisabled = isPremiumDisabled
self.showPremiumGiftInAttachMenu = showPremiumGiftInAttachMenu
Expand All @@ -91,6 +109,12 @@ public struct PremiumConfiguration {
self.minChannelEmojiStatusLevel = minChannelEmojiStatusLevel
self.minChannelWallpaperLevel = minChannelWallpaperLevel
self.minChannelCustomWallpaperLevel = minChannelCustomWallpaperLevel
self.minGroupProfileIconLevel = minGroupProfileIconLevel
self.minGroupEmojiStatusLevel = minGroupEmojiStatusLevel
self.minGroupWallpaperLevel = minGroupWallpaperLevel
self.minGroupCustomWallpaperLevel = minGroupCustomWallpaperLevel
self.minGroupEmojiPackLevel = minGroupEmojiPackLevel
self.minGroupAudioTranscriptionLevel = minGroupAudioTranscriptionLevel
}

public static func with(appConfiguration: AppConfiguration) -> PremiumConfiguration {
Expand All @@ -113,7 +137,13 @@ public struct PremiumConfiguration {
minChannelProfileIconLevel: get(data["channel_profile_bg_icon_level_min"]) ?? defaultValue.minChannelProfileIconLevel,
minChannelEmojiStatusLevel: get(data["channel_emoji_status_level_min"]) ?? defaultValue.minChannelEmojiStatusLevel,
minChannelWallpaperLevel: get(data["channel_wallpaper_level_min"]) ?? defaultValue.minChannelWallpaperLevel,
minChannelCustomWallpaperLevel: get(data["channel_custom_wallpaper_level_min"]) ?? defaultValue.minChannelCustomWallpaperLevel
minChannelCustomWallpaperLevel: get(data["channel_custom_wallpaper_level_min"]) ?? defaultValue.minChannelCustomWallpaperLevel,
minGroupProfileIconLevel: get(data["group_profile_bg_icon_level_min "]) ?? defaultValue.minGroupProfileIconLevel,
minGroupEmojiStatusLevel: get(data["group_emoji_status_level_min"]) ?? defaultValue.minGroupEmojiStatusLevel,
minGroupWallpaperLevel: get(data["group_wallpaper_level_min"]) ?? defaultValue.minGroupWallpaperLevel,
minGroupCustomWallpaperLevel: get(data["group_custom_wallpaper_level_min"]) ?? defaultValue.minGroupCustomWallpaperLevel,
minGroupEmojiPackLevel: get(data["group_emoji_stickers_level_min"]) ?? defaultValue.minGroupEmojiPackLevel,
minGroupAudioTranscriptionLevel: get(data["group_transcribe_level_min"]) ?? defaultValue.minGroupAudioTranscriptionLevel
)
} else {
return defaultValue
Expand All @@ -124,6 +154,7 @@ public struct PremiumConfiguration {




extension AppConfiguration {
func getGeneralValue(_ key: String, orElse defaultValue: Int32) -> Int32 {
if let value = self.data?[key] as? Double {
Expand Down Expand Up @@ -462,7 +493,7 @@ final class AccountContext {
if let _peerNameColors = _peerNameColors {
return _peerNameColors
}
return .init(colors: [:], darkColors: [:], displayOrder: [], profileColors: [:], profileDarkColors: [:], profilePaletteColors: [:], profilePaletteDarkColors: [:], profileStoryColors: [:], profileStoryDarkColors: [:], profileDisplayOrder: [], nameColorsChannelMinRequiredBoostLevel: [:])
return .init(colors: [:], darkColors: [:], displayOrder: [], profileColors: [:], profileDarkColors: [:], profilePaletteColors: [:], profilePaletteDarkColors: [:], profileStoryColors: [:], profileStoryDarkColors: [:], profileDisplayOrder: [], nameColorsChannelMinRequiredBoostLevel: [:], nameColorsGroupMinRequiredBoostLevel: [:])
}


Expand Down
42 changes: 32 additions & 10 deletions Telegram-Mac/AccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ fileprivate final class AccountInfoArguments {
let openFaq:()->Void
let ask:()->Void
let openUpdateApp:() -> Void
let openPremium:()->Void
let openPremium:(Bool)->Void
let giftPremium:()->Void
let addAccount:([AccountWithInfo])->Void
let setStatus:(Control, TelegramUser)->Void
let runStatusPopover:()->Void
let set2Fa:(TwoStepVeriticationAccessConfiguration?)->Void
let openStory:(StoryInitialIndex?)->Void
let openWebBot:(AttachMenuBot)->Void
init(context: AccountContext, storyList: PeerStoryListContext, presentController:@escaping(ViewController, Bool)->Void, openFaq: @escaping()->Void, ask:@escaping()->Void, openUpdateApp: @escaping() -> Void, openPremium:@escaping()->Void, giftPremium:@escaping()->Void, addAccount:@escaping([AccountWithInfo])->Void, setStatus:@escaping(Control, TelegramUser)->Void, runStatusPopover:@escaping()->Void, set2Fa:@escaping(TwoStepVeriticationAccessConfiguration?)->Void, openStory:@escaping(StoryInitialIndex?)->Void, openWebBot:@escaping(AttachMenuBot)->Void) {
init(context: AccountContext, storyList: PeerStoryListContext, presentController:@escaping(ViewController, Bool)->Void, openFaq: @escaping()->Void, ask:@escaping()->Void, openUpdateApp: @escaping() -> Void, openPremium:@escaping(Bool)->Void, giftPremium:@escaping()->Void, addAccount:@escaping([AccountWithInfo])->Void, setStatus:@escaping(Control, TelegramUser)->Void, runStatusPopover:@escaping()->Void, set2Fa:@escaping(TwoStepVeriticationAccessConfiguration?)->Void, openStory:@escaping(StoryInitialIndex?)->Void, openWebBot:@escaping(AttachMenuBot)->Void) {
self.context = context
self.storyList = storyList
self.presentController = presentController
Expand Down Expand Up @@ -141,6 +141,7 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
case update(index: Int, viewType: GeneralViewType, state: AnyUpdateStateEquatable)
case filters(index: Int, viewType: GeneralViewType)
case premium(index: Int, viewType: GeneralViewType)
case business(index: Int, viewType: GeneralViewType)
case giftPremium(index: Int, viewType: GeneralViewType)
case about(index: Int, viewType: GeneralViewType)
case faq(index: Int, viewType: GeneralViewType)
Expand Down Expand Up @@ -190,16 +191,18 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
return .index(17)
case .premium:
return .index(18)
case .giftPremium:
case .business:
return .index(19)
case .faq:
case .giftPremium:
return .index(20)
case .ask:
case .faq:
return .index(21)
case .about:
case .ask:
return .index(22)
case .about:
return .index(23)
case let .attach(index, _, _):
return .index(23 + index)
return .index(24 + index)
case let .whiteSpace(index, _):
return .index(1000 + index)
}
Expand Down Expand Up @@ -249,6 +252,8 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
return index
case let .premium(index, _):
return index
case let .business(index, _):
return index
case let .giftPremium(index, _):
return index
case let .faq(index, _):
Expand Down Expand Up @@ -397,7 +402,11 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
}, border:[BorderType.Right], inset:NSEdgeInsets(left: 12, right: 12))
case let .premium(_, viewType):
return GeneralInteractedRowItem(initialSize, stableId: stableId, name: strings().accountSettingsPremium, icon: theme.icons.settingsPremium, activeIcon: theme.icons.settingsPremium, type: .next, viewType: viewType, action: {
arguments.openPremium()
arguments.openPremium(false)
}, border:[BorderType.Right], inset:NSEdgeInsets(left: 12, right: 12))
case let .business(_, viewType):
return GeneralInteractedRowItem(initialSize, stableId: stableId, name: strings().accountSettingsTelegramBusiness, icon: theme.icons.settingsBusiness, activeIcon: theme.icons.settingsBusinessActive, type: .next, viewType: viewType, action: {
arguments.openPremium(true)
}, border:[BorderType.Right], inset:NSEdgeInsets(left: 12, right: 12))
case let .giftPremium(_, viewType):
return GeneralInteractedRowItem(initialSize, stableId: stableId, name: strings().accountSettingsGiftPremium, icon: theme.icons.settingsGiftPremium, activeIcon: theme.icons.settingsGiftPremium, type: .next, viewType: viewType, action: arguments.giftPremium, border:[BorderType.Right], inset:NSEdgeInsets(left: 12, right: 12))
Expand Down Expand Up @@ -607,6 +616,8 @@ private func accountInfoEntries(peerView:PeerView, context: AccountContext, acco
if !context.premiumIsBlocked {
entries.append(.premium(index: index, viewType: .singleItem))
index += 1
entries.append(.business(index: index, viewType: .singleItem))
index += 1

entries.append(.giftPremium(index: index, viewType: .singleItem))
index += 1
Expand Down Expand Up @@ -863,8 +874,15 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
#if !APP_STORE
navigation.push(AppUpdateViewController(), false)
#endif
}, openPremium: {
showModal(with: PremiumBoardingController(context: context), for: context.window)
}, openPremium: { [weak self] business in
guard let navigation = self?.navigation as? MajorNavigationController else {return}
if business, context.isPremium {
if !(navigation.controller is PremiumBoardingController) {
navigation.push(PremiumBoardingController(context: context, source: .business_standalone), false)
}
} else {
showModal(with: PremiumBoardingController(context: context, source: business ? .business : .settings), for: context.window)
}
}, giftPremium: {

let behaviour = SelectContactsBehavior.init(settings: [.contacts, .remote, .excludeBots], excludePeerIds: [], limit: 10)
Expand Down Expand Up @@ -1027,6 +1045,10 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
if let item = tableView.item(stableId: AccountInfoEntryId.index(Int(17))) {
_ = tableView.select(item: item)
}
} else if let controller = navigation.controller as? PremiumBoardingController {
if let item = tableView.item(stableId: AnyHashable(AccountInfoEntryId.index(19))) {
_ = tableView.select(item: item)
}
} else if let controller = navigation.controller as? InputDataController {
switch true {
case controller.identifier == "proxy":
Expand Down
2 changes: 1 addition & 1 deletion Telegram-Mac/AddReactionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ final class AddReactionManager : NSObject, Notifable {
if isRemoving {
self.nextResponder?.scrollWheel(with: event)
}
if let window = kitWindow, window.inLiveSwiping {
if let window = _window, window.inLiveSwiping {
return
}
if let superview = superview as? ChatControllerView {
Expand Down
5 changes: 3 additions & 2 deletions Telegram-Mac/AppAppearanceViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Dock

func generateSingleColorImage(size: CGSize, color: NSColor) -> CGImage? {
return generateImage(size, contextGenerator: { size, context in
context.clear(size.bounds)
context.setFillColor(color.cgColor)
context.fill(CGRect(origin: CGPoint(), size: size))
})
Expand All @@ -26,7 +27,7 @@ func generateSingleColorImage(size: CGSize, color: NSColor) -> CGImage? {

func generateSettingsMenuPeerColorsLabelIcon(peer: Peer?, context: AccountContext, isDark: Bool = theme.colors.isDark) -> CGImage {
var colors:[PeerNameColors.Colors] = []
if let nameColor = peer?.nameColor {
if let nameColor = peer?.nameColor, let peer = peer, !peer.isGroup && !peer.isSupergroup {
colors.append(context.peerNameColors.get(nameColor, dark: isDark))
}
if let nameColor = peer?.profileColor {
Expand Down Expand Up @@ -739,7 +740,7 @@ func AppAppearanceViewController(context: AccountContext, focusOnItemTag: ThemeS
return current
}
}, userNameColor: {
context.bindings.rootNavigation().push(SelectColorController(context: context, source: .account(context.myPeer!)))
context.bindings.rootNavigation().push(SelectColorController(context: context, peer: context.myPeer!))
}, selectAppIcon: { icon in

if icon.isPremium, !context.isPremium {
Expand Down
Loading

0 comments on commit d0ab7fa

Please sign in to comment.