Skip to content

Commit d96cbd4

Browse files
committed
Merge branch 'release'
2 parents 539b85f + 32a3394 commit d96cbd4

File tree

2,697 files changed

+64185
-455510
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,697 files changed

+64185
-455510
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ core-xprojects/libopus/build
1010
core-xprojects/ffmpeg/build
1111
core-xprojects/webrtc/build
1212
core-xprojects/libvpx/build
13-
13+
core-xprojects/OpenH264/build
14+
submodules/libwebp/SharedHeaders
15+
submodules/Mozjpeg/SharedHeaders
16+
submodules/OpenSSLEncryptionProvider/SharedHeaders
17+
core-xprojects/dav1d/build
18+
core-xprojects/tde2e/build

Telegram-Mac.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Telegram-Mac/AccountContext.swift

Lines changed: 231 additions & 115 deletions
Large diffs are not rendered by default.

Telegram-Mac/AccountInfoItem.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class AccountInfoItem: GeneralRowItem {
5757
self.titleActiveLayout = .init(activeTitle, maximumNumberOfLines: 1)
5858

5959
if let phone = peer.phone {
60-
_ = attr.append(string: formatPhoneNumber(phone), color: theme.colors.grayText, font: .normal(.text))
60+
_ = attr.append(string: formatPhoneNumber(context: context, number: phone), color: theme.colors.grayText, font: .normal(.text))
6161
}
6262
if let username = peer.username, !username.isEmpty {
6363
if !attr.string.isEmpty {
@@ -104,7 +104,7 @@ class AccountInfoItem: GeneralRowItem {
104104
textLayout.measure(width: width - 140)
105105
activeTextlayout.measure(width: width - 140)
106106

107-
let hasControl = PremiumStatusControl.hasControl(peer)
107+
let hasControl = PremiumStatusControl.hasControl(peer, left: false)
108108

109109
self.titleLayout.measure(width: width - 140 - (hasControl ? 45 : 0))
110110
self.titleActiveLayout.measure(width: width - 140 - (hasControl ? 45 : 0))
@@ -333,7 +333,7 @@ private class AccountInfoView : GeneralContainableRowView {
333333
self.statusControl = nil
334334
}
335335

336-
let control = PremiumStatusControl.control(item.peer, account: item.context.account, inlinePacksContext: item.context.inlinePacksContext, isSelected: item.isSelected, isBig: true, cached: self.statusControl, animated: animated)
336+
let control = PremiumStatusControl.control(item.peer, account: item.context.account, inlinePacksContext: item.context.inlinePacksContext, left: false, isSelected: item.isSelected, isBig: true, cached: self.statusControl, animated: animated)
337337

338338
if let control = control {
339339
self.statusControl = control
@@ -380,7 +380,7 @@ private class AccountInfoView : GeneralContainableRowView {
380380
self.photoVideoView!.isEventLess = true
381381
self.photoVideoView!.frame = self.avatarView.frame
382382

383-
let file = TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: video.resource, previewRepresentations: first.image.representations, videoThumbnails: [], immediateThumbnailData: nil, mimeType: "video/mp4", size: video.resource.size, attributes: [])
383+
let file = TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: video.resource, previewRepresentations: first.image.representations, videoThumbnails: [], immediateThumbnailData: nil, mimeType: "video/mp4", size: video.resource.size, attributes: [], alternativeRepresentations: [])
384384

385385
let mediaPlayer = MediaPlayer(postbox: item.context.account.postbox, userLocation: .peer(item.context.peerId), userContentType: .avatar, reference: MediaResourceReference.standalone(resource: file.resource), streamable: true, video: true, preferSoftwareDecoding: false, enableSound: false, fetchAutomatically: true)
386386

Telegram-Mac/AccountViewController.swift

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
418418
arguments.openPremium(true)
419419
}, border:[BorderType.Right], inset:NSEdgeInsets(left: 12, right: 12))
420420
case let .giftPremium(_, viewType):
421-
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))
421+
return GeneralInteractedRowItem(initialSize, stableId: stableId, name: strings().accountSettingsSendGift, icon: theme.icons.settingsGiftPremium, activeIcon: theme.icons.settingsGiftPremium, type: .next, viewType: viewType, action: arguments.giftPremium, border:[BorderType.Right], inset:NSEdgeInsets(left: 12, right: 12))
422422
case let .stars(_, stars, viewType):
423423
return GeneralInteractedRowItem(initialSize, stableId: stableId, name: strings().accountSettingsStars, icon: theme.icons.settingsStars, activeIcon: theme.icons.settingsStars, type: .nextContext(stars > 0 ? "\(stars)" : ""), viewType: viewType, action: arguments.stars, border:[BorderType.Right], inset:NSEdgeInsets(left: 12, right: 12))
424424
case let .faq(_, viewType):
@@ -635,8 +635,8 @@ private func accountInfoEntries(peerView:PeerView, context: AccountContext, acco
635635

636636
let stars_purchase_blocked = context.appConfiguration.getBoolValue("stars_purchase_blocked", orElse: true)
637637

638-
if !stars_purchase_blocked, let stars, stars.balance > 0 || !stars.transactions.isEmpty {
639-
entries.append(.stars(index: index, count: stars.balance, viewType: .singleItem))
638+
if !stars_purchase_blocked, let stars, stars.balance.value > 0 || !stars.transactions.isEmpty {
639+
entries.append(.stars(index: index, count: stars.balance.value, viewType: .singleItem))
640640
index += 1
641641
}
642642

@@ -813,6 +813,17 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
813813

814814
private let settings: Promise<(AccountPrivacySettings?, WebSessionsContextState, (ProxySettings, ConnectionStatus), (Bool, Bool))> = Promise()
815815

816+
func updateMessagesPrivacy(noPaidMessages: SelectivePrivacySettings, globalSettings: GlobalPrivacySettings) {
817+
let privacy = self.settings.get() |> deliverOnMainQueue |> take(1)
818+
_ = privacy.startStandalone(next: { [weak self] privacy, web, proxy, value in
819+
var privacy = privacy
820+
privacy?.noPaidMessages = noPaidMessages
821+
privacy?.globalSettings = globalSettings
822+
DispatchQueue.main.async {
823+
self?.settings.set(.single((privacy, web, proxy, value)))
824+
}
825+
})
826+
}
816827

817828
func updatePrivacy(_ updated: SelectivePrivacySettings, kind: SelectivePrivacySettingsKind) {
818829
let privacy = self.settings.get() |> deliverOnMainQueue |> take(1)
@@ -838,6 +849,8 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
838849
privacy?.bio = updated
839850
case .birthday:
840851
privacy?.birthday = updated
852+
case .gifts:
853+
privacy?.giftsAutoSave = updated
841854
}
842855
DispatchQueue.main.async {
843856
self?.settings.set(.single((privacy, web, proxy, value)))
@@ -909,8 +922,8 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
909922

910923

911924
let setStatus:(Control, TelegramUser)->Void = { control, peer in
912-
let callback:(TelegramMediaFile, Int32?, CGRect?)->Void = { file, timeout, fromRect in
913-
context.reactions.setStatus(file, peer: peer, timestamp: context.timestamp, timeout: timeout, fromRect: fromRect)
925+
let callback:(TelegramMediaFile, StarGift.UniqueGift?, Int32?, CGRect?)->Void = { file, starGift, timeout, fromRect in
926+
context.reactions.setStatus(file, peer: peer, timestamp: context.timestamp, timeout: timeout, fromRect: fromRect, starGift: starGift)
914927
}
915928
if control.popover == nil {
916929
showPopover(for: control, with: PremiumStatusController(context, callback: callback, peer: peer), edge: .maxY, inset: NSMakePoint(-80, -35), static: true, animationMode: .reveal)
@@ -941,7 +954,7 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
941954
navigation.push(PremiumBoardingController(context: context, source: .business_standalone), false)
942955
}
943956
} else {
944-
showModal(with: PremiumBoardingController(context: context, source: business ? .business : .settings), for: context.window)
957+
prem(with: PremiumBoardingController(context: context, source: business ? .business : .settings), for: context.window)
945958
}
946959
}, giftPremium: {
947960
multigift(context: context)

Telegram-Mac/AddContactModalController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func AddContactModalController(_ context: AccountContext) -> InputDataModalContr
146146
return state
147147
.withUpdatedFirstName(data[_id_input_first_name]?.stringValue ?? "")
148148
.withUpdatedLastName(data[_id_input_last_name]?.stringValue ?? "")
149-
.withUpdatedPhoneNumber(formatPhoneNumber(data[_id_input_phone_number]?.stringValue ?? ""))
149+
.withUpdatedPhoneNumber(formatPhoneNumber(context: context, number: data[_id_input_phone_number]?.stringValue ?? ""))
150150
.withUpdatedError(nil, for: _id_input_first_name)
151151
.withUpdatedError(nil, for: _id_input_last_name)
152152
.withUpdatedError(nil, for: _id_input_phone_number)

Telegram-Mac/AddReactionManager.swift

Lines changed: 82 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ private func generateParabollicMotionKeyframes(from sourcePoint: CGPoint, to tar
9595

9696

9797
enum ContextReaction : Equatable {
98+
case stars(file: TelegramMediaFile, isSelected: Bool)
9899
case builtin(value: MessageReaction.Reaction, staticFile: TelegramMediaFile, selectFile: TelegramMediaFile, appearFile: TelegramMediaFile, isSelected: Bool)
99100
case custom(value: MessageReaction.Reaction, fileId: Int64, TelegramMediaFile?, isSelected: Bool)
100101

@@ -104,6 +105,8 @@ enum ContextReaction : Equatable {
104105
return staticFile
105106
case let .custom(_, _, file, _ ):
106107
return file
108+
case let .stars(file, _):
109+
return file
107110
}
108111
}
109112
var fileId: Int64 {
@@ -112,6 +115,8 @@ enum ContextReaction : Equatable {
112115
return staticFile.fileId.id
113116
case let .custom(_, fileId, _, _):
114117
return fileId
118+
case let .stars(file, _):
119+
return file.fileId.id
115120
}
116121
}
117122
var isSelected: Bool {
@@ -120,6 +125,8 @@ enum ContextReaction : Equatable {
120125
return isSelected
121126
case let .custom(_, _, _, isSelected):
122127
return isSelected
128+
case let .stars(_, isSelected):
129+
return isSelected
123130
}
124131
}
125132
func selectAnimation(_ context: AccountContext) -> Signal<TelegramMediaFile, NoError> {
@@ -128,6 +135,8 @@ enum ContextReaction : Equatable {
128135
return .single(selectAnimation)
129136
case .custom:
130137
return .complete()
138+
case let .stars(file, _):
139+
return .single(file)
131140
}
132141
}
133142
var selectedAnimation: TelegramMediaFile? {
@@ -136,6 +145,8 @@ enum ContextReaction : Equatable {
136145
return selectAnimation
137146
case let .custom(_, _, file, _ ):
138147
return file
148+
case let .stars(file, _):
149+
return file
139150
}
140151
}
141152
var appearAnimation: TelegramMediaFile? {
@@ -144,6 +155,8 @@ enum ContextReaction : Equatable {
144155
return appearAnimation
145156
case .custom:
146157
return nil
158+
case .stars:
159+
return nil
147160
}
148161
}
149162
var value: MessageReaction.Reaction {
@@ -152,6 +165,8 @@ enum ContextReaction : Equatable {
152165
return value
153166
case let .custom(value, _, _, _):
154167
return value
168+
case .stars:
169+
return .stars
155170
}
156171
}
157172

@@ -178,7 +193,11 @@ final class ContextAddReactionsListView : View, StickerFramesCollector {
178193
private var selectionView : View?
179194
private let presentation: TelegramPresentationTheme
180195

181-
required init(frame frameRect: NSRect, context: AccountContext, reaction: ContextReaction, add: @escaping(MessageReaction.Reaction, Bool, NSRect?)->Void, theme: TelegramPresentationTheme) {
196+
private var starEffect: StarsButtonEffectLayer?
197+
198+
private var starBackground: SimpleGradientLayer?
199+
200+
required init(frame frameRect: NSRect, context: AccountContext, reaction: ContextReaction, add: @escaping(MessageReaction.Reaction, Bool, NSRect?)->Void, theme: TelegramPresentationTheme, message: Message?) {
182201

183202
let size: NSSize = reaction.isSelected ? NSMakeSize(25, 24) : NSMakeSize(frameRect.width, 30)
184203
let rect = CGRect(origin: .zero, size: size)
@@ -192,6 +211,32 @@ final class ContextAddReactionsListView : View, StickerFramesCollector {
192211

193212
super.init(frame: frameRect)
194213

214+
self.layer?.masksToBounds = false
215+
216+
if case .stars = reaction.value {
217+
218+
if !reaction.isSelected {
219+
starBackground = .init(frame: frameRect.size.bounds.insetBy(dx: -2, dy: -2))
220+
self.layer?.addSublayer(starBackground!)
221+
222+
starBackground?.colors = [NSColor(0xFFAC04).withAlphaComponent(0.15),
223+
NSColor(0xFFCA35).withAlphaComponent(0.1),
224+
NSColor(0xffffff).withAlphaComponent(0.0)].map { $0.cgColor }
225+
226+
starBackground?.startPoint = NSMakePoint(0, 0.5)
227+
starBackground?.endPoint = NSMakePoint(1, 0.5)
228+
}
229+
230+
231+
232+
233+
starEffect = .init()
234+
starEffect?.frame = rect
235+
starEffect?.update(size: rect.size)
236+
self.layer?.addSublayer(starEffect!)
237+
}
238+
239+
195240
let imageView: InlineStickerView
196241
if let file = reaction.selectedAnimation {
197242
imageView = InlineStickerView(account: context.account, file: file, size: size, isPlayable: false)
@@ -203,13 +248,16 @@ final class ContextAddReactionsListView : View, StickerFramesCollector {
203248

204249
addSubview(player)
205250
self.player.isHidden = false
206-
251+
252+
207253

208254
switch reaction {
209255
case .builtin:
210256
self.layer?.cornerRadius = 0
211257
case .custom:
212258
self.layer?.cornerRadius = 4
259+
case .stars:
260+
self.layer?.cornerRadius = 0
213261
}
214262

215263
stateDisposable.set(player.state.start(next: { [weak self] state in
@@ -228,8 +276,12 @@ final class ContextAddReactionsListView : View, StickerFramesCollector {
228276
}))
229277

230278

231-
let signal = reaction.selectAnimation(context) |> mapToSignal {
232-
context.account.postbox.mediaBox.resourceData($0.resource, attemptSynchronously: true)
279+
let signal = reaction.selectAnimation(context) |> mapToSignal { file in
280+
if let resource = file.resource as? LocalBundleResource, let path = resource.path {
281+
return .single(MediaResourceData(path: path, offset: 0, size: 0, complete: true))
282+
} else {
283+
return context.account.postbox.mediaBox.resourceData(file.resource, attemptSynchronously: true)
284+
}
233285
}
234286
|> filter {
235287
$0.complete
@@ -239,14 +291,15 @@ final class ContextAddReactionsListView : View, StickerFramesCollector {
239291
disposable.set(signal.start(next: { [weak self] resourceData in
240292
if let data = try? Data(contentsOf: URL.init(fileURLWithPath: resourceData.path)) {
241293
self?.selectAnimationData = data
242-
if isLite {
294+
if !isLite {
243295
let apply:()->Void = {
244296
self?.apply(data, key: "select", policy: .framesCount(1))
245297
}
246298
apply()
247299
}
248300
}
249301
}))
302+
250303
set(handler: { control in
251304
if let window = control.window {
252305
let wrect = control.convert(control.frame.size.bounds, to: nil)
@@ -255,14 +308,30 @@ final class ContextAddReactionsListView : View, StickerFramesCollector {
255308
}
256309
}, for: .Click)
257310

258-
contextMenu = {
259-
let menu = ContextMenu()
260-
menu.addItem(ContextMenuItem(strings().chatContextReactionQuick, handler: {
261-
context.reactions.updateQuick(reaction.value)
262-
}, itemImage: MenuAnimation.menu_add_to_favorites.value))
263-
return menu
311+
if case .stars = reaction.value, let message {
312+
self.set(handler: { _ in
313+
showModal(with: Star_ReactionsController(context: context, message: message), for: context.window)
314+
AppMenu.closeAll()
315+
}, for: .RightDown)
316+
317+
self.set(handler: { _ in
318+
showModal(with: Star_ReactionsController(context: context, message: message), for: context.window)
319+
AppMenu.closeAll()
320+
}, for: .LongMouseDown)
321+
} else {
322+
323+
contextMenu = {
324+
let menu = ContextMenu()
325+
menu.addItem(ContextMenuItem(strings().chatContextReactionQuick, handler: {
326+
context.reactions.updateQuick(reaction.value)
327+
}, itemImage: MenuAnimation.menu_add_to_favorites.value))
328+
return menu
329+
}
264330
}
265331

332+
333+
334+
266335
if reaction.isSelected {
267336
let view = View()
268337
self.selectionView = view
@@ -435,7 +504,7 @@ final class ContextAddReactionsListView : View, StickerFramesCollector {
435504
private let presentation: TelegramPresentationTheme
436505
private let hasBubble: Bool
437506
private let aboveText: TextViewLayout?
438-
required init(frame frameRect: NSRect, context: AccountContext, list: [ContextReaction], add:@escaping(MessageReaction.Reaction, Bool, NSRect?)->Void, radiusLayer: CGFloat? = 15, revealReactions:((ContextAddReactionsListView & StickerFramesCollector)->Void)? = nil, presentation: TelegramPresentationTheme = theme, hasBubble: Bool = true, aboveText: TextViewLayout? = nil) {
507+
required init(frame frameRect: NSRect, context: AccountContext, list: [ContextReaction], add:@escaping(MessageReaction.Reaction, Bool, NSRect?)->Void, radiusLayer: CGFloat? = 15, revealReactions:((ContextAddReactionsListView & StickerFramesCollector)->Void)? = nil, presentation: TelegramPresentationTheme = theme, hasBubble: Bool = true, aboveText: TextViewLayout? = nil, message: Message? = nil) {
439508
self.list = list
440509
self.showMore = ShowMore(frame: NSMakeRect(0, 0, 34, 34), theme: presentation)
441510
self.revealReactions = revealReactions
@@ -541,7 +610,7 @@ final class ContextAddReactionsListView : View, StickerFramesCollector {
541610
for reaction in list {
542611
let add:(ContextReaction)->Void = { reaction in
543612
let itemSize = size.bounds
544-
let reaction = ReactionView(frame: NSMakeRect(x, y, itemSize.width, itemSize.height), context: context, reaction: reaction, add: add, theme: presentation)
613+
let reaction = ReactionView(frame: NSMakeRect(x, y, itemSize.width, itemSize.height), context: context, reaction: reaction, add: add, theme: presentation, message: message)
545614

546615
self.documentView.addSubview(reaction)
547616
x += size.width + 4

0 commit comments

Comments
 (0)