Skip to content

Commit f223dab

Browse files
committed
Various fixes
1 parent 27e6f83 commit f223dab

File tree

6 files changed

+111
-35
lines changed

6 files changed

+111
-35
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13611,6 +13611,29 @@ Sorry for the inconvenience.";
1361113611
"Gift.View.Self.Title" = "Saved Gift";
1361213612
"Gift.View.Self.Description" = "You can display this gift on your page or turn it into a unique collectible and send to others.";
1361313613

13614+
"BotVerification.Verify.Placeholder" = "This page is verified by %@";
13615+
13616+
"BotVerification.Verify.Channel.Title" = "Verify Channel";
13617+
"BotVerification.Verify.Channel.Text" = "Do you want to verify this channel with your verification mark and description?";
13618+
"BotVerification.Verify.Group.Title" = "Verify Group";
13619+
"BotVerification.Verify.Group.Text" = "Do you want to verify this group with your verification mark and description?";
13620+
"BotVerification.Verify.User.Title" = "Verify Bot";
13621+
"BotVerification.Verify.User.Text" = "Do you want to verify this user with your verification mark and description?";
13622+
"BotVerification.Verify.Bot.Title" = "Verify Bot";
13623+
"BotVerification.Verify.Bot.Text" = "Do you want to verify this bot with your verification mark and description?";
13624+
13625+
"BotVerification.Verify.Verify" = "Verify";
13626+
13627+
"BotVerification.Remove.Title" = "Remove Verification";
13628+
"BotVerification.Remove.Channel.Text" = "This channel is already verified by you. Do you want to remove verification?";
13629+
"BotVerification.Remove.Group.Text" = "This group is already verified by you. Do you want to remove verification?";
13630+
"BotVerification.Remove.User.Text" = "This user is already verified by you. Do you want to remove verification?";
13631+
"BotVerification.Remove.Bot.Text" = "This bot is already verified by you. Do you want to remove verification?";
13632+
"BotVerification.Remove.Remove" = "Remove";
13633+
1361413634
"BotVerification.ChooseChat" = "Choose Chat to Verify";
1361513635
"BotVerification.Added" = "**%@** has been notified and will receive your verification mark and description upon accepting.";
1361613636
"BotVerification.Removed" = "You have removed **%@'s** verification.";
13637+
13638+
"Premium.Gift.ContactSelection.ThisIsYou" = "THIS IS YOU";
13639+
"Premium.Gift.ContactSelection.BuySelf" = "buy yourself a gift";

submodules/ContactListUI/Sources/ContactListNode.swift

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private enum ContactListNodeEntry: Comparable, Identifiable {
9898
case permissionInfo(PresentationTheme, String, String, Bool)
9999
case permissionEnable(PresentationTheme, String)
100100
case option(Int, ContactListAdditionalOption, ListViewItemHeader?, PresentationTheme, PresentationStrings)
101-
case peer(Int, ContactListPeer, EnginePeer.Presence?, ListViewItemHeader?, ContactsPeerItemSelection, PresentationTheme, PresentationStrings, PresentationDateTimeFormat, PresentationPersonNameOrder, PresentationPersonNameOrder, Bool, Bool, Bool, StoryData?, Bool)
101+
case peer(Int, ContactListPeer, EnginePeer.Presence?, ListViewItemHeader?, ContactsPeerItemSelection, PresentationTheme, PresentationStrings, PresentationDateTimeFormat, PresentationPersonNameOrder, PresentationPersonNameOrder, Bool, Bool, Bool, StoryData?, Bool, String?)
102102

103103
var stableId: ContactListNodeEntryId {
104104
switch self {
@@ -112,7 +112,7 @@ private enum ContactListNodeEntry: Comparable, Identifiable {
112112
return .permission(action: true)
113113
case let .option(index, _, _, _, _):
114114
return .option(index: index)
115-
case let .peer(_, peer, _, _, _, _, _, _, _, _, _, _, _, storyData, _):
115+
case let .peer(_, peer, _, _, _, _, _, _, _, _, _, _, _, storyData, _, _):
116116
switch peer {
117117
case let .peer(peer, _, _):
118118
return .peerId(peerId: peer.id.toInt64(), section: storyData != nil ? .stories : .contacts)
@@ -152,7 +152,7 @@ private enum ContactListNodeEntry: Comparable, Identifiable {
152152
style = .generic
153153
}
154154
return ContactListActionItem(presentationData: ItemListPresentationData(presentationData), title: option.title, subtitle: option.subtitle, icon: option.icon, style: style, clearHighlightAutomatically: option.clearHighlightAutomatically, header: header, action: option.action)
155-
case let .peer(_, peer, presence, header, selection, _, strings, dateTimeFormat, nameSortOrder, nameDisplayOrder, displayCallIcons, hasMoreButton, enabled, storyData, requiresPremiumForMessaging):
155+
case let .peer(_, peer, presence, header, selection, _, strings, dateTimeFormat, nameSortOrder, nameDisplayOrder, displayCallIcons, hasMoreButton, enabled, storyData, requiresPremiumForMessaging, customSubtitle):
156156
var status: ContactsPeerItemStatus
157157
let itemPeer: ContactsPeerItemPeer
158158
var isContextActionEnabled = false
@@ -221,8 +221,11 @@ private enum ContactListNodeEntry: Comparable, Identifiable {
221221
})]
222222
}
223223

224+
224225
var storyStats: (total: Int, unseen: Int, hasUnseenCloseFriends: Bool)?
225-
if let storyData = storyData {
226+
if let customSubtitle {
227+
status = .custom(string: NSAttributedString(string: customSubtitle), multiline: false, isActive: false, icon: nil)
228+
} else if let storyData {
226229
storyStats = (storyData.count, storyData.unseenCount, storyData.hasUnseenCloseFriends)
227230

228231
let text: String
@@ -276,9 +279,9 @@ private enum ContactListNodeEntry: Comparable, Identifiable {
276279
} else {
277280
return false
278281
}
279-
case let .peer(lhsIndex, lhsPeer, lhsPresence, lhsHeader, lhsSelection, lhsTheme, lhsStrings, lhsTimeFormat, lhsSortOrder, lhsDisplayOrder, lhsDisplayCallIcons, lhsHasMoreButton, lhsEnabled, lhsStoryData, lhsRequiresPremiumForMessaging):
282+
case let .peer(lhsIndex, lhsPeer, lhsPresence, lhsHeader, lhsSelection, lhsTheme, lhsStrings, lhsTimeFormat, lhsSortOrder, lhsDisplayOrder, lhsDisplayCallIcons, lhsHasMoreButton, lhsEnabled, lhsStoryData, lhsRequiresPremiumForMessaging, lhsCustomSubtitle):
280283
switch rhs {
281-
case let .peer(rhsIndex, rhsPeer, rhsPresence, rhsHeader, rhsSelection, rhsTheme, rhsStrings, rhsTimeFormat, rhsSortOrder, rhsDisplayOrder, rhsDisplayCallIcons, rhsHasMoreButton, rhsEnabled, rhsStoryData, rhsRequiresPremiumForMessaging):
284+
case let .peer(rhsIndex, rhsPeer, rhsPresence, rhsHeader, rhsSelection, rhsTheme, rhsStrings, rhsTimeFormat, rhsSortOrder, rhsDisplayOrder, rhsDisplayCallIcons, rhsHasMoreButton, rhsEnabled, rhsStoryData, rhsRequiresPremiumForMessaging, rhsCustomSubtitle):
282285
if lhsIndex != rhsIndex {
283286
return false
284287
}
@@ -328,6 +331,9 @@ private enum ContactListNodeEntry: Comparable, Identifiable {
328331
if lhsRequiresPremiumForMessaging != rhsRequiresPremiumForMessaging {
329332
return false
330333
}
334+
if lhsCustomSubtitle != rhsCustomSubtitle {
335+
return false
336+
}
331337
return true
332338
default:
333339
return false
@@ -369,11 +375,11 @@ private enum ContactListNodeEntry: Comparable, Identifiable {
369375
case .peer:
370376
return true
371377
}
372-
case let .peer(lhsIndex, _, _, _, _, _, _, _, _, _, _, _, _, lhsStoryData, _):
378+
case let .peer(lhsIndex, _, _, _, _, _, _, _, _, _, _, _, _, lhsStoryData, _, _):
373379
switch rhs {
374380
case .search, .sort, .permissionInfo, .permissionEnable, .option:
375381
return false
376-
case let .peer(rhsIndex, _, _, _, _, _, _, _, _, _, _, _, _, rhsStoryData, _):
382+
case let .peer(rhsIndex, _, _, _, _, _, _, _, _, _, _, _, _, rhsStoryData, _, _):
377383
if (lhsStoryData == nil) != (rhsStoryData == nil) {
378384
if lhsStoryData != nil {
379385
return true
@@ -567,15 +573,24 @@ private func contactListNodeEntries(accountPeer: EnginePeer?, peers: [ContactLis
567573
}
568574

569575
let presence = presences[peer.id]
570-
entries.append(.peer(index, .peer(peer: peer._asPeer(), isGlobal: false, participantCount: nil), presence, header, selection, theme, strings, dateTimeFormat, sortOrder, displayOrder, false, false, true, nil, false))
576+
entries.append(.peer(index, .peer(peer: peer._asPeer(), isGlobal: false, participantCount: nil), presence, header, selection, theme, strings, dateTimeFormat, sortOrder, displayOrder, false, false, true, nil, false, nil))
571577

572578
index += 1
573579
}
574580
}
575-
case let .custom(sections):
581+
case let .custom(showSelf, sections):
576582
if !topPeers.isEmpty {
577583
var index: Int = 0
578-
var sectionId: Int = 1
584+
585+
if showSelf, let accountPeer {
586+
if let peer = topPeers.first(where: { $0.id == accountPeer.id }) {
587+
let header = ChatListSearchItemHeader(type: .text(strings.Premium_Gift_ContactSelection_ThisIsYou.uppercased(), AnyHashable(10)), theme: theme, strings: strings)
588+
entries.append(.peer(index, .peer(peer: peer._asPeer(), isGlobal: false, participantCount: nil), nil, header, .none, theme, strings, dateTimeFormat, sortOrder, displayOrder, false, false, true, nil, false, strings.Premium_Gift_ContactSelection_BuySelf))
589+
existingPeerIds.insert(.peer(peer.id))
590+
}
591+
}
592+
593+
var sectionId: Int = 2
579594
for (title, peerIds, hasActions) in sections {
580595
var allSelected = true
581596
if let selectedPeerIndices = selectionState?.selectedPeerIndices, !selectedPeerIndices.isEmpty {
@@ -624,7 +639,7 @@ private func contactListNodeEntries(accountPeer: EnginePeer?, peers: [ContactLis
624639
}
625640

626641
let presence = presences[peer.id]
627-
entries.append(.peer(index, .peer(peer: peer._asPeer(), isGlobal: false, participantCount: nil), presence, header, selection, theme, strings, dateTimeFormat, sortOrder, displayOrder, false, hasActions, true, nil, false))
642+
entries.append(.peer(index, .peer(peer: peer._asPeer(), isGlobal: false, participantCount: nil), presence, header, selection, theme, strings, dateTimeFormat, sortOrder, displayOrder, false, hasActions, true, nil, false, nil))
628643

629644
index += 1
630645
}
@@ -675,7 +690,7 @@ private func contactListNodeEntries(accountPeer: EnginePeer?, peers: [ContactLis
675690
let presence = presences[peer.id]
676691
entries.append(.peer(index, .peer(peer: peer._asPeer(), isGlobal: false, participantCount: nil), presence, header, selection, theme, strings, dateTimeFormat, sortOrder, displayOrder, false, false, true, peersWithStories[peer.id].flatMap {
677692
ContactListNodeEntry.StoryData(count: $0.totalCount, unseenCount: $0.unseenCount, hasUnseenCloseFriends: $0.hasUnseenCloseFriends)
678-
}, false))
693+
}, false, nil))
679694

680695
index += 1
681696
}
@@ -726,7 +741,7 @@ private func contactListNodeEntries(accountPeer: EnginePeer?, peers: [ContactLis
726741
}
727742
}
728743

729-
entries.append(.peer(index, peer, presence, nil, selection, theme, strings, dateTimeFormat, sortOrder, displayOrder, displayCallIcons, false, enabled, storyData, false))
744+
entries.append(.peer(index, peer, presence, nil, selection, theme, strings, dateTimeFormat, sortOrder, displayOrder, displayCallIcons, false, enabled, storyData, false, nil))
730745
index += 1
731746
}
732747
}
@@ -779,7 +794,7 @@ private func contactListNodeEntries(accountPeer: EnginePeer?, peers: [ContactLis
779794
}
780795
}
781796

782-
entries.append(.peer(index, peer, presence, header, selection, theme, strings, dateTimeFormat, sortOrder, displayOrder, displayCallIcons, false, enabled, storyData, requiresPremiumForMessaging))
797+
entries.append(.peer(index, peer, presence, header, selection, theme, strings, dateTimeFormat, sortOrder, displayOrder, displayCallIcons, false, enabled, storyData, requiresPremiumForMessaging, nil))
783798
index += 1
784799
}
785800
return entries
@@ -803,7 +818,7 @@ private func preparedContactListNodeTransition(context: AccountContext, presenta
803818
case .search:
804819
//indexSections.apend(CollectionIndexNode.searchIndex)
805820
break
806-
case let .peer(_, _, _, header, _, _, _, _, _, _, _, _, _, _, _):
821+
case let .peer(_, _, _, header, _, _, _, _, _, _, _, _, _, _, _, _):
807822
if let header = header as? ContactListNameIndexHeader {
808823
if !existingSections.contains(header.letter) {
809824
existingSections.insert(header.letter)
@@ -872,7 +887,7 @@ public enum ContactListPresentation {
872887
public enum TopPeers {
873888
case none
874889
case recent
875-
case custom([(title: String, peerIds: [EnginePeer.Id], hasActions: Bool)])
890+
case custom(showSelf: Bool, sections: [(title: String, peerIds: [EnginePeer.Id], hasActions: Bool)])
876891
}
877892

878893
case orderedByPresence(options: [ContactListAdditionalOption])
@@ -1284,7 +1299,7 @@ public final class ContactListNode: ASDisplayNode {
12841299
strongSelf.listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.PreferSynchronousDrawing, .PreferSynchronousResourceLoading], scrollToItem: ListViewScrollToItem(index: index, position: .top(-navigationBarSearchContentHeight), animated: false, curve: .Default(duration: nil), directionHint: .Down), additionalScrollDistance: 0.0, updateSizeAndInsets: updateSizeAndInsets, stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in })
12851300
break loop
12861301
}
1287-
case let .peer(_, _, _, header, _, _, _, _, _, _, _, _, _, _, _):
1302+
case let .peer(_, _, _, header, _, _, _, _, _, _, _, _, _, _, _, _):
12881303
if let header = header as? ContactListNameIndexHeader {
12891304
if let scalar = UnicodeScalar(header.letter) {
12901305
let title = "\(Character(scalar))"
@@ -1718,8 +1733,11 @@ public final class ContactListNode: ASDisplayNode {
17181733
return .single([])
17191734
}
17201735
}
1721-
case let .custom(sections):
1736+
case let .custom(showSelf, sections):
17221737
var peerIds: [EnginePeer.Id] = []
1738+
if showSelf {
1739+
peerIds.append(context.account.peerId)
1740+
}
17231741
for (_, sectionPeers, _) in sections {
17241742
peerIds.append(contentsOf: sectionPeers)
17251743
}

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,10 +1729,18 @@ public class GiftViewScreen: ViewControllerComponentContainer {
17291729
switch action.action {
17301730
case let .starGift(gift, convertStars, text, entities, nameHidden, savedToProfile, converted, upgraded, canUpgrade, upgradeStars, _, upgradeMessageId):
17311731
return (message.id.peerId, message.author?.id, message.author?.compactDisplayTitle, message.id, message.flags.contains(.Incoming), gift, message.timestamp, convertStars, text, entities, nameHidden, savedToProfile, converted, upgraded, canUpgrade, upgradeStars, nil, nil, upgradeMessageId)
1732-
case let .starGiftUnique(gift, isUpgrade, _, savedToProfile, canExportDate, transferStars, _):
1733-
var incoming = message.flags.contains(.Incoming)
1734-
if isUpgrade && message.author?.id != message.id.peerId {
1735-
incoming = true
1732+
case let .starGiftUnique(gift, isUpgrade, isTransferred, savedToProfile, canExportDate, transferStars, _):
1733+
var incoming = false
1734+
if isUpgrade {
1735+
if message.author?.id != message.id.peerId {
1736+
incoming = true
1737+
}
1738+
} else if isTransferred {
1739+
if message.author?.id != message.id.peerId {
1740+
incoming = true
1741+
}
1742+
} else {
1743+
incoming = message.flags.contains(.Incoming)
17361744
}
17371745
return (message.id.peerId, message.author?.id, message.author?.compactDisplayTitle, message.id, incoming, gift, message.timestamp, nil, nil, nil, false, savedToProfile, false, false, false, nil, transferStars, canExportDate, nil)
17381746
default:

0 commit comments

Comments
 (0)