Skip to content

Commit 3865e25

Browse files
committed
Various fixes
1 parent 79eb359 commit 3865e25

File tree

7 files changed

+52
-30
lines changed

7 files changed

+52
-30
lines changed

submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/Sources/ChatMessageItemCommon.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,6 @@ public func canAddMessageReactions(message: Message) -> Bool {
295295
return true
296296
}
297297
}
298-
} else if let story = media as? TelegramMediaStory {
299-
if story.isMention {
300-
return false
301-
}
302298
}
303299
}
304300
return true

submodules/TelegramUI/Components/Gifts/GiftItemComponent/Sources/GiftItemComponent.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ public final class GiftItemComponent: Component {
559559
let price: String
560560
switch component.subject {
561561
case let .premium(_, priceValue), let .starGift(_, priceValue):
562-
if priceValue.containsEmoji {
562+
if priceValue.contains("#") {
563563
buttonColor = component.theme.overallDarkAppearance ? UIColor(rgb: 0xffc337) : UIColor(rgb: 0xd3720a)
564564
if !component.isSoldOut {
565565
starsColor = UIColor(rgb: 0xffbe27)
@@ -867,10 +867,12 @@ public final class GiftItemComponent: Component {
867867
}
868868
)
869869
let dateTimeFormat = component.context.sharedContext.currentPresentationData.with { $0 }.dateTimeFormat
870-
let labelText = NSMutableAttributedString(attributedString: parseMarkdownIntoAttributedString("#\(presentationStringsFormattedNumber(Int32(resellPrice), dateTimeFormat.groupingSeparator))", attributes: attributes))
871-
if let range = labelText.string.range(of: "#") {
872-
labelText.addAttribute(NSAttributedString.Key.font, value: Font.semibold(10.0), range: NSRange(range, in: labelText.string))
873-
labelText.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .stars(tinted: true)), range: NSRange(range, in: labelText.string))
870+
let labelText = NSMutableAttributedString(attributedString: parseMarkdownIntoAttributedString("# \(presentationStringsFormattedNumber(Int32(resellPrice), dateTimeFormat.groupingSeparator))", attributes: attributes))
871+
let range = (labelText.string as NSString).range(of: "#")
872+
if range.location != NSNotFound {
873+
labelText.addAttribute(NSAttributedString.Key.font, value: Font.semibold(10.0), range: range)
874+
labelText.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .stars(tinted: true)), range: range)
875+
labelText.addAttribute(.kern, value: -2.0, range: NSRange(location: range.lowerBound, length: 1))
874876
}
875877

876878
let resellSize = self.reselLabel.update(
@@ -1048,11 +1050,13 @@ private final class ButtonContentComponent: Component {
10481050
self.componentState = state
10491051

10501052
let attributedText = NSMutableAttributedString(string: component.text, font: Font.semibold(11.0), textColor: component.color)
1051-
let range = (attributedText.string as NSString).range(of: "⭐️")
1053+
let range = (attributedText.string as NSString).range(of: "#")
10521054
if range.location != NSNotFound {
10531055
attributedText.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .stars(tinted: component.tinted)), range: range)
1054-
attributedText.addAttribute(.font, value: Font.semibold(15.0), range: range)
1055-
attributedText.addAttribute(.baselineOffset, value: 2.0, range: NSRange(location: range.upperBound, length: attributedText.length - range.upperBound))
1056+
attributedText.addAttribute(.font, value: Font.semibold(component.tinted ? 14.0 : 15.0), range: range)
1057+
attributedText.addAttribute(.baselineOffset, value: -3.0, range: range)
1058+
attributedText.addAttribute(.baselineOffset, value: 1.5, range: NSRange(location: range.upperBound + 1, length: attributedText.length - range.upperBound - 1))
1059+
attributedText.addAttribute(.kern, value: -1.5, range: NSRange(location: range.upperBound, length: 1))
10561060
}
10571061

10581062
let titleSize = self.title.update(

submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,12 @@ final class GiftOptionsScreenComponent: Component {
412412
if let availability = gift.availability, availability.remains == 0, let minResaleStars = availability.minResaleStars {
413413
let priceString = presentationStringsFormattedNumber(Int32(minResaleStars), environment.dateTimeFormat.groupingSeparator)
414414
if let resaleConfiguration = self.resaleConfiguration, minResaleStars == resaleConfiguration.starGiftResaleMaxAmount || availability.resale == 1 {
415-
subject = .starGift(gift: gift, price: "⭐️ \(priceString)")
415+
subject = .starGift(gift: gift, price: "# \(priceString)")
416416
} else {
417-
subject = .starGift(gift: gift, price: "⭐️ \(priceString)+")
417+
subject = .starGift(gift: gift, price: "# \(priceString)+")
418418
}
419419
} else {
420-
subject = .starGift(gift: gift, price: "⭐️ \(presentationStringsFormattedNumber(Int32(gift.price), environment.dateTimeFormat.groupingSeparator))")
420+
subject = .starGift(gift: gift, price: "# \(presentationStringsFormattedNumber(Int32(gift.price), environment.dateTimeFormat.groupingSeparator))")
421421
}
422422
case let .unique(gift):
423423
subject = .uniqueGift(gift: gift, price: nil)

submodules/TelegramUI/Components/Gifts/GiftStoreScreen/Sources/GiftStoreScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ final class GiftStoreScreenComponent: Component {
230230
color: ribbonColor
231231
)
232232

233-
let subject: GiftItemComponent.Subject = .uniqueGift(gift: uniqueGift, price: "⭐️\(presentationStringsFormattedNumber(Int32(uniqueGift.resellStars ?? 0), environment.dateTimeFormat.groupingSeparator))")
233+
let subject: GiftItemComponent.Subject = .uniqueGift(gift: uniqueGift, price: "# \(presentationStringsFormattedNumber(Int32(uniqueGift.resellStars ?? 0), environment.dateTimeFormat.groupingSeparator))")
234234
let _ = visibleItem.update(
235235
transition: itemTransition,
236236
component: AnyComponent(

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,29 @@ private final class GiftViewSheetContent: CombinedComponent {
309309
let context = self.context
310310
let action = {
311311
if gifts {
312-
if let profileController = context.sharedContext.makePeerInfoController(
313-
context: context,
314-
updatedPresentationData: nil,
315-
peer: peer._asPeer(),
316-
mode: peer.id == context.account.peerId ? .myProfileGifts : .gifts,
317-
avatarInitiallyExpanded: false,
318-
fromChat: false,
319-
requestsContext: nil
320-
) {
321-
navigationController.pushViewController(profileController)
312+
let profileGifts = ProfileGiftsContext(account: context.account, peerId: peer.id)
313+
let _ = (profileGifts.state
314+
|> filter { state in
315+
if case .ready = state.dataState {
316+
return true
317+
}
318+
return false
322319
}
320+
|> take(1)
321+
|> deliverOnMainQueue).start(next: { [weak navigationController] _ in
322+
if let profileController = context.sharedContext.makePeerInfoController(
323+
context: context,
324+
updatedPresentationData: nil,
325+
peer: peer._asPeer(),
326+
mode: peer.id == context.account.peerId ? .myProfileGifts : .gifts,
327+
avatarInitiallyExpanded: false,
328+
fromChat: false,
329+
requestsContext: nil
330+
) {
331+
navigationController?.pushViewController(profileController)
332+
}
333+
let _ = profileGifts
334+
})
323335
} else {
324336
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(
325337
navigationController: navigationController,

submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
488488

489489
switch product.gift {
490490
case let .generic(gift):
491-
subject = .starGift(gift: gift, price: "⭐️ \(gift.price)")
491+
subject = .starGift(gift: gift, price: "# \(gift.price)")
492492
peer = product.fromPeer.flatMap { .peer($0) } ?? .anonymous
493493

494494
if let availability = gift.availability {

submodules/TelegramUI/Components/TabSelectorComponent/Sources/TabSelectorComponent.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ public final class TabSelectorComponent: Component {
117117
private let selectionView: UIImageView
118118
private var visibleItems: [AnyHashable: VisibleItem] = [:]
119119

120+
private var didInitiallyScroll = false
121+
120122
override init(frame: CGRect) {
121123
self.selectionView = UIImageView()
122124

@@ -238,11 +240,15 @@ public final class TabSelectorComponent: Component {
238240
)),
239241
effectAlignment: .center,
240242
minSize: nil,
241-
action: { [weak self] in
243+
action: { [weak self, weak itemView] in
242244
guard let self, let component = self.component else {
243245
return
244246
}
245247
component.setSelectedId(itemId)
248+
249+
if let view = itemView?.title.view, allowScroll && self.contentSize.width > self.bounds.width {
250+
self.scrollRectToVisible(view.frame.insetBy(dx: -64.0, dy: 0.0), animated: true)
251+
}
246252
},
247253
animateScale: !isLineSelection
248254
)),
@@ -336,11 +342,15 @@ public final class TabSelectorComponent: Component {
336342
self.selectionView.alpha = 0.0
337343
}
338344

339-
self.contentSize = CGSize(width: contentWidth, height: baseHeight + verticalInset * 2.0)
345+
let contentSize = CGSize(width: contentWidth, height: baseHeight + verticalInset * 2.0)
346+
if self.contentSize != contentSize {
347+
self.contentSize = contentSize
348+
}
340349
self.disablesInteractiveTransitionGestureRecognizer = contentWidth > availableSize.width
341350

342-
if let selectedBackgroundRect, self.bounds.width > 0.0 {
351+
if let selectedBackgroundRect, self.bounds.width > 0.0 && !self.didInitiallyScroll {
343352
self.scrollRectToVisible(selectedBackgroundRect.insetBy(dx: -spacing, dy: 0.0), animated: false)
353+
self.didInitiallyScroll = true
344354
}
345355

346356
return CGSize(width: min(contentWidth, availableSize.width), height: baseHeight + verticalInset * 2.0)

0 commit comments

Comments
 (0)