Various fixes

This commit is contained in:
Ilya Laktyushin 2025-05-18 04:32:32 +04:00
parent b6db0715d0
commit b8a4748388
7 changed files with 61 additions and 8 deletions

View File

@ -14333,3 +14333,6 @@ Sorry for the inconvenience.";
"ChatbotSetup.Gift.Warning.StarsText" = "The bot **%@** will be able to **transfer your stars**."; "ChatbotSetup.Gift.Warning.StarsText" = "The bot **%@** will be able to **transfer your stars**.";
"ChatbotSetup.Gift.Warning.UsernameText" = "The bot **%@** will be able to **set and remove usernames** for your account, which may result in the loss of your current username."; "ChatbotSetup.Gift.Warning.UsernameText" = "The bot **%@** will be able to **set and remove usernames** for your account, which may result in the loss of your current username.";
"ChatbotSetup.Gift.Warning.Proceed" = "Proceed"; "ChatbotSetup.Gift.Warning.Proceed" = "Proceed";
"Gift.Buy.ErrorTooEarly.Title" = "Try Later";
"Gift.Buy.ErrorTooEarly.Text" = "You will be able to buy this gift on %@.";

View File

@ -338,8 +338,13 @@ final class ChatSendMessageContextScreenComponent: Component {
guard let animateInTimestamp = self.animateInTimestamp, animateInTimestamp < CFAbsoluteTimeGetCurrent() - 0.35 else { guard let animateInTimestamp = self.animateInTimestamp, animateInTimestamp < CFAbsoluteTimeGetCurrent() - 0.35 else {
return return
} }
let localPoint: CGPoint
actionsStackNode.highlightGestureMoved(location: actionsStackNode.view.convert(location, from: view)) if let metrics = self.environment?.metrics, metrics.isTablet, availableSize.width > availableSize.height, let view {
localPoint = view.convert(location, to: nil)
} else {
localPoint = self.convert(location, from: view)
}
actionsStackNode.highlightGestureMoved(location: self.convert(localPoint, to: actionsStackNode.view))
} }
component.gesture.externalEnded = { [weak self] viewAndLocation in component.gesture.externalEnded = { [weak self] viewAndLocation in
guard let self, let actionsStackNode = self.actionsStackNode else { guard let self, let actionsStackNode = self.actionsStackNode else {

View File

@ -1539,12 +1539,14 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
strongSelf.videoNode?.playOnceWithSound(playAndRecord: false, seek: .none, actionAtEnd: isAnimated ? .loop : strongSelf.actionAtEnd) strongSelf.videoNode?.playOnceWithSound(playAndRecord: false, seek: .none, actionAtEnd: isAnimated ? .loop : strongSelf.actionAtEnd)
} }
Queue.mainQueue().after(0.1) {
if let playbackRate = strongSelf.playbackRate { if let playbackRate = strongSelf.playbackRate {
strongSelf.videoNode?.setBaseRate(playbackRate) strongSelf.videoNode?.setBaseRate(playbackRate)
} }
} }
} }
} }
}
self.videoNode = videoNode self.videoNode = videoNode
self.videoNodeUserInteractionEnabled = disablePlayerControls || forceEnableUserInteraction self.videoNodeUserInteractionEnabled = disablePlayerControls || forceEnableUserInteraction
videoNode.isUserInteractionEnabled = disablePlayerControls || forceEnableUserInteraction videoNode.isUserInteractionEnabled = disablePlayerControls || forceEnableUserInteraction

View File

@ -179,6 +179,7 @@ public enum BotPaymentFormRequestError {
case alreadyActive case alreadyActive
case noPaymentNeeded case noPaymentNeeded
case disallowedStarGift case disallowedStarGift
case starGiftResellTooEarly(Int32)
} }
extension BotPaymentInvoice { extension BotPaymentInvoice {
@ -482,6 +483,11 @@ func _internal_fetchBotPaymentForm(accountPeerId: PeerId, postbox: Postbox, netw
return .fail(.noPaymentNeeded) return .fail(.noPaymentNeeded)
} else if error.errorDescription == "USER_DISALLOWED_STARGIFTS" { } else if error.errorDescription == "USER_DISALLOWED_STARGIFTS" {
return .fail(.disallowedStarGift) return .fail(.disallowedStarGift)
} else if error.errorDescription.hasPrefix("STARGIFT_RESELL_TOO_EARLY_") {
let timeout = String(error.errorDescription[error.errorDescription.index(error.errorDescription.startIndex, offsetBy: "STARGIFT_RESELL_TOO_EARLY_".count)...])
if let value = Int32(timeout) {
return .fail(.starGiftResellTooEarly(value))
}
} }
return .fail(.generic) return .fail(.generic)
} }

View File

@ -855,6 +855,7 @@ public enum TransferStarGiftError {
public enum BuyStarGiftError { public enum BuyStarGiftError {
case generic case generic
case priceChanged(Int64) case priceChanged(Int64)
case starGiftResellTooEarly(Int32)
} }
public enum UpdateStarGiftPriceError { public enum UpdateStarGiftPriceError {
@ -871,6 +872,9 @@ func _internal_buyStarGift(account: Account, slug: String, peerId: EnginePeer.Id
return _internal_fetchBotPaymentForm(accountPeerId: account.peerId, postbox: account.postbox, network: account.network, source: source, themeParams: nil) return _internal_fetchBotPaymentForm(accountPeerId: account.peerId, postbox: account.postbox, network: account.network, source: source, themeParams: nil)
|> map(Optional.init) |> map(Optional.init)
|> `catch` { error -> Signal<BotPaymentForm?, BuyStarGiftError> in |> `catch` { error -> Signal<BotPaymentForm?, BuyStarGiftError> in
if case let .starGiftResellTooEarly(timestamp) = error {
return .fail(.starGiftResellTooEarly(timestamp))
}
return .fail(.generic) return .fail(.generic)
} }
|> mapToSignal { paymentForm in |> mapToSignal { paymentForm in

View File

@ -107,6 +107,7 @@ private final class GiftViewSheetContent: CombinedComponent {
var buyForm: BotPaymentForm? var buyForm: BotPaymentForm?
var buyFormDisposable: Disposable? var buyFormDisposable: Disposable?
var buyDisposable: Disposable? var buyDisposable: Disposable?
var resellTooEarlyTimestamp: Int32?
var inWearPreview = false var inWearPreview = false
var pendingWear = false var pendingWear = false
@ -180,6 +181,14 @@ private final class GiftViewSheetContent: CombinedComponent {
} }
self.buyForm = paymentForm self.buyForm = paymentForm
self.updated() self.updated()
}, error: { [weak self] error in
guard let self else {
return
}
if case let .starGiftResellTooEarly(remaining) = error {
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
self.resellTooEarlyTimestamp = currentTime + remaining
}
}) })
} }
} else if case let .generic(gift) = arguments.gift { } else if case let .generic(gift) = arguments.gift {
@ -871,7 +880,7 @@ private final class GiftViewSheetContent: CombinedComponent {
title = nil title = nil
text = presentationData.strings.Gift_Send_ErrorUnknown text = presentationData.strings.Gift_Send_ErrorUnknown
case let .starGiftResellTooEarly(canResaleDate): case let .starGiftResellTooEarly(canResaleDate):
let dateString = stringForFullDate(timestamp: canResaleDate, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat) let dateString = stringForFullDate(timestamp: currentTime + canResaleDate, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat)
title = presentationData.strings.Gift_Resale_Unavailable_Title title = presentationData.strings.Gift_Resale_Unavailable_Title
text = presentationData.strings.Gift_Resale_Unavailable_Text(dateString).string text = presentationData.strings.Gift_Resale_Unavailable_Text(dateString).string
} }
@ -1150,10 +1159,28 @@ private final class GiftViewSheetContent: CombinedComponent {
return return
} }
let giftTitle = "\(uniqueGift.title) #\(uniqueGift.number)"
let context = self.context let context = self.context
let presentationData = context.sharedContext.currentPresentationData.with { $0 } let presentationData = context.sharedContext.currentPresentationData.with { $0 }
if let resellTooEarlyTimestamp = self.resellTooEarlyTimestamp {
guard let controller = self.getController() else {
return
}
let dateString = stringForFullDate(timestamp: resellTooEarlyTimestamp, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat)
let alertController = textAlertController(
context: context,
title: presentationData.strings.Gift_Buy_ErrorTooEarly_Title,
text: presentationData.strings.Gift_Buy_ErrorTooEarly_Text(dateString).string,
actions: [
TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})
],
parseMarkdown: true
)
controller.present(alertController, in: .window(.root))
return
}
let giftTitle = "\(uniqueGift.title) #\(uniqueGift.number)"
let recipientPeerId = self.recipientPeerId ?? self.context.account.peerId let recipientPeerId = self.recipientPeerId ?? self.context.account.peerId
let action = { let action = {
@ -1344,6 +1371,12 @@ private final class GiftViewSheetContent: CombinedComponent {
} else { } else {
proceed() proceed()
} }
} else {
guard let controller = self.getController() else {
return
}
let alertController = textAlertController(context: context, title: nil, text: presentationData.strings.Gift_Buy_ErrorUnknown, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})], parseMarkdown: true)
controller.present(alertController, in: .window(.root))
} }
} }

View File

@ -128,7 +128,7 @@ final class ChatbotSearchResultItemComponent: Component {
animateScale: false animateScale: false
)), )),
environment: {}, environment: {},
containerSize: CGSize(width: 100.0, height: 100.0) containerSize: CGSize(width: 140.0, height: 100.0)
) )
} else { } else {
if let addButton = self.addButton { if let addButton = self.addButton {