Skip to content

Commit 711f8f7

Browse files
committed
Various improvements
1 parent 7a99577 commit 711f8f7

File tree

6 files changed

+120
-72
lines changed

6 files changed

+120
-72
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14787,3 +14787,5 @@ Sorry for the inconvenience.";
1478714787
"Stars.SellGift.TonAmountTitle" = "PRICE IN TON";
1478814788
"Stars.SellGift.OnlyTon" = "Only Accept TON";
1478914789
"Stars.SellGift.OnlyTonInfo" = "If the buyer pays you in TON, there's no risk of refunds, unlike with Stars payments.";
14790+
14791+
"Chat.ViewCollection" = "VIEW COLLECTION";

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,7 @@ public final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContent
477477
case "telegram_call":
478478
actionTitle = item.presentationData.strings.Chat_ViewGroupCall
479479
case "telegram_collection":
480-
//TODO:localize
481-
actionTitle = "VIEW COLLECTION"
480+
actionTitle = item.presentationData.strings.Chat_ViewCollection
482481
default:
483482
break
484483
}

submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ private final class PeerInfoPendingPane {
537537
paneDidScroll: @escaping () -> Void,
538538
expandIfNeeded: @escaping () -> Void,
539539
ensureRectVisible: @escaping (UIView, CGRect) -> Void,
540-
externalDataUpdated: @escaping (ContainedViewLayoutTransition) -> Void
540+
externalDataUpdated: @escaping (ContainedViewLayoutTransition) -> Void,
541+
openShareLink: @escaping (String) -> Void
541542
) {
542543
var chatLocationPeerId = peerId
543544
var chatLocation = chatLocation
@@ -578,7 +579,9 @@ private final class PeerInfoPendingPane {
578579
}
579580
}
580581
}
581-
paneNode = PeerInfoGiftsPaneNode(context: context, peerId: peerId, chatControllerInteraction: chatControllerInteraction, profileGiftsCollections: data.profileGiftsCollectionsContext!, profileGifts: data.profileGiftsContext!, canManage: canManage, canGift: canGift, initialGiftCollectionId: initialGiftCollectionId)
582+
let giftPaneNode = PeerInfoGiftsPaneNode(context: context, peerId: peerId, chatControllerInteraction: chatControllerInteraction, profileGiftsCollections: data.profileGiftsCollectionsContext!, profileGifts: data.profileGiftsContext!, canManage: canManage, canGift: canGift, initialGiftCollectionId: initialGiftCollectionId)
583+
giftPaneNode.openShareLink = openShareLink
584+
paneNode = giftPaneNode
582585
case .stories, .storyArchive, .botPreview:
583586
var canManage = false
584587
if let peer = data.peer {
@@ -748,6 +751,7 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, ASGestureRecognizerDelegat
748751

749752
var openMediaCalendar: (() -> Void)?
750753
var openAddStory: (() -> Void)?
754+
var openShareLink: ((String) -> Void)?
751755
var paneDidScroll: (() -> Void)?
752756

753757
var ensurePaneRectVisible: ((UIView, CGRect) -> Void)?
@@ -1181,6 +1185,12 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, ASGestureRecognizerDelegat
11811185
return
11821186
}
11831187
self.requestUpdate?(transition)
1188+
},
1189+
openShareLink: { [weak self] url in
1190+
guard let self else {
1191+
return
1192+
}
1193+
self.openShareLink?(url)
11841194
}
11851195
)
11861196
self.pendingPanes[key] = pane

submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4103,6 +4103,13 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
41034103
}
41044104
}
41054105

4106+
self.paneContainerNode.openShareLink = { [weak self] url in
4107+
guard let self else {
4108+
return
4109+
}
4110+
self.openShareLink(url: url)
4111+
}
4112+
41064113
self.headerNode.performButtonAction = { [weak self] key, gesture in
41074114
self?.performButtonAction(key: key, gesture: gesture)
41084115
}
@@ -11392,17 +11399,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
1139211399
pane.addGiftsToCollection(id: id)
1139311400
}
1139411401
})))
11395-
11396-
if let addressName = data.peer?.addressName, !addressName.isEmpty {
11397-
items.append(.action(ContextMenuActionItem(text: strings.PeerInfo_Gifts_ShareCollection, icon: { theme in
11398-
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.contextMenu.primaryColor)
11399-
}, action: { [weak self] _, f in
11400-
f(.default)
11401-
if let pane, case let .collection(id) = pane.currentCollection {
11402-
self?.openShareLink(url: "https://t.me/\(addressName)/c/\(id)")
11403-
}
11404-
})))
11405-
}
1140611402
}
1140711403

1140811404
if canReorder {
@@ -11430,6 +11426,20 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
1143011426
}
1143111427
}
1143211428

11429+
if let pane, case let .collection(id) = pane.currentCollection, let addressName = data.peer?.addressName, !addressName.isEmpty {
11430+
let shareAction: ContextMenuItem = .action(ContextMenuActionItem(text: strings.PeerInfo_Gifts_ShareCollection, icon: { theme in
11431+
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.contextMenu.primaryColor)
11432+
}, action: { [weak self] _, f in
11433+
f(.default)
11434+
self?.openShareLink(url: "https://t.me/\(addressName)/c/\(id)")
11435+
}))
11436+
if items.isEmpty {
11437+
items.append(shareAction)
11438+
} else {
11439+
items.insert(shareAction, at: 1)
11440+
}
11441+
}
11442+
1143311443
if !items.isEmpty {
1143411444
items.append(.separator)
1143511445
}

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

Lines changed: 80 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
7070
private let profileGifts: ProfileGiftsContext
7171
private let canManage: Bool
7272
private let canGift: Bool
73+
private var peer: EnginePeer?
7374
private let initialGiftCollectionId: Int64?
7475

7576
private var resultsAreEmpty = false
@@ -130,6 +131,8 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
130131
return self.giftsListView.profileGifts
131132
}
132133

134+
public var openShareLink: ((String) -> Void)?
135+
133136
private let collectionsMaxCount: Int
134137

135138
public init(context: AccountContext, peerId: PeerId, chatControllerInteraction: ChatControllerInteraction, profileGiftsCollections: ProfileGiftsCollectionsContext, profileGifts: ProfileGiftsContext, canManage: Bool, canGift: Bool, initialGiftCollectionId: Int64?) {
@@ -193,6 +196,15 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
193196
if let initialGiftCollectionId {
194197
self.setCurrentCollection(collection: .collection(Int32(initialGiftCollectionId)))
195198
}
199+
200+
let _ = (context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
201+
|> deliverOnMainQueue).start(next: { [weak self] peer in
202+
guard let self else {
203+
return
204+
}
205+
self.peer = peer
206+
self.updateScrolling(transition: .immediate)
207+
})
196208
}
197209

198210
deinit {
@@ -485,68 +497,78 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
485497
return
486498
}
487499

488-
var items: [ContextMenuItem] = []
500+
var canEditCollections = false
501+
if self.peerId == self.context.account.peerId || self.canManage {
502+
canEditCollections = true
503+
}
489504

490-
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_AddGifts, icon: { theme in
491-
return generateTintedImage(image: UIImage(bundleImageName: "Peer Info/Gifts/AddGift"), color: theme.actionSheet.primaryTextColor)
492-
}, action: { [weak self] _, f in
493-
guard let self else {
494-
return
495-
}
496-
f(.default)
497-
498-
self.setCurrentCollection(collection: .collection(id))
499-
self.addGiftsToCollection(id: id)
500-
})))
505+
var items: [ContextMenuItem] = []
501506

502-
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_RenameCollection, icon: { theme in
503-
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Edit"), color: theme.actionSheet.primaryTextColor)
504-
}, action: { [weak self] _, f in
505-
guard let self else {
506-
return
507-
}
508-
f(.default)
507+
if canEditCollections {
508+
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_AddGifts, icon: { theme in
509+
return generateTintedImage(image: UIImage(bundleImageName: "Peer Info/Gifts/AddGift"), color: theme.actionSheet.primaryTextColor)
510+
}, action: { [weak self] _, f in
511+
guard let self else {
512+
return
513+
}
514+
f(.default)
515+
516+
self.setCurrentCollection(collection: .collection(id))
517+
self.addGiftsToCollection(id: id)
518+
})))
509519

510-
Queue.mainQueue().after(0.15) {
511-
self.renameCollection(id: id)
512-
}
513-
})))
520+
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_RenameCollection, icon: { theme in
521+
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Edit"), color: theme.actionSheet.primaryTextColor)
522+
}, action: { [weak self] _, f in
523+
guard let self else {
524+
return
525+
}
526+
f(.default)
527+
528+
Queue.mainQueue().after(0.15) {
529+
self.renameCollection(id: id)
530+
}
531+
})))
532+
}
514533

515-
516-
// items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_ShareCollection, icon: { theme in
517-
// return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.actionSheet.primaryTextColor)
518-
// }, action: { [weak self] _, f in
519-
// guard let self else {
520-
// return
521-
// }
522-
// f(.default)
523-
//
524-
// let _ = self
525-
// })))
526-
527-
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_Reorder, icon: { theme in
528-
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ReorderItems"), color: theme.actionSheet.primaryTextColor)
529-
}, action: { [weak self] c, f in
530-
c?.dismiss(completion: { [weak self] in
534+
if let peer = self.peer, let addressName = peer.addressName, !addressName.isEmpty {
535+
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_ShareCollection, icon: { theme in
536+
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.actionSheet.primaryTextColor)
537+
}, action: { [weak self] _, f in
531538
guard let self else {
532539
return
533540
}
534-
self.beginReordering()
535-
})
536-
})))
541+
f(.default)
542+
543+
self.openShareLink?("https://t.me/\(addressName)/c/\(id)")
544+
})))
545+
}
537546

538-
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_DeleteCollection, textColor: .destructive, icon: { theme in
539-
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.contextMenu.destructiveColor)
540-
}, action: { [weak self] _, f in
541-
guard let self else {
542-
return
543-
}
544-
f(.default)
547+
if canEditCollections {
548+
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_Reorder, icon: { theme in
549+
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ReorderItems"), color: theme.actionSheet.primaryTextColor)
550+
}, action: { [weak self] c, f in
551+
c?.dismiss(completion: { [weak self] in
552+
guard let self else {
553+
return
554+
}
555+
self.beginReordering()
556+
})
557+
})))
545558

546-
Queue.mainQueue().after(0.15) {
547-
self.deleteCollection(id: id)
548-
}
549-
})))
559+
items.append(.action(ContextMenuActionItem(text: params.presentationData.strings.PeerInfo_Gifts_DeleteCollection, textColor: .destructive, icon: { theme in
560+
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.contextMenu.destructiveColor)
561+
}, action: { [weak self] _, f in
562+
guard let self else {
563+
return
564+
}
565+
f(.default)
566+
567+
Queue.mainQueue().after(0.15) {
568+
self.deleteCollection(id: id)
569+
}
570+
})))
571+
}
550572

551573
let contextController = ContextController(
552574
presentationData: params.presentationData,
@@ -568,6 +590,10 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
568590
if self.peerId == self.context.account.peerId || self.canManage {
569591
canEditCollections = true
570592
}
593+
var canShare = false
594+
if let peer = self.peer, let addressName = peer.addressName, !addressName.isEmpty {
595+
canShare = true
596+
}
571597

572598
let hasNonEmptyCollections = self.collections?.contains(where: { $0.count > 0 }) ?? false
573599
if let collections = self.collections, !collections.isEmpty && (hasNonEmptyCollections || canEditCollections) {
@@ -607,7 +633,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
607633
)
608634
)),
609635
isReorderable: collections.count > 1,
610-
contextAction: canEditCollections ? { [weak self] sourceNode, gesture in
636+
contextAction: canEditCollections || canShare ? { [weak self] sourceNode, gesture in
611637
guard let self else {
612638
return
613639
}

submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,15 +1037,16 @@ private final class SheetContent: CombinedComponent {
10371037
}
10381038

10391039
if case let .starGiftResell(giftToMatch, update, _) = self.mode {
1040+
let resaleConfiguration = StarsSubscriptionConfiguration.with(appConfiguration: self.context.currentAppConfiguration.with { $0 })
10401041
if update {
10411042
if giftToMatch.resellForTonOnly {
10421043
if let resellStars = giftToMatch.resellAmounts?.first(where: { $0.currency == .ton }) {
1043-
self.amount = resellStars.amount
1044+
self.amount = StarsAmount(value: max(resellStars.amount.value, resaleConfiguration.starGiftResaleMinTonAmount), nanos: 0)
10441045
}
10451046
self.currency = .ton
10461047
} else {
10471048
if let resellStars = giftToMatch.resellAmounts?.first(where: { $0.currency == .stars }) {
1048-
self.amount = resellStars.amount
1049+
self.amount = StarsAmount(value: max(resellStars.amount.value, resaleConfiguration.starGiftResaleMinStarsAmount), nanos: 0)
10491050
}
10501051
self.currency = .stars
10511052
}
@@ -1067,7 +1068,7 @@ private final class SheetContent: CombinedComponent {
10671068
return
10681069
}
10691070
if case let .generic(genericGift) = matchingGift, let minResaleStars = genericGift.availability?.minResaleStars {
1070-
self.amount = StarsAmount(value: minResaleStars, nanos: 0)
1071+
self.amount = StarsAmount(value: max(minResaleStars, resaleConfiguration.starGiftResaleMinStarsAmount), nanos: 0)
10711072
self.updated()
10721073
}
10731074
})

0 commit comments

Comments
 (0)