Skip to content

Commit edecdd7

Browse files
committed
Various fixes
1 parent f75bea1 commit edecdd7

File tree

24 files changed

+181
-94
lines changed

24 files changed

+181
-94
lines changed

submodules/AuthorizationUI/Sources/AuthorizationSequenceController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
351351
|> deliverOnMainQueue).startStrict(error: { [weak self] error in
352352
if let self, case .alreadyInProgress = error {
353353
let formattedNumber = formatPhoneNumber(number)
354-
let title = NSAttributedString(string: self.presentationData.strings.Login_Email_PremiumRequiredTitle, font: Font.semibold(self.presentationData.listsFontSize.baseDisplaySize), textColor: self.presentationData.theme.actionSheet.primaryTextColor)
354+
let title = NSAttributedString(string: self.presentationData.strings.Login_Email_PremiumRequiredTitle, font: Font.semibold(self.presentationData.listsFontSize.baseDisplaySize), textColor: self.presentationData.theme.actionSheet.primaryTextColor, paragraphAlignment: .center)
355355
let text = parseMarkdownIntoAttributedString(self.presentationData.strings.Login_Email_PremiumRequiredText(formattedNumber).string, attributes: MarkdownAttributes(body: body, bold: bold, link: body, linkAttribute: { _ in nil }), textAlignment: .center).mutableCopy() as! NSMutableAttributedString
356356

357357
let alertController = textWithEntitiesAlertController(theme: AlertControllerTheme(presentationData: self.presentationData), title: title, text: text, actions: [TextAlertAction(type: .genericAction, title: self.presentationData.strings.Common_OK, action: { })])

submodules/BrowserUI/Sources/BrowserWebContent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,10 +1722,10 @@ function tgBrowserHandleMutations(mutations) {
17221722
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
17231723
mutation.addedNodes.forEach((newNode) => {
17241724
if (newNode.tagName === 'VIDEO') {
1725-
disableWebkitEnterFullscreen(newNode);
1725+
tgBrowserDisableWebkitEnterFullscreen(newNode);
17261726
}
17271727
if (newNode.querySelectorAll) {
1728-
newNode.querySelectorAll('video').forEach(disableWebkitEnterFullscreen);
1728+
newNode.querySelectorAll('video').forEach(tgBrowserDisableWebkitEnterFullscreen);
17291729
}
17301730
});
17311731
}

submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ private final class ChannelPermissionsControllerArguments {
3737
let openChannelExample: () -> Void
3838
let updateSlowmode: (Int32) -> Void
3939
let updateUnrestrictBoosters: (Int32) -> Void
40-
let updateStarsAmount: (StarsAmount?) -> Void
40+
let updateStarsAmount: (StarsAmount?, Bool) -> Void
4141
let toggleIsOptionExpanded: (TelegramChatBannedRightsFlags) -> Void
4242

43-
init(context: AccountContext, updatePermission: @escaping (TelegramChatBannedRightsFlags, Bool) -> Void, setPeerIdWithRevealedOptions: @escaping (EnginePeer.Id?, EnginePeer.Id?) -> Void, addPeer: @escaping () -> Void, removePeer: @escaping (EnginePeer.Id) -> Void, openPeer: @escaping (ChannelParticipant) -> Void, openPeerInfo: @escaping (EnginePeer) -> Void, openKicked: @escaping () -> Void, presentRestrictedPermissionAlert: @escaping (TelegramChatBannedRightsFlags) -> Void, presentConversionToBroadcastGroup: @escaping () -> Void, openChannelExample: @escaping () -> Void, updateSlowmode: @escaping (Int32) -> Void, updateUnrestrictBoosters: @escaping (Int32) -> Void, updateStarsAmount: @escaping (StarsAmount?) -> Void, toggleIsOptionExpanded: @escaping (TelegramChatBannedRightsFlags) -> Void) {
43+
init(context: AccountContext, updatePermission: @escaping (TelegramChatBannedRightsFlags, Bool) -> Void, setPeerIdWithRevealedOptions: @escaping (EnginePeer.Id?, EnginePeer.Id?) -> Void, addPeer: @escaping () -> Void, removePeer: @escaping (EnginePeer.Id) -> Void, openPeer: @escaping (ChannelParticipant) -> Void, openPeerInfo: @escaping (EnginePeer) -> Void, openKicked: @escaping () -> Void, presentRestrictedPermissionAlert: @escaping (TelegramChatBannedRightsFlags) -> Void, presentConversionToBroadcastGroup: @escaping () -> Void, openChannelExample: @escaping () -> Void, updateSlowmode: @escaping (Int32) -> Void, updateUnrestrictBoosters: @escaping (Int32) -> Void, updateStarsAmount: @escaping (StarsAmount?, Bool) -> Void, toggleIsOptionExpanded: @escaping (TelegramChatBannedRightsFlags) -> Void) {
4444
self.context = context
4545
self.updatePermission = updatePermission
4646
self.addPeer = addPeer
@@ -418,15 +418,15 @@ private enum ChannelPermissionsEntry: ItemListNodeEntry {
418418
}
419419
case let .chargeForMessages(_, title, value):
420420
return ItemListSwitchItem(presentationData: presentationData, title: title, value: value, sectionId: self.section, style: .blocks, updated: { value in
421-
arguments.updateStarsAmount(value ? StarsAmount(value: 400, nanos: 0) : nil)
421+
arguments.updateStarsAmount(value ? StarsAmount(value: 400, nanos: 0) : nil, true)
422422
})
423423
case let .chargeForMessagesInfo(_, value):
424424
return ItemListTextItem(presentationData: presentationData, text: .plain(value), sectionId: self.section)
425425
case let .messagePriceHeader(_, value):
426426
return ItemListSectionHeaderItem(presentationData: presentationData, text: value, sectionId: self.section)
427427
case let .messagePrice(_, value, maxValue, price):
428-
return MessagePriceItem(theme: presentationData.theme, strings: presentationData.strings, isEnabled: true, minValue: 1, maxValue: maxValue, value: value, price: price, sectionId: self.section, updated: { value in
429-
arguments.updateStarsAmount(StarsAmount(value: value, nanos: 0))
428+
return MessagePriceItem(theme: presentationData.theme, strings: presentationData.strings, isEnabled: true, minValue: 1, maxValue: maxValue, value: value, price: price, sectionId: self.section, updated: { value, apply in
429+
arguments.updateStarsAmount(StarsAmount(value: value, nanos: 0), apply)
430430
})
431431
case let .messagePriceInfo(_, value):
432432
return ItemListTextItem(presentationData: presentationData, text: .plain(value), sectionId: self.section)
@@ -1248,23 +1248,25 @@ public func channelPermissionsController(context: AccountContext, updatedPresent
12481248
updateUnrestrictBoostersDisposable.set((context.engine.peers.updateChannelBoostsToUnlockRestrictions(peerId: view.peerId, boosts: value)
12491249
|> deliverOnMainQueue).start())
12501250
})
1251-
}, updateStarsAmount: { value in
1251+
}, updateStarsAmount: { value, apply in
12521252
updateState { state in
12531253
var state = state
12541254
state.modifiedStarsAmount = value
12551255
return state
12561256
}
12571257

1258-
let _ = (peerView.get()
1259-
|> take(1)
1260-
|> deliverOnMainQueue).start(next: { view in
1261-
var effectiveValue = value
1262-
if value?.value == 0 {
1263-
effectiveValue = nil
1264-
}
1265-
updateSendPaidMessageStarsDisposable.set((context.engine.peers.updateChannelPaidMessagesStars(peerId: view.peerId, stars: effectiveValue)
1266-
|> deliverOnMainQueue).start())
1267-
})
1258+
if apply {
1259+
let _ = (peerView.get()
1260+
|> take(1)
1261+
|> deliverOnMainQueue).start(next: { view in
1262+
var effectiveValue = value
1263+
if value?.value == 0 {
1264+
effectiveValue = nil
1265+
}
1266+
updateSendPaidMessageStarsDisposable.set((context.engine.peers.updateChannelPaidMessagesStars(peerId: view.peerId, stars: effectiveValue)
1267+
|> deliverOnMainQueue).start())
1268+
})
1269+
}
12681270
}, toggleIsOptionExpanded: { flags in
12691271
updateState { state in
12701272
var state = state

submodules/SettingsUI/Sources/Privacy and Security/IncomingMessagePrivacyScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private enum GlobalAutoremoveEntry: ItemListNodeEntry {
149149
case .priceHeader:
150150
return ItemListSectionHeaderItem(presentationData: presentationData, text: presentationData.strings.Privacy_Messages_MessagePrice, sectionId: self.section)
151151
case let .price(value, maxValue, price, isEnabled):
152-
return MessagePriceItem(theme: presentationData.theme, strings: presentationData.strings, isEnabled: isEnabled, minValue: 1, maxValue: maxValue, value: value, price: price, sectionId: self.section, updated: { value in
152+
return MessagePriceItem(theme: presentationData.theme, strings: presentationData.strings, isEnabled: isEnabled, minValue: 1, maxValue: maxValue, value: value, price: price, sectionId: self.section, updated: { value, _ in
153153
arguments.updateValue(.paidMessages(StarsAmount(value: value, nanos: 0)))
154154
}, openPremiumInfo: {
155155
arguments.openPremiumInfo()

submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,10 @@ private final class ProfileGiftsContextImpl {
10161016
let sorting = self.sorting
10171017

10181018
let isFiltered = self.filter != .All || self.sorting != .date
1019-
1019+
if !isFiltered {
1020+
self.filteredGifts = []
1021+
self.filteredCount = nil
1022+
}
10201023
let dataState = isFiltered ? self.filteredDataState : self.dataState
10211024

10221025
if case let .ready(true, initialNextOffset) = dataState {
@@ -1202,7 +1205,6 @@ private final class ProfileGiftsContextImpl {
12021205
}
12031206
}
12041207
let existingGifts = Set(pinnedGifts.compactMap { $0.reference })
1205-
12061208
var updatedGifts: [ProfileGiftsContext.State.StarGift] = []
12071209
for gift in self.gifts {
12081210
if let reference = gift.reference, existingGifts.contains(reference) {
@@ -1216,18 +1218,44 @@ private final class ProfileGiftsContextImpl {
12161218
updatedGifts.insert(contentsOf: pinnedGifts, at: 0)
12171219
self.gifts = updatedGifts
12181220

1219-
if let index = self.filteredGifts.firstIndex(where: { $0.reference == reference }) {
1220-
self.filteredGifts[index] = self.filteredGifts[index].withPinnedToTop(pinnedToTop)
1221+
var effectiveReferences = pinnedGifts.compactMap { $0.reference }
1222+
if !self.filteredGifts.isEmpty {
1223+
var filteredPinnedGifts = self.filteredGifts.filter { $0.pinnedToTop }
1224+
if var gift = self.filteredGifts.first(where: { $0.reference == reference }) {
1225+
gift = gift.withPinnedToTop(pinnedToTop)
1226+
if pinnedToTop {
1227+
if !gift.savedToProfile {
1228+
gift = gift.withSavedToProfile(true)
1229+
}
1230+
filteredPinnedGifts.append(gift)
1231+
} else {
1232+
filteredPinnedGifts.removeAll(where: { $0.reference == reference })
1233+
}
1234+
}
1235+
let existingFilteredGifts = Set(filteredPinnedGifts.compactMap { $0.reference })
1236+
var updatedFilteredGifts: [ProfileGiftsContext.State.StarGift] = []
1237+
for gift in self.filteredGifts {
1238+
if let reference = gift.reference, existingFilteredGifts.contains(reference) {
1239+
continue
1240+
}
1241+
updatedFilteredGifts.append(gift)
1242+
}
1243+
updatedFilteredGifts.sort { lhs, rhs in
1244+
lhs.date > rhs.date
1245+
}
1246+
updatedFilteredGifts.insert(contentsOf: filteredPinnedGifts, at: 0)
1247+
self.filteredGifts = updatedFilteredGifts
1248+
1249+
effectiveReferences = filteredPinnedGifts.compactMap { $0.reference }
12211250
}
1251+
12221252
self.pushState()
12231253

1224-
var signal = _internal_updateStarGiftsPinnedToTop(account: self.account, peerId: self.peerId, references: pinnedGifts.compactMap { $0.reference })
1225-
1254+
var signal = _internal_updateStarGiftsPinnedToTop(account: self.account, peerId: self.peerId, references: effectiveReferences)
12261255
if saveToProfile {
12271256
signal = _internal_updateStarGiftAddedToProfile(account: self.account, reference: reference, added: true)
12281257
|> then(signal)
12291258
}
1230-
12311259
self.actionDisposable.set(
12321260
(signal |> deliverOn(self.queue)).startStrict(completed: { [weak self] in
12331261
self?.reload()
@@ -1279,7 +1307,6 @@ private final class ProfileGiftsContextImpl {
12791307
|> ignoreValues
12801308
|> then(signal)
12811309
}
1282-
12831310
self.actionDisposable.set(
12841311
(signal |> deliverOn(self.queue)).startStrict(completed: { [weak self] in
12851312
self?.reload()
@@ -1349,6 +1376,9 @@ private final class ProfileGiftsContextImpl {
13491376
}
13501377

13511378
func updateFilter(_ filter: ProfileGiftsContext.Filters) {
1379+
guard self.filter != filter else {
1380+
return
1381+
}
13521382
self.filter = filter
13531383
self.filteredDataState = .ready(canLoadMore: true, nextOffset: nil)
13541384
self.pushState()
@@ -1357,6 +1387,9 @@ private final class ProfileGiftsContextImpl {
13571387
}
13581388

13591389
func updateSorting(_ sorting: ProfileGiftsContext.Sorting) {
1390+
guard self.sorting != sorting else {
1391+
return
1392+
}
13601393
self.sorting = sorting
13611394
self.filteredDataState = .ready(canLoadMore: true, nextOffset: nil)
13621395
self.pushState()

submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
11481148
case let .starGiftUnique(gift, isUpgrade, _, _, _, _, _, peerId, senderId, _):
11491149
if case let .unique(gift) = gift {
11501150
if !forAdditionalServiceMessage && !"".isEmpty {
1151-
attributedString = NSAttributedString(string: "\(gift.title) #\(gift.number)", font: titleFont, textColor: primaryTextColor)
1151+
attributedString = NSAttributedString(string: "\(gift.title) #\(presentationStringsFormattedNumber(gift.number, dateTimeFormat.groupingSeparator))", font: titleFont, textColor: primaryTextColor)
11521152
} else if let messagePeer = message.peers[message.id.peerId] {
11531153
var peerName = EnginePeer(messagePeer).compactDisplayTitle
11541154
var peerIds: [(Int, EnginePeer.Id?)] = [(0, messagePeer.id)]

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,7 +2968,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
29682968
} else {
29692969
let contentProperties = contentPropertiesAndLayouts[i].3
29702970

2971-
if i == 0 && !headerSize.height.isZero {
2971+
if (i == 0 || (i == 1 && detachedContentNodesHeight > 0)) && !headerSize.height.isZero {
29722972
if contentGroupId == nil {
29732973
contentNodesHeight += properties.headerSpacing
29742974
}
@@ -2981,7 +2981,15 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
29812981
if !contentContainerNodeFrames.isEmpty {
29822982
overlapOffset = currentContainerGroupOverlap
29832983
}
2984-
let containerFrame = CGRect(x: 0.0, y: headerSize.height + totalContentNodesHeight - contentNodesHeight - overlapOffset, width: maxContentWidth, height: contentNodesHeight)
2984+
var containerContentNodesOrigin = contentNodesHeight
2985+
var containerContentNodesHeight = contentNodesHeight
2986+
if detachedContentNodesHeight > 0 {
2987+
if contentContainerNodeFrames.isEmpty {
2988+
containerContentNodesHeight -= detachedContentNodesHeight - 4.0
2989+
containerContentNodesOrigin -= detachedContentNodesHeight - 4.0
2990+
}
2991+
}
2992+
let containerFrame = CGRect(x: 0.0, y: headerSize.height + totalContentNodesHeight - containerContentNodesOrigin - overlapOffset, width: maxContentWidth, height: containerContentNodesHeight)
29852993
contentContainerNodeFrames.append((containerGroupId, containerFrame, currentItemSelection, currentContainerGroupOverlap))
29862994

29872995
if !overlapOffset.isZero {
@@ -2997,7 +3005,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
29973005
}
29983006

29993007
var contentNodeOriginY = contentNodesHeight
3000-
if detachedContentNodesHeight > 0 {
3008+
if detachedContentNodesHeight > 0, contentContainerNodeFrames.isEmpty {
30013009
contentNodeOriginY -= detachedContentNodesHeight - 4.0
30023010
}
30033011

@@ -3025,7 +3033,15 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
30253033
if !contentContainerNodeFrames.isEmpty {
30263034
overlapOffset = currentContainerGroupOverlap
30273035
}
3028-
contentContainerNodeFrames.append((containerGroupId, CGRect(x: 0.0, y: headerSize.height + totalContentNodesHeight - contentNodesHeight - overlapOffset, width: maxContentWidth, height: contentNodesHeight), currentItemSelection, currentContainerGroupOverlap))
3036+
var containerContentNodesOrigin = contentNodesHeight
3037+
var containerContentNodesHeight = contentNodesHeight
3038+
if detachedContentNodesHeight > 0 {
3039+
if contentContainerNodeFrames.isEmpty {
3040+
containerContentNodesHeight -= detachedContentNodesHeight - 4.0
3041+
containerContentNodesOrigin -= detachedContentNodesHeight - 4.0
3042+
}
3043+
}
3044+
contentContainerNodeFrames.append((containerGroupId, CGRect(x: 0.0, y: headerSize.height + totalContentNodesHeight - containerContentNodesOrigin - overlapOffset, width: maxContentWidth, height: containerContentNodesHeight), currentItemSelection, currentContainerGroupOverlap))
30293045
if !overlapOffset.isZero {
30303046
totalContentNodesHeight -= currentContainerGroupOverlap
30313047
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public final class ChatMessageCommentFooterContentNode: ChatMessageBubbleContent
213213
} else {
214214
textLeftInset = 15.0 + imageSize * min(1.0, CGFloat(replyPeers.count)) + (imageSpacing) * max(0.0, min(2.0, CGFloat(replyPeers.count - 1)))
215215
}
216-
let textRightInset: CGFloat = 36.0
216+
let textRightInset: CGFloat = 24.0
217217

218218
let textConstrainedSize = CGSize(width: min(maxTextWidth, constrainedSize.width - horizontalInset - textLeftInset - textRightInset), height: constrainedSize.height)
219219

0 commit comments

Comments
 (0)