@@ -70,6 +70,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
70
70
private let profileGifts : ProfileGiftsContext
71
71
private let canManage : Bool
72
72
private let canGift : Bool
73
+ private var peer : EnginePeer ?
73
74
private let initialGiftCollectionId : Int64 ?
74
75
75
76
private var resultsAreEmpty = false
@@ -130,6 +131,8 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
130
131
return self . giftsListView. profileGifts
131
132
}
132
133
134
+ public var openShareLink : ( ( String ) -> Void ) ?
135
+
133
136
private let collectionsMaxCount : Int
134
137
135
138
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
193
196
if let initialGiftCollectionId {
194
197
self . setCurrentCollection ( collection: . collection( Int32 ( initialGiftCollectionId) ) )
195
198
}
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
+ } )
196
208
}
197
209
198
210
deinit {
@@ -485,68 +497,78 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
485
497
return
486
498
}
487
499
488
- var items : [ ContextMenuItem ] = [ ]
500
+ var canEditCollections = false
501
+ if self . peerId == self . context. account. peerId || self . canManage {
502
+ canEditCollections = true
503
+ }
489
504
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 ] = [ ]
501
506
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
+ } ) ) )
509
519
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
+ }
514
533
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
531
538
guard let self else {
532
539
return
533
540
}
534
- self . beginReordering ( )
535
- } )
536
- } ) ) )
541
+ f ( . default)
542
+
543
+ self . openShareLink ? ( " https://t.me/ \( addressName) /c/ \( id) " )
544
+ } ) ) )
545
+ }
537
546
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
+ } ) ) )
545
558
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
+ }
550
572
551
573
let contextController = ContextController (
552
574
presentationData: params. presentationData,
@@ -568,6 +590,10 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
568
590
if self . peerId == self . context. account. peerId || self . canManage {
569
591
canEditCollections = true
570
592
}
593
+ var canShare = false
594
+ if let peer = self . peer, let addressName = peer. addressName, !addressName. isEmpty {
595
+ canShare = true
596
+ }
571
597
572
598
let hasNonEmptyCollections = self . collections? . contains ( where: { $0. count > 0 } ) ?? false
573
599
if let collections = self . collections, !collections. isEmpty && ( hasNonEmptyCollections || canEditCollections) {
@@ -607,7 +633,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
607
633
)
608
634
) ) ,
609
635
isReorderable: collections. count > 1 ,
610
- contextAction: canEditCollections ? { [ weak self] sourceNode, gesture in
636
+ contextAction: canEditCollections || canShare ? { [ weak self] sourceNode, gesture in
611
637
guard let self else {
612
638
return
613
639
}
0 commit comments