Skip to content

Commit 0a84999

Browse files
committed
bug fixes
1 parent c9e3e32 commit 0a84999

File tree

8 files changed

+104
-67
lines changed

8 files changed

+104
-67
lines changed

Telegram-Mac/ChatInterfaceInteraction.swift

Lines changed: 67 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import TGUIKit
1414
import SwiftSignalKit
1515
import MapKit
1616
import InputView
17-
17+
import CurrencyFormat
1818

1919
final class ReplyMarkupInteractions {
2020
let context: AccountContext
@@ -892,6 +892,7 @@ final class ChatInteraction : InterfaceObserver {
892892
} else if let attribute = keyboardMessage.suggestPostAttribute, !isLogInteraction, let amount = attribute.amount {
893893

894894
let context = self.context
895+
let peer = presentation.peer
895896

896897
return ReplyMarkupInteractions(context: context, proccess: { [weak self] button, progress in
897898

@@ -900,75 +901,80 @@ final class ChatInteraction : InterfaceObserver {
900901
switch url {
901902
case SuggestedPostMessageAttribute.commandApprove:
902903

903-
let comission = context.appConfiguration.getGeneralValue("ton_suggested_post_commission_permille", orElse: 850)
904-
905-
let totalAmount = amount.amount.totalValue * Double(comission.decemial / 100.0)
904+
if let peer, !peer.groupAccess.canPostMessages {
905+
_ = context.engine.messages.monoforumPerformSuggestedPostAction(
906+
id: keyboardMessage.id,
907+
action: .approve(timestamp: nil)
908+
).start()
909+
} else {
910+
let comission = context.appConfiguration.getGeneralValue("ton_suggested_post_commission_permille", orElse: 850)
911+
912+
let totalAmount = "\(Double(formatCurrencyAmount(amount.amount.value, currency: TON))! * Double(comission.decemial / 100.0))".prettyCurrencyNumberUsd
906913

907-
let formatted: String
908-
switch amount.currency {
909-
case .ton:
910-
formatted = "\(totalAmount) \(TON)"
911-
case .stars:
912-
formatted = strings().starListItemCountCountable(Int(totalAmount))
913-
}
914+
let formatted: String
915+
switch amount.currency {
916+
case .ton:
917+
formatted = "\(totalAmount) \(TON)"
918+
case .stars:
919+
formatted = strings().starListItemCountCountable(Int(amount.amount.totalValue))
920+
}
914921

915-
if attribute.timestamp == nil {
916-
let infoText = TextViewLayout(
917-
.initialize(
918-
string: strings().chatSuggestPostPublishInfo(formatted, "\(comission.decemial.string)%"),
919-
color: theme.colors.text,
920-
font: .normal(.text)
921-
),
922-
alignment: .center
923-
)
924-
infoText.measure(width: 260)
922+
if attribute.timestamp == nil {
923+
let infoText = TextViewLayout(
924+
.initialize(
925+
string: strings().chatSuggestPostPublishInfo(formatted, "\(comission.decemial.string)%"),
926+
color: theme.colors.text,
927+
font: .normal(.text)
928+
),
929+
alignment: .center
930+
)
931+
infoText.measure(width: 260)
925932

926-
showModal(
927-
with: DateSelectorModalController(
928-
context: context,
929-
mode: .dateAction(
930-
title: strings().chatSuggestPostPublishAcceptTitle,
931-
done: { date in
932-
strings().chatSuggestPostPublishDateConfirm(stringForDate(timestamp: Int32(date.timeIntervalSince1970)))
933+
showModal(
934+
with: DateSelectorModalController(
935+
context: context,
936+
mode: .dateAction(
937+
title: strings().chatSuggestPostPublishAcceptTitle,
938+
done: { date in
939+
strings().chatSuggestPostPublishDateConfirm(stringForDate(timestamp: Int32(date.timeIntervalSince1970)))
940+
},
941+
action: .init(
942+
string: strings().chatSuggestPostPublishActionNow,
943+
callback: {
944+
_ = context.engine.messages.monoforumPerformSuggestedPostAction(
945+
id: keyboardMessage.id,
946+
action: .approve(timestamp: nil)
947+
).start()
948+
}
949+
)
950+
),
951+
selectedAt: { date in
952+
_ = context.engine.messages.monoforumPerformSuggestedPostAction(
953+
id: keyboardMessage.id,
954+
action: .approve(timestamp: Int32(date.timeIntervalSince1970))
955+
).start()
933956
},
934-
action: .init(
935-
string: strings().chatSuggestPostPublishActionNow,
936-
callback: {
937-
_ = context.engine.messages.monoforumPerformSuggestedPostAction(
938-
id: keyboardMessage.id,
939-
action: .approve(timestamp: nil)
940-
).start()
941-
}
942-
)
957+
infoText: infoText
943958
),
944-
selectedAt: { date in
959+
for: context.window
960+
)
961+
} else {
962+
let author = keyboardMessage.author?.displayTitle ?? ""
963+
let info = strings().chatSuggestPostPublishConfirmInfo(author, formatted, comission.decemial.string)
964+
verifyAlert(
965+
for: context.window,
966+
header: strings().chatSuggestPostPublishConfirmHeader,
967+
information: info,
968+
ok: strings().chatSuggestPostPublishConfirmButton,
969+
successHandler: { _ in
945970
_ = context.engine.messages.monoforumPerformSuggestedPostAction(
946971
id: keyboardMessage.id,
947-
action: .approve(timestamp: Int32(date.timeIntervalSince1970))
972+
action: .approve(timestamp: nil)
948973
).start()
949-
},
950-
infoText: infoText
951-
),
952-
for: context.window
953-
)
954-
} else {
955-
let author = keyboardMessage.author?.displayTitle ?? ""
956-
let info = strings().chatSuggestPostPublishConfirmInfo(author, formatted, comission.decemial.string)
957-
verifyAlert(
958-
for: context.window,
959-
header: strings().chatSuggestPostPublishConfirmHeader,
960-
information: info,
961-
ok: strings().chatSuggestPostPublishConfirmButton,
962-
successHandler: { _ in
963-
_ = context.engine.messages.monoforumPerformSuggestedPostAction(
964-
id: keyboardMessage.id,
965-
action: .approve(timestamp: nil)
966-
).start()
967-
}
968-
)
974+
}
975+
)
976+
}
969977
}
970-
971-
972978

973979
case SuggestedPostMessageAttribute.commandDecline:
974980
showModal(with: DeclineSuggestPostModalController(context: context, callback: { comment in

Telegram-Mac/EditPostSuggestionController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private final class InputItem : GeneralRowItem {
209209
usd_rate = arguments.context.appConfiguration.getGeneralValueDouble("star_usd_rate", orElse: 0.013)
210210
}
211211

212-
self.usdLayout = .init(.initialize(string: "~\("\((Double(value) * usd_rate))".prettyCurrencyNumberUsd)", color: theme.colors.grayText, font: .normal(.text)))
212+
self.usdLayout = .init(.initialize(string: "~\("\((Double(value) * usd_rate))".prettyCurrencyNumberUsd)", color: theme.colors.grayText, font: .normal(.short)))
213213
self.usdLayout.measure(width: .greatestFiniteMagnitude)
214214
super.init(initialSize, stableId: stableId)
215215
}

Telegram-Mac/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</dict>
3434
</array>
3535
<key>CFBundleVersion</key>
36-
<string>273682</string>
36+
<string>273687</string>
3737
<key>ITSAppUsesNonExemptEncryption</key>
3838
<false/>
3939
<key>LSApplicationCategoryType</key>

Telegram-Mac/PremiumDiamondSceneView.swift

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ final class PremiumDiamondSceneView: View, SCNSceneRendererDelegate, PremiumScen
1919

2020
private let sceneView: SCNView
2121
private let diamondView = View()
22+
#if arch(arm64)
2223
private let diamondLayer: DiamondLayer
24+
#else
25+
private let diamondFallbackView: MediaAnimatedStickerView
26+
#endif
2327
private let appearanceDelay = MetaDisposable()
2428

2529
private var didSetReady = false
@@ -42,7 +46,11 @@ final class PremiumDiamondSceneView: View, SCNSceneRendererDelegate, PremiumScen
4246
self.sceneView.preferredFramesPerSecond = 60
4347
self.sceneView.isJitteringEnabled = true
4448

49+
#if arch(arm64)
4550
self.diamondLayer = DiamondLayer()
51+
#else
52+
self.diamondFallbackView = MediaAnimatedStickerView(frame: NSMakeRect(0, 0, 120, 120))
53+
#endif
4654

4755
super.init(frame: frame)
4856

@@ -52,7 +60,13 @@ final class PremiumDiamondSceneView: View, SCNSceneRendererDelegate, PremiumScen
5260
self.addSubview(sceneView)
5361
self.addSubview(diamondView)
5462
// self.layer?.addSublayer(testLayer)
63+
64+
#if arch(arm64)
5565
diamondView.layer?.addSublayer(diamondLayer)
66+
#else
67+
diamondView.addSubview(diamondFallbackView)
68+
#endif
69+
5670

5771

5872
self.setup()
@@ -76,6 +90,12 @@ final class PremiumDiamondSceneView: View, SCNSceneRendererDelegate, PremiumScen
7690
self.sceneView.delegate = self
7791
}
7892

93+
func initFallbackView(context: AccountContext) {
94+
#if arch(x86_64)
95+
diamondFallbackView.update(with: LocalAnimatedSticker.diamond.file, size: NSMakeSize(120, 120), context: context, table: nil, animated: false)
96+
#endif
97+
}
98+
7999
func renderer(_ renderer: SCNSceneRenderer, didRenderScene scene: SCNScene, atTime time: TimeInterval) {
80100
if !didSetReady {
81101
didSetReady = true
@@ -96,8 +116,9 @@ final class PremiumDiamondSceneView: View, SCNSceneRendererDelegate, PremiumScen
96116
animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
97117
animation.autoreverses = true
98118
animation.repeatCount = .infinity
99-
119+
#if arch(arm64)
100120
self.diamondLayer.add(animation, forKey: "scale")
121+
#endif
101122
}
102123

103124
private func playAppearanceAnimation(velocity: CGFloat? = nil, smallAngle: Bool = false, mirror: Bool = false, explode: Bool = false) {
@@ -168,7 +189,11 @@ final class PremiumDiamondSceneView: View, SCNSceneRendererDelegate, PremiumScen
168189
// self.diamondLayer.bounds = size.bounds
169190
// self.diamondLayer.position = NSMakePoint(size.width / 2, 0)
170191
diamondView.frame = size.bounds
192+
#if arch(arm64)
171193
diamondLayer.frame = size.bounds
194+
#else
195+
diamondFallbackView.frame = diamondView.focus(NSMakeSize(120, 120))
196+
#endif
172197
}
173198

174199
override func layout() {
@@ -182,14 +207,18 @@ final class PremiumDiamondSceneView: View, SCNSceneRendererDelegate, PremiumScen
182207
}
183208

184209
@objc private func handlePan(_ gesture: NSPanGestureRecognizer) {
210+
#if arch(arm64)
185211
self.diamondLayer.handlePan(gesture)
212+
#endif
186213
}
187214

188215
@objc private func handleTap(_ gesture: NSClickGestureRecognizer) {
189216
self.playAppearanceAnimation(explode: true)
190217
}
191218

192219
override func viewDidMoveToWindow() {
220+
#if arch(arm64)
193221
self.diamondLayer.isInHierarchy = window != nil
222+
#endif
194223
}
195224
}

Telegram-Mac/Star_ListScreen.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ private final class HeaderView : GeneralContainableRowView {
597597
addSubview(sceneView)
598598
self.sceneView.sceneBackground = theme.colors.listBackground
599599
}
600+
(sceneView as? PremiumDiamondSceneView)?.initFallbackView(context: item.context)
600601

601602
case .stars:
602603
if sceneView == nil {
@@ -607,6 +608,7 @@ private final class HeaderView : GeneralContainableRowView {
607608

608609
}
609610

611+
610612

611613
switch item.source {
612614
case let .gift(peer):

TelegramShare/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<key>CFBundleShortVersionString</key>
2222
<string>$(MARKETING_VERSION)</string>
2323
<key>CFBundleVersion</key>
24-
<string>273682</string>
24+
<string>273687</string>
2525
<key>ITSAppUsesNonExemptEncryption</key>
2626
<false/>
2727
<key>LSMinimumSystemVersion</key>

packages/TelegramMedia/Sources/LottiePlayer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ final class RenderAtomic<T> {
6363
}
6464

6565

66-
public let lottieThreadPool: ThreadPool = ThreadPool(threadCount: 10, threadPriority: 1.0)
66+
public let lottieThreadPool: ThreadPool = ThreadPool(threadCount: 4, threadPriority: 1.0)
6767
public let lottieStateQueue = Queue(name: "lottieStateQueue", qos: .default)
6868

6969

submodules/rlottie

0 commit comments

Comments
 (0)