mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-19 04:39:36 +00:00
Various fixes
This commit is contained in:
parent
fe81be7931
commit
9c486969ea
@ -962,7 +962,11 @@
|
|||||||
|
|
||||||
[_coverImageCache setImage:image forKey:itemId attributes:NULL];
|
[_coverImageCache setImage:image forKey:itemId attributes:NULL];
|
||||||
_coverImagePipe.sink([TGMediaImageUpdate imageUpdateWithItem:item representation:image]);
|
_coverImagePipe.sink([TGMediaImageUpdate imageUpdateWithItem:item representation:image]);
|
||||||
[_coverPositions setObject:position forKey:itemId];
|
if (position != nil) {
|
||||||
|
[_coverPositions setObject:position forKey:itemId];
|
||||||
|
} else {
|
||||||
|
[_coverPositions removeObjectForKey:itemId];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFullSizeImage:(UIImage *)image forItem:(id<TGMediaEditableItem>)item
|
- (void)setFullSizeImage:(UIImage *)image forItem:(id<TGMediaEditableItem>)item
|
||||||
|
|||||||
@ -367,96 +367,93 @@ final class GiftSetupScreenComponent: Component {
|
|||||||
let entities = generateChatInputTextEntities(self.textInputState.text)
|
let entities = generateChatInputTextEntities(self.textInputState.text)
|
||||||
let source: BotPaymentInvoiceSource = .starGift(hideName: self.hideName, includeUpgrade: self.includeUpgrade, peerId: peerId, giftId: starGift.id, text: self.textInputState.text.string, entities: entities)
|
let source: BotPaymentInvoiceSource = .starGift(hideName: self.hideName, includeUpgrade: self.includeUpgrade, peerId: peerId, giftId: starGift.id, text: self.textInputState.text.string, entities: entities)
|
||||||
|
|
||||||
let inputData = BotCheckoutController.InputData.fetch(context: component.context, source: source)
|
|
||||||
|> map(Optional.init)
|
|
||||||
|> `catch` { _ -> Signal<BotCheckoutController.InputData?, NoError> in
|
|
||||||
return .single(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
let completion = component.completion
|
let completion = component.completion
|
||||||
|
|
||||||
let _ = (inputData
|
let signal = BotCheckoutController.InputData.fetch(context: component.context, source: source)
|
||||||
|> deliverOnMainQueue).startStandalone(next: { [weak self] inputData in
|
|> `catch` { _ -> Signal<BotCheckoutController.InputData, SendBotPaymentFormError> in
|
||||||
guard let inputData else {
|
return .fail(.generic)
|
||||||
|
}
|
||||||
|
|> mapToSignal { inputData -> Signal<SendBotPaymentResult, SendBotPaymentFormError> in
|
||||||
|
return component.context.engine.payments.sendStarsPaymentForm(formId: inputData.form.id, source: source)
|
||||||
|
}
|
||||||
|
|> deliverOnMainQueue
|
||||||
|
|
||||||
|
let _ = signal.start(next: { [weak self] result in
|
||||||
|
guard let self, let controller = self.environment?.controller(), let navigationController = controller.navigationController as? NavigationController else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let _ = (component.context.engine.payments.sendStarsPaymentForm(formId: inputData.form.id, source: source)
|
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] result in
|
|
||||||
guard let self, let controller = self.environment?.controller(), let navigationController = controller.navigationController as? NavigationController else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||||
var controllers = navigationController.viewControllers
|
var controllers = navigationController.viewControllers
|
||||||
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) }
|
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) }
|
||||||
navigationController.setViewControllers(controllers, animated: true)
|
navigationController.setViewControllers(controllers, animated: true)
|
||||||
|
|
||||||
let tooltipController = UndoOverlayController(
|
let tooltipController = UndoOverlayController(
|
||||||
presentationData: presentationData,
|
presentationData: presentationData,
|
||||||
content: .sticker(
|
content: .sticker(
|
||||||
context: context,
|
context: context,
|
||||||
file: starGift.file,
|
file: starGift.file,
|
||||||
loop: true,
|
loop: true,
|
||||||
title: nil,
|
title: nil,
|
||||||
text: presentationData.strings.Gift_Send_Success(self.peerMap[peerId]?.compactDisplayTitle ?? "", presentationData.strings.Gift_Send_Success_Stars(Int32(starGift.price))).string,
|
text: presentationData.strings.Gift_Send_Success(self.peerMap[peerId]?.compactDisplayTitle ?? "", presentationData.strings.Gift_Send_Success_Stars(Int32(starGift.price))).string,
|
||||||
undoText: nil,
|
undoText: nil,
|
||||||
customAction: nil
|
customAction: nil
|
||||||
),
|
),
|
||||||
action: { _ in return true }
|
action: { _ in return true }
|
||||||
)
|
)
|
||||||
(navigationController.viewControllers.last as? ViewController)?.present(tooltipController, in: .current)
|
(navigationController.viewControllers.last as? ViewController)?.present(tooltipController, in: .current)
|
||||||
|
|
||||||
navigationController.view.addSubview(ConfettiView(frame: navigationController.view.bounds))
|
navigationController.view.addSubview(ConfettiView(frame: navigationController.view.bounds))
|
||||||
} else if peerId.namespace == Namespaces.Peer.CloudUser {
|
} else if peerId.namespace == Namespaces.Peer.CloudUser {
|
||||||
var controllers = navigationController.viewControllers
|
var controllers = navigationController.viewControllers
|
||||||
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) && !($0 is PeerInfoScreen) && !($0 is ContactSelectionController) }
|
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) && !($0 is PeerInfoScreen) && !($0 is ContactSelectionController) }
|
||||||
var foundController = false
|
var foundController = false
|
||||||
for controller in controllers.reversed() {
|
for controller in controllers.reversed() {
|
||||||
if let chatController = controller as? ChatController, case .peer(id: component.peerId) = chatController.chatLocation {
|
if let chatController = controller as? ChatController, case .peer(id: component.peerId) = chatController.chatLocation {
|
||||||
chatController.hintPlayNextOutgoingGift()
|
|
||||||
foundController = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !foundController {
|
|
||||||
let chatController = component.context.sharedContext.makeChatController(context: component.context, chatLocation: .peer(id: component.peerId), subject: nil, botStart: nil, mode: .standard(.default), params: nil)
|
|
||||||
chatController.hintPlayNextOutgoingGift()
|
chatController.hintPlayNextOutgoingGift()
|
||||||
controllers.append(chatController)
|
foundController = true
|
||||||
}
|
break
|
||||||
navigationController.setViewControllers(controllers, animated: true)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let completion {
|
|
||||||
completion()
|
|
||||||
|
|
||||||
if let controller = self.environment?.controller() {
|
|
||||||
controller.dismiss()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !foundController {
|
||||||
starsContext.load(force: true)
|
let chatController = component.context.sharedContext.makeChatController(context: component.context, chatLocation: .peer(id: component.peerId), subject: nil, botStart: nil, mode: .standard(.default), params: nil)
|
||||||
}, error: { [weak self] error in
|
chatController.hintPlayNextOutgoingGift()
|
||||||
guard let self, let controller = self.environment?.controller() else {
|
controllers.append(chatController)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
navigationController.setViewControllers(controllers, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
if let completion {
|
||||||
|
completion()
|
||||||
|
|
||||||
self.inProgress = false
|
if let controller = self.environment?.controller() {
|
||||||
self.state?.updated()
|
controller.dismiss()
|
||||||
|
|
||||||
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
|
|
||||||
var errorText: String?
|
|
||||||
switch error {
|
|
||||||
case .starGiftOutOfStock:
|
|
||||||
errorText = presentationData.strings.Gift_Send_ErrorOutOfStock
|
|
||||||
default:
|
|
||||||
errorText = presentationData.strings.Gift_Send_ErrorUnknown
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if let errorText = errorText {
|
|
||||||
let alertController = textAlertController(context: component.context, title: nil, text: errorText, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})])
|
starsContext.load(force: true)
|
||||||
controller.present(alertController, in: .window(.root))
|
}, error: { [weak self] error in
|
||||||
}
|
guard let self, let controller = self.environment?.controller() else {
|
||||||
})
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
self.inProgress = false
|
||||||
|
self.state?.updated()
|
||||||
|
|
||||||
|
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
var errorText: String?
|
||||||
|
switch error {
|
||||||
|
case .starGiftOutOfStock:
|
||||||
|
errorText = presentationData.strings.Gift_Send_ErrorOutOfStock
|
||||||
|
default:
|
||||||
|
errorText = presentationData.strings.Gift_Send_ErrorUnknown
|
||||||
|
}
|
||||||
|
|
||||||
|
if let errorText = errorText {
|
||||||
|
let alertController = textAlertController(context: component.context, title: nil, text: errorText, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})])
|
||||||
|
controller.present(alertController, in: .window(.root))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -141,11 +141,11 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||||
self.updateScrolling(transition: .immediate)
|
self.updateScrolling(interactive: true, transition: .immediate)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var notify = false
|
private var notify = false
|
||||||
func updateScrolling(transition: ComponentTransition) {
|
func updateScrolling(interactive: Bool = false, transition: ComponentTransition) {
|
||||||
if let starsProducts = self.starsProducts, let params = self.currentParams {
|
if let starsProducts = self.starsProducts, let params = self.currentParams {
|
||||||
let optionSpacing: CGFloat = 10.0
|
let optionSpacing: CGFloat = 10.0
|
||||||
let itemsSideInset = params.sideInset + 16.0
|
let itemsSideInset = params.sideInset + 16.0
|
||||||
@ -644,7 +644,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
|||||||
}
|
}
|
||||||
|
|
||||||
let bottomContentOffset = max(0.0, self.scrollNode.view.contentSize.height - self.scrollNode.view.contentOffset.y - self.scrollNode.view.frame.height)
|
let bottomContentOffset = max(0.0, self.scrollNode.view.contentSize.height - self.scrollNode.view.contentOffset.y - self.scrollNode.view.frame.height)
|
||||||
if bottomContentOffset < 200.0 {
|
if interactive, bottomContentOffset < 200.0 {
|
||||||
self.profileGifts.loadMore()
|
self.profileGifts.loadMore()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user