mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-08 21:49:41 +00:00
Various fixes
This commit is contained in:
parent
a5ad9935d2
commit
11d8158a62
@ -182,23 +182,27 @@ func _internal_checkPremiumGiftCode(account: Account, slug: String) -> Signal<Pr
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_applyPremiumGiftCode(account: Account, slug: String) -> Signal<Never, NoError> {
|
||||
public enum ApplyPremiumGiftCodeError {
|
||||
case generic
|
||||
}
|
||||
|
||||
func _internal_applyPremiumGiftCode(account: Account, slug: String) -> Signal<Never, ApplyPremiumGiftCodeError> {
|
||||
return account.network.request(Api.functions.payments.applyGiftCode(slug: slug))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
|
||||
return .single(nil)
|
||||
|> mapError { _ -> ApplyPremiumGiftCodeError in
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<Never, NoError> in
|
||||
if let updates = updates {
|
||||
account.stateManager.addUpdates(updates)
|
||||
}
|
||||
|
||||
|> mapToSignal { updates -> Signal<Never, ApplyPremiumGiftCodeError> in
|
||||
account.stateManager.addUpdates(updates)
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_launchPrepaidGiveaway(account: Account, peerId: EnginePeer.Id, id: Int64, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, randomId: Int64, untilDate: Int32) -> Signal<Never, NoError> {
|
||||
return account.postbox.transaction { transaction -> Signal<Never, NoError> in
|
||||
public enum LaunchPrepaidGiveawayError {
|
||||
case generic
|
||||
}
|
||||
|
||||
func _internal_launchPrepaidGiveaway(account: Account, peerId: EnginePeer.Id, id: Int64, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, randomId: Int64, untilDate: Int32) -> Signal<Never, LaunchPrepaidGiveawayError> {
|
||||
return account.postbox.transaction { transaction -> Signal<Never, LaunchPrepaidGiveawayError> in
|
||||
var flags: Int32 = 0
|
||||
if onlyNewSubscribers {
|
||||
flags |= (1 << 0)
|
||||
@ -227,17 +231,15 @@ func _internal_launchPrepaidGiveaway(account: Account, peerId: EnginePeer.Id, id
|
||||
return .complete()
|
||||
}
|
||||
return account.network.request(Api.functions.payments.launchPrepaidGiveaway(peer: inputPeer, giveawayId: id, purpose: .inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: inputPeer, additionalPeers: additionalPeers, countriesIso2: countries, randomId: randomId, untilDate: untilDate, currency: "", amount: 0)))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
|
||||
return .single(nil)
|
||||
|> mapError { _ -> LaunchPrepaidGiveawayError in
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<Never, NoError> in
|
||||
if let updates = updates {
|
||||
account.stateManager.addUpdates(updates)
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<Never, LaunchPrepaidGiveawayError> in
|
||||
account.stateManager.addUpdates(updates)
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
|> castError(LaunchPrepaidGiveawayError.self)
|
||||
|> switchToLatest
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public extension TelegramEngine {
|
||||
return _internal_checkPremiumGiftCode(account: self.account, slug: slug)
|
||||
}
|
||||
|
||||
public func applyPremiumGiftCode(slug: String) -> Signal<Never, NoError> {
|
||||
public func applyPremiumGiftCode(slug: String) -> Signal<Never, ApplyPremiumGiftCodeError> {
|
||||
return _internal_applyPremiumGiftCode(account: self.account, slug: slug)
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public extension TelegramEngine {
|
||||
return _internal_getPremiumGiveawayInfo(account: self.account, peerId: peerId, messageId: messageId)
|
||||
}
|
||||
|
||||
public func launchPrepaidGiveaway(peerId: EnginePeer.Id, id: Int64, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, randomId: Int64, untilDate: Int32) -> Signal<Never, NoError> {
|
||||
public func launchPrepaidGiveaway(peerId: EnginePeer.Id, id: Int64, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, randomId: Int64, untilDate: Int32) -> Signal<Never, LaunchPrepaidGiveawayError> {
|
||||
return _internal_launchPrepaidGiveaway(account: self.account, peerId: peerId, id: id, additionalPeerIds: additionalPeerIds, countries: countries, onlyNewSubscribers: onlyNewSubscribers, randomId: randomId, untilDate: untilDate)
|
||||
}
|
||||
}
|
||||
|
@ -3848,14 +3848,21 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
strongSelf.openResolved(result: .join(joinHash), sourceMessageId: nil)
|
||||
}, openWebView: { [weak self] buttonText, url, simple, source in
|
||||
guard let strongSelf = self, let peerId = strongSelf.chatLocation.peerId, let peer = strongSelf.presentationInterfaceState.renderedPeer?.peer as? TelegramUser else {
|
||||
guard let strongSelf = self, let peerId = strongSelf.chatLocation.peerId, let peer = strongSelf.presentationInterfaceState.renderedPeer?.peer else {
|
||||
return
|
||||
}
|
||||
|
||||
strongSelf.chatDisplayNode.dismissInput()
|
||||
|
||||
let botName = EnginePeer(peer).displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)
|
||||
let botAddress = peer.addressName ?? ""
|
||||
let botName: String
|
||||
let botAddress: String
|
||||
if case let .inline(bot) = source {
|
||||
botName = bot.compactDisplayTitle
|
||||
botAddress = bot.addressName ?? ""
|
||||
} else {
|
||||
botName = EnginePeer(peer).displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)
|
||||
botAddress = peer.addressName ?? ""
|
||||
}
|
||||
|
||||
if source == .generic {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, {
|
||||
|
Loading…
x
Reference in New Issue
Block a user