Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
overtake committed Mar 29, 2024
1 parent 9ee213a commit 6495449
Show file tree
Hide file tree
Showing 94 changed files with 4,313 additions and 696 deletions.
6 changes: 6 additions & 0 deletions Telegram-Mac/AccountContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public struct PremiumConfiguration {
minChannelEmojiStatusLevel: 8,
minChannelWallpaperLevel: 9,
minChannelCustomWallpaperLevel: 10,
minChannelRestrictAdsLevel: 50,
minGroupProfileIconLevel: 7,
minGroupEmojiStatusLevel: 8,
minGroupWallpaperLevel: 9,
Expand All @@ -65,6 +66,8 @@ public struct PremiumConfiguration {
public let minChannelEmojiStatusLevel: Int32
public let minChannelWallpaperLevel: Int32
public let minChannelCustomWallpaperLevel: Int32
public let minChannelRestrictAdsLevel: Int32


public let minGroupProfileIconLevel: Int32
public let minGroupEmojiStatusLevel: Int32
Expand All @@ -88,6 +91,7 @@ public struct PremiumConfiguration {
minChannelEmojiStatusLevel: Int32,
minChannelWallpaperLevel: Int32,
minChannelCustomWallpaperLevel: Int32,
minChannelRestrictAdsLevel: Int32,
minGroupProfileIconLevel: Int32,
minGroupEmojiStatusLevel: Int32,
minGroupWallpaperLevel: Int32,
Expand All @@ -109,6 +113,7 @@ public struct PremiumConfiguration {
self.minChannelEmojiStatusLevel = minChannelEmojiStatusLevel
self.minChannelWallpaperLevel = minChannelWallpaperLevel
self.minChannelCustomWallpaperLevel = minChannelCustomWallpaperLevel
self.minChannelRestrictAdsLevel = minChannelRestrictAdsLevel
self.minGroupProfileIconLevel = minGroupProfileIconLevel
self.minGroupEmojiStatusLevel = minGroupEmojiStatusLevel
self.minGroupWallpaperLevel = minGroupWallpaperLevel
Expand Down Expand Up @@ -138,6 +143,7 @@ public struct PremiumConfiguration {
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,
minChannelRestrictAdsLevel: get(data["channel_restrict_sponsored_level_min"]) ?? defaultValue.minChannelRestrictAdsLevel,
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,
Expand Down
11 changes: 2 additions & 9 deletions Telegram-Mac/AccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import SwiftSignalKit
let normalAccountsLimit: Int = 3



struct SetupPasswordConfiguration {

let setup2Fa: Bool
Expand Down Expand Up @@ -889,15 +890,7 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
showModal(with: PremiumBoardingController(context: context, source: business ? .business : .settings), for: context.window)
}
}, giftPremium: {

let behaviour = SelectContactsBehavior.init(settings: [.contacts, .remote, .excludeBots], excludePeerIds: [], limit: 10)

_ = selectModalPeers(window: context.window, context: context, title: strings().premiumGiftTitle, behavior: behaviour).start(next: { peerIds in

showModal(with: PremiumGiftingController(context: context, peerIds: peerIds), for: context.window)
})

//showModal(with: ShareModalController(GiftPremiumShareObject(context)), for: context.window)
multigift(context: context)
}, addAccount: { accounts in
let testingEnvironment = NSApp.currentEvent?.modifierFlags.contains(.command) == true
let hasPremium = accounts.contains(where: { $0.peer.isPremium })
Expand Down
4 changes: 2 additions & 2 deletions Telegram-Mac/AddReactionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Postbox
import ObjcUtils
import TelegramMedia

func parabollicReactionAnimation(_ layer: CALayer, fromPoint: NSPoint, toPoint: NSPoint, window: Window, completion: ((Bool)->Void)? = nil) {
func parabollicReactionAnimation(_ layer: CALayer, fromPoint: NSPoint, toPoint: NSPoint, window: Window, completion: ((Bool)->Void)? = nil, duration: Double = 0.2) {

let view = View(frame: window.frame.size.bounds)
view.isEventLess = true
Expand All @@ -28,7 +28,7 @@ func parabollicReactionAnimation(_ layer: CALayer, fromPoint: NSPoint, toPoint:

view.layer?.addSublayer(layer)

let transition = ContainedViewLayoutTransition.animated(duration: 0.2, curve: .linear)
let transition = ContainedViewLayoutTransition.animated(duration: duration, curve: .linear)

let keyFrames = generateParabollicMotionKeyframes(from: fromPoint, to: toPoint, elevation: fromPoint.y < toPoint.y ? 50 : -50)

Expand Down
1 change: 1 addition & 0 deletions Telegram-Mac/Appearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2900,6 +2900,7 @@ private func generateIcons(from palette: ColorPalette, bubbled: Bool) -> Telegra
channel_feature_stories: { NSImage(named: "Icon_ChannelFeature_Stories")!.precomposed(palette.accent) },
channel_feature_emoji_pack: { NSImage(named: "Icon_ChannelFeature_EmojiPack")!.precomposed(palette.accent) },
channel_feature_voice_to_text: { NSImage(named: "Icon_ChannelFeature_VoiceToText")!.precomposed(palette.accent) },
channel_feature_no_ads: { NSImage(resource: .iconFragmentNoAds).precomposed(palette.accent) },
chat_hidden_author: { NSImage(named: "Icon_AuthorHidden")!.precomposed(.white) },
chat_my_notes: { NSImage(named: "Icon_MyNotes")!.precomposed(.white) },
premium_required_forward: { NSImage(named: "Icon_PremiumRequired_Forward")!.precomposed() },
Expand Down
42 changes: 35 additions & 7 deletions Telegram-Mac/ApplicationContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -525,18 +525,46 @@ final class AuthorizedApplicationContext: NSObject, SplitViewDelegate {

#if DEBUG
self.context.window.set(handler: { _ -> KeyHandlerResult in
let speedIncreaseFactor = context.appConfiguration.getGeneralValue("upload_premium_speedup_download", orElse: 10)
let title = "Download speed limited"
let text = "Subscribe to [Telegram Premium]() and increase download speeds \(speedIncreaseFactor) times."

showModalText(for: context.window, text: text, title: title, callback: { _ in
showModal(with: PremiumBoardingController(context: context, source: .upload_limit, openFeatures: true), for: context.window)
})
// var reasons: ComplicatedReport = .init(title: "WHAT IS WRONG WITH THIS AD?")
// reasons.list.append(.init(string: "I don’t like it", id: 0))
// reasons.list.append(.init(string: "I don't want to see ads", id: 1))
// reasons.list.append(.init(string: "Destination doesn't match the ad", id: 2))
//
// reasons.list.append(.init(string: "Word choice or style", id: 3, inner: .init(list: [.init(string: "Profanity or vulgarity", id: 0),
// .init(string: "Excessive formatting", id: 1),
// .init(string: "Unclear or vague meaning", id: 2)], title: "WHAT IS WRONG WITH THIS AD?")))
//
// reasons.list.append(.init(string: "Shocking or sexual content", id: 4, inner: .init(list: [.init(string: "Graphic or shocking content", id: 0),
// .init(string: "Nudity and sexual content", id: 1),
// .init(string: "Child abuse", id: 2)], title: "WHAT IS WRONG WITH THIS AD?")))
// reasons.list.append(.init(string: "Hate speech or threats", id: 5))
// reasons.list.append(.init(string: "Scam or misleading", id: 6, inner: .init(list: [.init(string: "Clickbait or exaggeration", id: 0),
// .init(string: "Deceptive or harmful financial products", id: 1),
// .init(string: "Impersonation", id: 2),
// .init(string: "Malware or phishing", id: 3)], title: "WHAT IS WRONG WITH THIS AD?")))
// reasons.list.append(.init(string: "Illegal or questionable products", id: 7, inner: .init(list: [.init(string: "Drugs, alcohol or tobacco", id: 0),
// .init(string: "Uncertified medicine or supplements", id: 1),
// .init(string: "Weapons or firearms", id: 2),
// .init(string: "Fake money", id: 3),
// .init(string: "Fake documents", id: 4),
// .init(string: "Malware, phishing, hacked accounts", id: 5),
// .init(string: "Human trafficking or exploitation", id: 6),
// .init(string: "Wild or restricted animals", id: 7),
// .init(string: "Gambling", id: 8)], title: "WHAT IS WRONG WITH THIS AD?")))
// reasons.list.append(.init(string: "Copyright infringement", id: 8, inner: .init(list: [.init(string: "Piracy or copyright infringement", id: 0),
// .init(string: "Impersonation", id: 1)], title: "WHAT IS WRONG WITH THIS AD?")))
// reasons.list.append(.init(string: "Politics or religion", id: 9, inner: .init(list: [.init(string: "Political ads or endorsement", id: 0),
// .init(string: "Religious messages or practices", id: 1),
// .init(string: "Misinformation", id: 2)], title: "WHAT IS WRONG WITH THIS AD?")))
// reasons.list.append(.init(string: "Spam", id: 10))
//
// showComplicatedReport(context: context, title: "Report Ad", info: nil, data: reasons)

return .invoked
}, with: self, for: .T, priority: .supreme, modifierFlags: [.command])

self.context.window.set(handler: { _ -> KeyHandlerResult in
showModal(with: FragmentAdsInfoController(context: context), for: context.window)
return .invoked
}, with: self, for: .Y, priority: .supreme, modifierFlags: [.command])

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "LinksToChat.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "tonads.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "lock_24.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "noads_24 (1).png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "noads_24@2x (1).png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "eye_crossed_24.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 23 additions & 2 deletions Telegram-Mac/BoostChannelModalController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ func requiredBoostSubjectLevel(subject: BoostSubject, group: Bool, context: Acco
return configuration.minGroupAudioTranscriptionLevel
case .emojiPack:
return configuration.minGroupEmojiPackLevel
case .noAds:
return configuration.minChannelRestrictAdsLevel
}
}

Expand All @@ -66,7 +68,7 @@ enum BoostSubject: Equatable {
case customWallpaper
case audioTranscription
case emojiPack

case noAds

func requiredLevel(context: AccountContext, group: Bool, configuration: PremiumConfiguration) -> Int32 {
return requiredBoostSubjectLevel(subject: self, group: group, context: context, configuration: configuration)
Expand Down Expand Up @@ -370,7 +372,7 @@ private final class BoostRowItem : TableRowItem {
var string: String

if state.status.nextLevelBoosts != nil {
if state.isAdmin {
if state.infoOnly {
if let remaining = remaining {
let valueString: String = strings().channelBoostMoreBoostsCountable(remaining)
switch state.source {
Expand Down Expand Up @@ -400,6 +402,8 @@ private final class BoostRowItem : TableRowItem {
} else {
string = strings().channelBoostEnableReactionsText("\(level + 1)", "\(level)")
}
case let .noAds(level):
string = strings().channelBoostEnableNoAdsLevelText("\(level)")
default:
if level == 0 {
if state.isGroup {
Expand Down Expand Up @@ -1111,7 +1115,20 @@ private func entries(_ state: State, arguments: Arguments) -> [InputDataEntry] {
let isGroup = arguments.isGroup

if let nextLevels = nextLevels {

var levels: [Int32] = []
for level in nextLevels {
levels.append(level)
}
if !isGroup {
let noAdsLevel = requiredBoostSubjectLevel(subject: .noAds, group: false, context: arguments.context, configuration: premiumConfiguration)
if noAdsLevel <= nextLevels.upperBound {
} else {
levels.append(noAdsLevel)
}
}

for level in levels {
var perks: [BoostChannelPerk] = []
perks.append(.story(level))

Expand Down Expand Up @@ -1167,6 +1184,9 @@ private func entries(_ state: State, arguments: Arguments) -> [InputDataEntry] {
if level >= premiumConfiguration.minChannelCustomWallpaperLevel {
perks.append(.customWallpaper)
}
if !isGroup && level >= requiredBoostSubjectLevel(subject: .noAds, group: isGroup, context: arguments.context, configuration: premiumConfiguration) {
perks.append(.noAds)
}


// header
Expand Down Expand Up @@ -1203,6 +1223,7 @@ enum BoostChannelSource : Equatable {
case wallpaper(Int32)
case unblockText(Int32)
case unblockSlowmode(Int32)
case noAds(Int32)
}

func BoostChannelModalController(context: AccountContext, peer: Peer, boosts: ChannelBoostStatus, myStatus: MyBoostStatus?, infoOnly: Bool = false, onlyFeatures: Bool = false, source: BoostChannelSource = .basic, presentation: TelegramPresentationTheme = theme) -> InputDataModalController {
Expand Down
6 changes: 5 additions & 1 deletion Telegram-Mac/BoostFeatureRowItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum BoostChannelPerk: Equatable {
case customWallpaper
case audioTranscription
case emojiPack
case noAds
func title(isGroup: Bool) -> String {
switch self {
case let .story(value):
Expand Down Expand Up @@ -64,6 +65,8 @@ enum BoostChannelPerk: Equatable {
return strings().channelBoostTableAudioTranscription
case .emojiPack:
return strings().channelBoostTableEmojiPack
case .noAds:
return strings().channelBoostTableNoAds

}
}
Expand Down Expand Up @@ -95,7 +98,8 @@ enum BoostChannelPerk: Equatable {
return theme.icons.channel_feature_voice_to_text
case .emojiPack:
return theme.icons.channel_feature_emoji_pack

case .noAds:
return theme.icons.channel_feature_no_ads
}
}
}
Expand Down
Loading

0 comments on commit 6495449

Please sign in to comment.