mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
Various fixes
This commit is contained in:
parent
b6db0715d0
commit
b8a4748388
@ -14333,3 +14333,6 @@ Sorry for the inconvenience.";
|
||||
"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.Proceed" = "Proceed";
|
||||
|
||||
"Gift.Buy.ErrorTooEarly.Title" = "Try Later";
|
||||
"Gift.Buy.ErrorTooEarly.Text" = "You will be able to buy this gift on %@.";
|
||||
|
@ -338,8 +338,13 @@ final class ChatSendMessageContextScreenComponent: Component {
|
||||
guard let animateInTimestamp = self.animateInTimestamp, animateInTimestamp < CFAbsoluteTimeGetCurrent() - 0.35 else {
|
||||
return
|
||||
}
|
||||
|
||||
actionsStackNode.highlightGestureMoved(location: actionsStackNode.view.convert(location, from: view))
|
||||
let localPoint: CGPoint
|
||||
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
|
||||
guard let self, let actionsStackNode = self.actionsStackNode else {
|
||||
|
@ -1539,8 +1539,10 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
strongSelf.videoNode?.playOnceWithSound(playAndRecord: false, seek: .none, actionAtEnd: isAnimated ? .loop : strongSelf.actionAtEnd)
|
||||
}
|
||||
|
||||
if let playbackRate = strongSelf.playbackRate {
|
||||
strongSelf.videoNode?.setBaseRate(playbackRate)
|
||||
Queue.mainQueue().after(0.1) {
|
||||
if let playbackRate = strongSelf.playbackRate {
|
||||
strongSelf.videoNode?.setBaseRate(playbackRate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,6 +179,7 @@ public enum BotPaymentFormRequestError {
|
||||
case alreadyActive
|
||||
case noPaymentNeeded
|
||||
case disallowedStarGift
|
||||
case starGiftResellTooEarly(Int32)
|
||||
}
|
||||
|
||||
extension BotPaymentInvoice {
|
||||
@ -482,6 +483,11 @@ func _internal_fetchBotPaymentForm(accountPeerId: PeerId, postbox: Postbox, netw
|
||||
return .fail(.noPaymentNeeded)
|
||||
} else if error.errorDescription == "USER_DISALLOWED_STARGIFTS" {
|
||||
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)
|
||||
}
|
||||
|
@ -855,6 +855,7 @@ public enum TransferStarGiftError {
|
||||
public enum BuyStarGiftError {
|
||||
case generic
|
||||
case priceChanged(Int64)
|
||||
case starGiftResellTooEarly(Int32)
|
||||
}
|
||||
|
||||
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)
|
||||
|> map(Optional.init)
|
||||
|> `catch` { error -> Signal<BotPaymentForm?, BuyStarGiftError> in
|
||||
if case let .starGiftResellTooEarly(timestamp) = error {
|
||||
return .fail(.starGiftResellTooEarly(timestamp))
|
||||
}
|
||||
return .fail(.generic)
|
||||
}
|
||||
|> mapToSignal { paymentForm in
|
||||
|
@ -107,6 +107,7 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
var buyForm: BotPaymentForm?
|
||||
var buyFormDisposable: Disposable?
|
||||
var buyDisposable: Disposable?
|
||||
var resellTooEarlyTimestamp: Int32?
|
||||
|
||||
var inWearPreview = false
|
||||
var pendingWear = false
|
||||
@ -180,6 +181,14 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
}
|
||||
self.buyForm = paymentForm
|
||||
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 {
|
||||
@ -871,7 +880,7 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
title = nil
|
||||
text = presentationData.strings.Gift_Send_ErrorUnknown
|
||||
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
|
||||
text = presentationData.strings.Gift_Resale_Unavailable_Text(dateString).string
|
||||
}
|
||||
@ -1150,10 +1159,28 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
return
|
||||
}
|
||||
|
||||
let giftTitle = "\(uniqueGift.title) #\(uniqueGift.number)"
|
||||
|
||||
let context = self.context
|
||||
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 action = {
|
||||
@ -1344,6 +1371,12 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
} else {
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ final class ChatbotSearchResultItemComponent: Component {
|
||||
animateScale: false
|
||||
)),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: 100.0, height: 100.0)
|
||||
containerSize: CGSize(width: 140.0, height: 100.0)
|
||||
)
|
||||
} else {
|
||||
if let addButton = self.addButton {
|
||||
|
Loading…
x
Reference in New Issue
Block a user