Skip to content

Commit e5762bd

Browse files
committed
Various fixes
1 parent 3b7ddc3 commit e5762bd

File tree

13 files changed

+80
-32
lines changed

13 files changed

+80
-32
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14333,3 +14333,6 @@ Sorry for the inconvenience.";
1433314333
"ChatbotSetup.Gift.Warning.StarsText" = "The bot **%@** will be able to **transfer your stars**.";
1433414334
"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.";
1433514335
"ChatbotSetup.Gift.Warning.Proceed" = "Proceed";
14336+
14337+
"Gift.Buy.ErrorTooEarly.Title" = "Try Later";
14338+
"Gift.Buy.ErrorTooEarly.Text" = "You will be able to buy this gift on %@.";

submodules/ChatSendMessageActionUI/Sources/ChatSendMessageContextScreen.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,13 @@ final class ChatSendMessageContextScreenComponent: Component {
338338
guard let animateInTimestamp = self.animateInTimestamp, animateInTimestamp < CFAbsoluteTimeGetCurrent() - 0.35 else {
339339
return
340340
}
341-
342-
actionsStackNode.highlightGestureMoved(location: actionsStackNode.view.convert(location, from: view))
341+
let localPoint: CGPoint
342+
if let metrics = self.environment?.metrics, metrics.isTablet, availableSize.width > availableSize.height, let view {
343+
localPoint = view.convert(location, to: nil)
344+
} else {
345+
localPoint = self.convert(location, from: view)
346+
}
347+
actionsStackNode.highlightGestureMoved(location: self.convert(localPoint, to: actionsStackNode.view))
343348
}
344349
component.gesture.externalEnded = { [weak self] viewAndLocation in
345350
guard let self, let actionsStackNode = self.actionsStackNode else {

submodules/DrawingUI/Sources/DrawingEntitiesView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
109109

110110
public var onInteractionUpdated: (Bool) -> Void = { _ in }
111111
public var edgePreviewUpdated: (Bool) -> Void = { _ in }
112+
public var onTextEditingEnded: (Bool) -> Void = { _ in }
112113

113114
private let hapticFeedback = HapticFeedback()
114115

submodules/DrawingUI/Sources/DrawingScreen.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3078,6 +3078,11 @@ public final class DrawingToolsInteraction {
30783078
self.onInteractionUpdated(isInteracting)
30793079
}
30803080
}
3081+
self.entitiesView.onTextEditingEnded = { [weak self] reset in
3082+
if let self {
3083+
self.onTextEditingEnded(reset)
3084+
}
3085+
}
30813086
self.entitiesView.requestedMenuForEntityView = { [weak self] entityView, isTopmost in
30823087
guard let self, let node = self.getControllerNode() else {
30833088
return
@@ -3267,7 +3272,6 @@ public final class DrawingToolsInteraction {
32673272
public func endTextEditing(reset: Bool) {
32683273
if let entityView = self.entitiesView.selectedEntityView as? DrawingTextEntityView {
32693274
entityView.endEditing(reset: reset)
3270-
self.onTextEditingEnded(reset)
32713275
}
32723276
}
32733277

submodules/DrawingUI/Sources/DrawingTextEntityView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ public final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate
357357
selectionView.alpha = 1.0
358358
selectionView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
359359
}
360+
361+
parentView.onTextEditingEnded(reset)
360362
}
361363

362364
func suspendEditing() {

submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,8 +1539,10 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
15391539
strongSelf.videoNode?.playOnceWithSound(playAndRecord: false, seek: .none, actionAtEnd: isAnimated ? .loop : strongSelf.actionAtEnd)
15401540
}
15411541

1542-
if let playbackRate = strongSelf.playbackRate {
1543-
strongSelf.videoNode?.setBaseRate(playbackRate)
1542+
Queue.mainQueue().after(0.1) {
1543+
if let playbackRate = strongSelf.playbackRate {
1544+
strongSelf.videoNode?.setBaseRate(playbackRate)
1545+
}
15441546
}
15451547
}
15461548
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ public enum BotPaymentFormRequestError {
179179
case alreadyActive
180180
case noPaymentNeeded
181181
case disallowedStarGift
182+
case starGiftResellTooEarly(Int32)
182183
}
183184

184185
extension BotPaymentInvoice {
@@ -482,6 +483,11 @@ func _internal_fetchBotPaymentForm(accountPeerId: PeerId, postbox: Postbox, netw
482483
return .fail(.noPaymentNeeded)
483484
} else if error.errorDescription == "USER_DISALLOWED_STARGIFTS" {
484485
return .fail(.disallowedStarGift)
486+
} else if error.errorDescription.hasPrefix("STARGIFT_RESELL_TOO_EARLY_") {
487+
let timeout = String(error.errorDescription[error.errorDescription.index(error.errorDescription.startIndex, offsetBy: "STARGIFT_RESELL_TOO_EARLY_".count)...])
488+
if let value = Int32(timeout) {
489+
return .fail(.starGiftResellTooEarly(value))
490+
}
485491
}
486492
return .fail(.generic)
487493
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ public enum TransferStarGiftError {
855855
public enum BuyStarGiftError {
856856
case generic
857857
case priceChanged(Int64)
858+
case starGiftResellTooEarly(Int32)
858859
}
859860

860861
public enum UpdateStarGiftPriceError {
@@ -871,6 +872,9 @@ func _internal_buyStarGift(account: Account, slug: String, peerId: EnginePeer.Id
871872
return _internal_fetchBotPaymentForm(accountPeerId: account.peerId, postbox: account.postbox, network: account.network, source: source, themeParams: nil)
872873
|> map(Optional.init)
873874
|> `catch` { error -> Signal<BotPaymentForm?, BuyStarGiftError> in
875+
if case let .starGiftResellTooEarly(timestamp) = error {
876+
return .fail(.starGiftResellTooEarly(timestamp))
877+
}
874878
return .fail(.generic)
875879
}
876880
|> mapToSignal { paymentForm in

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

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ private final class GiftViewSheetContent: CombinedComponent {
107107
var buyForm: BotPaymentForm?
108108
var buyFormDisposable: Disposable?
109109
var buyDisposable: Disposable?
110+
var resellTooEarlyTimestamp: Int32?
110111

111112
var inWearPreview = false
112113
var pendingWear = false
@@ -180,6 +181,14 @@ private final class GiftViewSheetContent: CombinedComponent {
180181
}
181182
self.buyForm = paymentForm
182183
self.updated()
184+
}, error: { [weak self] error in
185+
guard let self else {
186+
return
187+
}
188+
if case let .starGiftResellTooEarly(remaining) = error {
189+
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
190+
self.resellTooEarlyTimestamp = currentTime + remaining
191+
}
183192
})
184193
}
185194
} else if case let .generic(gift) = arguments.gift {
@@ -871,7 +880,7 @@ private final class GiftViewSheetContent: CombinedComponent {
871880
title = nil
872881
text = presentationData.strings.Gift_Send_ErrorUnknown
873882
case let .starGiftResellTooEarly(canResaleDate):
874-
let dateString = stringForFullDate(timestamp: canResaleDate, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat)
883+
let dateString = stringForFullDate(timestamp: currentTime + canResaleDate, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat)
875884
title = presentationData.strings.Gift_Resale_Unavailable_Title
876885
text = presentationData.strings.Gift_Resale_Unavailable_Text(dateString).string
877886
}
@@ -1150,10 +1159,28 @@ private final class GiftViewSheetContent: CombinedComponent {
11501159
return
11511160
}
11521161

1153-
let giftTitle = "\(uniqueGift.title) #\(uniqueGift.number)"
1154-
11551162
let context = self.context
11561163
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
1164+
1165+
if let resellTooEarlyTimestamp = self.resellTooEarlyTimestamp {
1166+
guard let controller = self.getController() else {
1167+
return
1168+
}
1169+
let dateString = stringForFullDate(timestamp: resellTooEarlyTimestamp, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat)
1170+
let alertController = textAlertController(
1171+
context: context,
1172+
title: presentationData.strings.Gift_Buy_ErrorTooEarly_Title,
1173+
text: presentationData.strings.Gift_Buy_ErrorTooEarly_Text(dateString).string,
1174+
actions: [
1175+
TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})
1176+
],
1177+
parseMarkdown: true
1178+
)
1179+
controller.present(alertController, in: .window(.root))
1180+
return
1181+
}
1182+
1183+
let giftTitle = "\(uniqueGift.title) #\(uniqueGift.number)"
11571184
let recipientPeerId = self.recipientPeerId ?? self.context.account.peerId
11581185

11591186
let action = {
@@ -1344,6 +1371,12 @@ private final class GiftViewSheetContent: CombinedComponent {
13441371
} else {
13451372
proceed()
13461373
}
1374+
} else {
1375+
guard let controller = self.getController() else {
1376+
return
1377+
}
1378+
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)
1379+
controller.present(alertController, in: .window(.root))
13471380
}
13481381
}
13491382

submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSearchResultItemComponent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ final class ChatbotSearchResultItemComponent: Component {
128128
animateScale: false
129129
)),
130130
environment: {},
131-
containerSize: CGSize(width: 100.0, height: 100.0)
131+
containerSize: CGSize(width: 140.0, height: 100.0)
132132
)
133133
} else {
134134
if let addButton = self.addButton {

0 commit comments

Comments
 (0)