Skip to content

Commit c0184d4

Browse files
committed
Various fixes
1 parent fd38d2e commit c0184d4

File tree

7 files changed

+177
-140
lines changed

7 files changed

+177
-140
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13801,3 +13801,10 @@ Sorry for the inconvenience.";
1380113801

1380213802
"Notification.StarsGift.TransferToChannel" = "%@ transferred a unique collectible to %@";
1380313803
"Notification.StarsGift.TransferToChannelYou" = "You transferred a unique collectible to %@";
13804+
13805+
"Gift.Convert.Success.ChannelText" = "**%1$@** were sent to channel's balance.";
13806+
"Gift.Convert.Success.ChannelText.Stars_1" = "%@ Star";
13807+
"Gift.Convert.Success.ChannelText.Stars_any" = "%@ Stars";
13808+
13809+
"Stars.Transfer.Terms" = "By purchasing you agree to the [Terms of Service]().";
13810+
"Stars.Transfer.Terms_URL" = "https://telegram.org/tos/stars";

submodules/LegacyComponents/Sources/TGMediaEditingContext.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,11 @@ - (void)setCoverImage:(UIImage *)image position:(NSNumber *)position forItem:(id
962962

963963
[_coverImageCache setImage:image forKey:itemId attributes:NULL];
964964
_coverImagePipe.sink([TGMediaImageUpdate imageUpdateWithItem:item representation:image]);
965-
[_coverPositions setObject:position forKey:itemId];
965+
if (position != nil) {
966+
[_coverPositions setObject:position forKey:itemId];
967+
} else {
968+
[_coverPositions removeObjectForKey:itemId];
969+
}
966970
}
967971

968972
- (void)setFullSizeImage:(UIImage *)image forItem:(id<TGMediaEditableItem>)item

submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/StickerPaneSearchContentNode.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,13 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
355355
let signal: Signal<([(String?, FoundStickerItem)], FoundStickerSets, Bool, FoundStickerSets?)?, NoError>
356356
if !text.isEmpty {
357357
let context = self.context
358-
let stickers: Signal<[(String?, FoundStickerItem)], NoError> = Signal { subscriber in
359-
var signals: Signal<[Signal<(String?, [FoundStickerItem]), NoError>], NoError> = .single([])
358+
let stickers: Signal<([(String?, FoundStickerItem)], Bool), NoError> = Signal { subscriber in
359+
var signals: Signal<[Signal<(String?, [FoundStickerItem], Bool), NoError>], NoError> = .single([])
360360

361361
let query = text.trimmingCharacters(in: .whitespacesAndNewlines)
362362
if query.isSingleEmoji {
363363
signals = .single([context.engine.stickers.searchStickers(query: nil, emoticon: [text.basicEmoji.0])
364-
|> map { (nil, $0.items) }])
364+
|> map { (nil, $0.items, $0.isFinalResult) }])
365365
} else if query.count > 1, let languageCode = languageCode, !languageCode.isEmpty && languageCode != "emoji" {
366366
var signal = context.engine.stickers.searchEmojiKeywords(inputLanguageCode: languageCode, query: query.lowercased(), completeMatch: query.count < 3)
367367
if !languageCode.lowercased().hasPrefix("en") {
@@ -377,10 +377,10 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
377377
}
378378
}
379379
signals = signal
380-
|> map { keywords -> [Signal<(String?, [FoundStickerItem]), NoError>] in
380+
|> map { keywords -> [Signal<(String?, [FoundStickerItem], Bool), NoError>] in
381381
let emoticon = keywords.flatMap { $0.emoticons }.map { $0.basicEmoji.0 }
382382
return [context.engine.stickers.searchStickers(query: query, emoticon: emoticon, inputLanguageCode: languageCode)
383-
|> map { (nil, $0.items) }]
383+
|> map { (nil, $0.items, $0.isFinalResult) }]
384384
}
385385
}
386386

@@ -389,12 +389,16 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
389389
return combineLatest(signals)
390390
}).start(next: { results in
391391
var result: [(String?, FoundStickerItem)] = []
392-
for (emoji, stickers) in results {
392+
var allAreFinal = true
393+
for (emoji, stickers, isFinal) in results {
393394
for sticker in stickers {
394395
result.append((emoji, sticker))
395396
}
397+
if !isFinal {
398+
allAreFinal = false
399+
}
396400
}
397-
subscriber.putNext(result)
401+
subscriber.putNext((result, allAreFinal))
398402
}, completed: {
399403
// subscriber.putCompletion()
400404
})
@@ -456,7 +460,7 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
456460

457461
signal = combineLatest(stickers, packs)
458462
|> map { stickers, packs -> ([(String?, FoundStickerItem)], FoundStickerSets, Bool, FoundStickerSets?)? in
459-
return (stickers, packs.0, packs.1, packs.2)
463+
return (stickers.0, packs.0, packs.1 && stickers.1, packs.2)
460464
}
461465
self.updateActivity?(true)
462466
} else {

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

Lines changed: 76 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -344,98 +344,93 @@ final class GiftSetupScreenComponent: Component {
344344
let entities = generateChatInputTextEntities(self.textInputState.text)
345345
let source: BotPaymentInvoiceSource = .starGift(hideName: self.hideName, includeUpgrade: self.includeUpgrade, peerId: peerId, giftId: starGift.id, text: self.textInputState.text.string, entities: entities)
346346

347-
let inputData = BotCheckoutController.InputData.fetch(context: component.context, source: source)
348-
|> map(Optional.init)
349-
|> `catch` { _ -> Signal<BotCheckoutController.InputData?, NoError> in
350-
return .single(nil)
351-
}
352347

353348
let completion = component.completion
354349

355-
let _ = (inputData
356-
|> deliverOnMainQueue).startStandalone(next: { [weak self] inputData in
357-
guard let inputData else {
350+
let signal = BotCheckoutController.InputData.fetch(context: component.context, source: source)
351+
|> `catch` { _ -> Signal<BotCheckoutController.InputData, SendBotPaymentFormError> in
352+
return .fail(.generic)
353+
}
354+
|> mapToSignal { inputData -> Signal<SendBotPaymentResult, SendBotPaymentFormError> in
355+
return component.context.engine.payments.sendStarsPaymentForm(formId: inputData.form.id, source: source)
356+
}
357+
|> deliverOnMainQueue
358+
359+
let _ = signal.start(next: { [weak self] result in
360+
guard let self, let controller = self.environment?.controller(), let navigationController = controller.navigationController as? NavigationController else {
358361
return
359362
}
360-
let _ = (component.context.engine.payments.sendStarsPaymentForm(formId: inputData.form.id, source: source)
361-
|> deliverOnMainQueue).start(next: { [weak self] result in
362-
if let self, peerId.namespace == Namespaces.Peer.CloudChannel, let controller = self.environment?.controller(), let navigationController = controller.navigationController as? NavigationController {
363-
var controllers = navigationController.viewControllers
364-
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) }
365-
navigationController.setViewControllers(controllers, animated: true)
366-
367-
let tooltipController = UndoOverlayController(
368-
presentationData: presentationData,
369-
content: .sticker(
370-
context: context,
371-
file: starGift.file,
372-
loop: true,
373-
title: nil,
374-
text: presentationData.strings.Gift_Send_Success(self.peerMap[peerId]?.compactDisplayTitle ?? "", presentationData.strings.Gift_Send_Success_Stars(Int32(starGift.price))).string,
375-
undoText: nil,
376-
customAction: nil
377-
),
378-
action: { _ in return true }
379-
)
380-
(navigationController.viewControllers.last as? ViewController)?.present(tooltipController, in: .current)
381-
382-
navigationController.view.addSubview(ConfettiView(frame: navigationController.view.bounds))
383-
}
363+
364+
if peerId.namespace == Namespaces.Peer.CloudChannel {
365+
var controllers = navigationController.viewControllers
366+
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) }
367+
navigationController.setViewControllers(controllers, animated: true)
384368

385-
if let completion {
386-
completion()
387-
388-
if let self, let controller = self.environment?.controller() {
389-
controller.dismiss()
390-
}
391-
} else {
392-
guard let self, let controller = self.environment?.controller(), let navigationController = controller.navigationController as? NavigationController else {
393-
return
394-
}
395-
396-
if peerId.namespace != Namespaces.Peer.CloudChannel {
397-
var controllers = navigationController.viewControllers
398-
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) && !($0 is PeerInfoScreen) && !($0 is ContactSelectionController) }
399-
var foundController = false
400-
for controller in controllers.reversed() {
401-
if let chatController = controller as? ChatController, case .peer(id: component.peerId) = chatController.chatLocation {
402-
chatController.hintPlayNextOutgoingGift()
403-
foundController = true
404-
break
405-
}
406-
}
407-
if !foundController {
408-
let chatController = component.context.sharedContext.makeChatController(context: component.context, chatLocation: .peer(id: component.peerId), subject: nil, botStart: nil, mode: .standard(.default), params: nil)
409-
chatController.hintPlayNextOutgoingGift()
410-
controllers.append(chatController)
411-
}
412-
navigationController.setViewControllers(controllers, animated: true)
413-
}
414-
}
369+
let tooltipController = UndoOverlayController(
370+
presentationData: presentationData,
371+
content: .sticker(
372+
context: context,
373+
file: starGift.file,
374+
loop: true,
375+
title: nil,
376+
text: presentationData.strings.Gift_Send_Success(self.peerMap[peerId]?.compactDisplayTitle ?? "", presentationData.strings.Gift_Send_Success_Stars(Int32(starGift.price))).string,
377+
undoText: nil,
378+
customAction: nil
379+
),
380+
action: { _ in return true }
381+
)
382+
(navigationController.viewControllers.last as? ViewController)?.present(tooltipController, in: .current)
415383

416-
starsContext.load(force: true)
417-
}, error: { [weak self] error in
418-
guard let self, let controller = self.environment?.controller() else {
419-
return
384+
navigationController.view.addSubview(ConfettiView(frame: navigationController.view.bounds))
385+
} else if peerId.namespace == Namespaces.Peer.CloudUser {
386+
var controllers = navigationController.viewControllers
387+
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) && !($0 is PeerInfoScreen) && !($0 is ContactSelectionController) }
388+
var foundController = false
389+
for controller in controllers.reversed() {
390+
if let chatController = controller as? ChatController, case .peer(id: component.peerId) = chatController.chatLocation {
391+
chatController.hintPlayNextOutgoingGift()
392+
foundController = true
393+
break
394+
}
420395
}
421-
422-
self.inProgress = false
423-
self.state?.updated()
424-
425-
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
426-
var errorText: String?
427-
switch error {
428-
case .starGiftOutOfStock:
429-
errorText = presentationData.strings.Gift_Send_ErrorOutOfStock
430-
default:
431-
errorText = presentationData.strings.Gift_Send_ErrorUnknown
396+
if !foundController {
397+
let chatController = component.context.sharedContext.makeChatController(context: component.context, chatLocation: .peer(id: component.peerId), subject: nil, botStart: nil, mode: .standard(.default), params: nil)
398+
chatController.hintPlayNextOutgoingGift()
399+
controllers.append(chatController)
432400
}
401+
navigationController.setViewControllers(controllers, animated: true)
402+
}
403+
404+
if let completion {
405+
completion()
433406

434-
if let errorText = errorText {
435-
let alertController = textAlertController(context: component.context, title: nil, text: errorText, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})])
436-
controller.present(alertController, in: .window(.root))
407+
if let controller = self.environment?.controller() {
408+
controller.dismiss()
437409
}
438-
})
410+
}
411+
412+
starsContext.load(force: true)
413+
}, error: { [weak self] error in
414+
guard let self, let controller = self.environment?.controller() else {
415+
return
416+
}
417+
418+
self.inProgress = false
419+
self.state?.updated()
420+
421+
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
422+
var errorText: String?
423+
switch error {
424+
case .starGiftOutOfStock:
425+
errorText = presentationData.strings.Gift_Send_ErrorOutOfStock
426+
default:
427+
errorText = presentationData.strings.Gift_Send_ErrorUnknown
428+
}
429+
430+
if let errorText = errorText {
431+
let alertController = textAlertController(context: component.context, title: nil, text: errorText, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})])
432+
controller.present(alertController, in: .window(.root))
433+
}
439434
})
440435
}
441436

0 commit comments

Comments
 (0)