mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various improvements
This commit is contained in:
parent
fa620eecde
commit
035ab8d2cb
@ -680,7 +680,6 @@ public protocol SharedAccountContext: AnyObject {
|
|||||||
var locationManager: DeviceLocationManager? { get }
|
var locationManager: DeviceLocationManager? { get }
|
||||||
var callManager: PresentationCallManager? { get }
|
var callManager: PresentationCallManager? { get }
|
||||||
var contactDataManager: DeviceContactDataManager? { get }
|
var contactDataManager: DeviceContactDataManager? { get }
|
||||||
var inAppPurchaseManager: InAppPurchaseManager? { get }
|
|
||||||
|
|
||||||
var activeAccountContexts: Signal<(primary: AccountContext?, accounts: [(AccountRecordId, AccountContext, Int32)], currentAuth: UnauthorizedAccount?), NoError> { get }
|
var activeAccountContexts: Signal<(primary: AccountContext?, accounts: [(AccountRecordId, AccountContext, Int32)], currentAuth: UnauthorizedAccount?), NoError> { get }
|
||||||
var activeAccountsWithInfo: Signal<(primary: AccountRecordId?, accounts: [AccountWithInfo]), NoError> { get }
|
var activeAccountsWithInfo: Signal<(primary: AccountRecordId?, accounts: [AccountWithInfo]), NoError> { get }
|
||||||
@ -861,6 +860,7 @@ public protocol AccountContext: AnyObject {
|
|||||||
var peerChannelMemberCategoriesContextsManager: PeerChannelMemberCategoriesContextsManager { get }
|
var peerChannelMemberCategoriesContextsManager: PeerChannelMemberCategoriesContextsManager { get }
|
||||||
var wallpaperUploadManager: WallpaperUploadManager? { get }
|
var wallpaperUploadManager: WallpaperUploadManager? { get }
|
||||||
var watchManager: WatchManager? { get }
|
var watchManager: WatchManager? { get }
|
||||||
|
var inAppPurchaseManager: InAppPurchaseManager? { get }
|
||||||
|
|
||||||
var currentLimitsConfiguration: Atomic<LimitsConfiguration> { get }
|
var currentLimitsConfiguration: Atomic<LimitsConfiguration> { get }
|
||||||
var currentContentSettings: Atomic<ContentSettings> { get }
|
var currentContentSettings: Atomic<ContentSettings> { get }
|
||||||
|
@ -114,7 +114,7 @@ public final class MultilineTextComponent: Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class View: ImmediateTextView {
|
public final class View: ImmediateTextView {
|
||||||
public func update(component: MultilineTextComponent, availableSize: CGSize) -> CGSize {
|
public func update(component: MultilineTextComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||||
let attributedString: NSAttributedString
|
let attributedString: NSAttributedString
|
||||||
switch component.text {
|
switch component.text {
|
||||||
case let .plain(string):
|
case let .plain(string):
|
||||||
@ -123,6 +123,8 @@ public final class MultilineTextComponent: Component {
|
|||||||
attributedString = parseMarkdownIntoAttributedString(text, attributes: attributes)
|
attributedString = parseMarkdownIntoAttributedString(text, attributes: attributes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let previousText = self.attributedText?.string
|
||||||
|
|
||||||
self.attributedText = attributedString
|
self.attributedText = attributedString
|
||||||
self.maximumNumberOfLines = component.maximumNumberOfLines
|
self.maximumNumberOfLines = component.maximumNumberOfLines
|
||||||
self.truncationType = component.truncationType
|
self.truncationType = component.truncationType
|
||||||
@ -138,6 +140,18 @@ public final class MultilineTextComponent: Component {
|
|||||||
self.tapAttributeAction = component.tapAction
|
self.tapAttributeAction = component.tapAction
|
||||||
self.longTapAttributeAction = component.longTapAction
|
self.longTapAttributeAction = component.longTapAction
|
||||||
|
|
||||||
|
if case let .curve(duration, _) = transition.animation, let previousText = previousText, previousText != attributedString.string {
|
||||||
|
if let snapshotView = self.snapshotView(afterScreenUpdates: false) {
|
||||||
|
snapshotView.center = self.center
|
||||||
|
self.superview?.addSubview(snapshotView)
|
||||||
|
|
||||||
|
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: duration, removeOnCompletion: false, completion: { [weak snapshotView] _ in
|
||||||
|
snapshotView?.removeFromSuperview()
|
||||||
|
})
|
||||||
|
self.layer.animateAlpha(from: 0.0, to: 1.0, duration: duration)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let size = self.updateLayout(availableSize)
|
let size = self.updateLayout(availableSize)
|
||||||
|
|
||||||
return size
|
return size
|
||||||
@ -149,6 +163,6 @@ public final class MultilineTextComponent: Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||||
return view.update(component: self, availableSize: availableSize)
|
return view.update(component: self, availableSize: availableSize, transition: transition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ public final class InAppPurchaseManager: NSObject {
|
|||||||
case deferred
|
case deferred
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private let engine: TelegramEngine
|
||||||
private let premiumProductId: String
|
private let premiumProductId: String
|
||||||
|
|
||||||
private var products: [Product] = []
|
private var products: [Product] = []
|
||||||
@ -56,7 +57,10 @@ public final class InAppPurchaseManager: NSObject {
|
|||||||
private let stateQueue = Queue()
|
private let stateQueue = Queue()
|
||||||
private var paymentContexts: [String: PaymentTransactionContext] = [:]
|
private var paymentContexts: [String: PaymentTransactionContext] = [:]
|
||||||
|
|
||||||
public init(premiumProductId: String) {
|
private let disposableSet = DisposableDict<String>()
|
||||||
|
|
||||||
|
public init(engine: TelegramEngine, premiumProductId: String) {
|
||||||
|
self.engine = engine
|
||||||
self.premiumProductId = premiumProductId
|
self.premiumProductId = premiumProductId
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
@ -88,7 +92,7 @@ public final class InAppPurchaseManager: NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func buyProduct(_ product: Product, account: Account) -> Signal<PurchaseState, PurchaseError> {
|
public func buyProduct(_ product: Product, account: Account) -> Signal<PurchaseState, PurchaseError> {
|
||||||
let payment = SKMutablePayment(product: product.skProduct)
|
let payment = SKPayment(product: product.skProduct)
|
||||||
SKPaymentQueue.default().add(payment)
|
SKPaymentQueue.default().add(payment)
|
||||||
|
|
||||||
let productIdentifier = payment.productIdentifier
|
let productIdentifier = payment.productIdentifier
|
||||||
@ -140,18 +144,38 @@ extension InAppPurchaseManager: SKProductsRequestDelegate {
|
|||||||
|
|
||||||
extension InAppPurchaseManager: SKPaymentTransactionObserver {
|
extension InAppPurchaseManager: SKPaymentTransactionObserver {
|
||||||
public func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
|
public func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
|
||||||
if let transaction = transactions.first {
|
for transaction in transactions {
|
||||||
let productIdentifier = transaction.payment.productIdentifier
|
let productIdentifier = transaction.payment.productIdentifier
|
||||||
self.stateQueue.async {
|
self.stateQueue.async {
|
||||||
if let context = self.paymentContexts[productIdentifier] {
|
|
||||||
let transactionState: TransactionState?
|
let transactionState: TransactionState?
|
||||||
switch transaction.transactionState {
|
switch transaction.transactionState {
|
||||||
case .purchased:
|
case .purchased:
|
||||||
transactionState = .purchased(transactionId: transaction.transactionIdentifier)
|
transactionState = .purchased(transactionId: transaction.transactionIdentifier)
|
||||||
|
if let transactionIdentifier = transaction.transactionIdentifier {
|
||||||
|
self.disposableSet.set(
|
||||||
|
self.engine.payments.assignAppStoreTransaction(transactionId: transactionIdentifier).start(error: { error in
|
||||||
|
|
||||||
|
}, completed: {
|
||||||
|
queue.finishTransaction(transaction)
|
||||||
|
}),
|
||||||
|
forKey: transaction.transactionIdentifier ?? ""
|
||||||
|
)
|
||||||
|
}
|
||||||
case .restored:
|
case .restored:
|
||||||
transactionState = .restored(transactionId: transaction.transactionIdentifier)
|
transactionState = .restored(transactionId: transaction.transactionIdentifier)
|
||||||
|
if let transactionIdentifier = transaction.transactionIdentifier {
|
||||||
|
self.disposableSet.set(
|
||||||
|
self.engine.payments.assignAppStoreTransaction(transactionId: transactionIdentifier).start(error: { error in
|
||||||
|
|
||||||
|
}, completed: {
|
||||||
|
queue.finishTransaction(transaction)
|
||||||
|
}),
|
||||||
|
forKey: transaction.transactionIdentifier ?? ""
|
||||||
|
)
|
||||||
|
}
|
||||||
case .failed:
|
case .failed:
|
||||||
transactionState = .failed
|
transactionState = .failed
|
||||||
|
queue.finishTransaction(transaction)
|
||||||
case .purchasing:
|
case .purchasing:
|
||||||
transactionState = .purchasing
|
transactionState = .purchasing
|
||||||
case .deferred:
|
case .deferred:
|
||||||
@ -160,6 +184,7 @@ extension InAppPurchaseManager: SKPaymentTransactionObserver {
|
|||||||
transactionState = nil
|
transactionState = nil
|
||||||
}
|
}
|
||||||
if let transactionState = transactionState {
|
if let transactionState = transactionState {
|
||||||
|
if let context = self.paymentContexts[productIdentifier] {
|
||||||
context.subscriber(transactionState)
|
context.subscriber(transactionState)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -793,6 +793,7 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
|
|||||||
private let context: AccountContext
|
private let context: AccountContext
|
||||||
|
|
||||||
var price: String?
|
var price: String?
|
||||||
|
var isPremium: Bool?
|
||||||
|
|
||||||
private var disposable: Disposable?
|
private var disposable: Disposable?
|
||||||
private(set) var configuration = PremiumIntroConfiguration.defaultValue
|
private(set) var configuration = PremiumIntroConfiguration.defaultValue
|
||||||
@ -867,6 +868,7 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
|
|||||||
let environment = context.environment[ViewControllerComponentContainer.Environment.self].value
|
let environment = context.environment[ViewControllerComponentContainer.Environment.self].value
|
||||||
let state = context.state
|
let state = context.state
|
||||||
state.price = context.component.price
|
state.price = context.component.price
|
||||||
|
state.isPremium = context.component.isPremium
|
||||||
|
|
||||||
let theme = environment.theme
|
let theme = environment.theme
|
||||||
let strings = environment.strings
|
let strings = environment.strings
|
||||||
@ -963,8 +965,6 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
|
|||||||
let buy = context.component.buy
|
let buy = context.component.buy
|
||||||
let updateIsFocused = context.component.updateIsFocused
|
let updateIsFocused = context.component.updateIsFocused
|
||||||
|
|
||||||
let isPremium = context.component.isPremium ?? false
|
|
||||||
|
|
||||||
var i = 0
|
var i = 0
|
||||||
for perk in state.configuration.perks {
|
for perk in state.configuration.perks {
|
||||||
let iconBackgroundColors = gradientColors[i]
|
let iconBackgroundColors = gradientColors[i]
|
||||||
@ -989,11 +989,21 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
|
|||||||
var demoSubject: PremiumDemoScreen.Subject
|
var demoSubject: PremiumDemoScreen.Subject
|
||||||
switch perk {
|
switch perk {
|
||||||
case .doubleLimits:
|
case .doubleLimits:
|
||||||
let controller = PremimLimitsListScreen(context: accountContext, buttonText: isPremium ? strings.Common_OK : strings.Premium_SubscribeFor(state?.price ?? "–").string, isPremium: isPremium)
|
var dismissImpl: (() -> Void)?
|
||||||
|
let controller = PremimLimitsListScreen(context: accountContext, buttonText: state?.isPremium == true ? strings.Common_OK : strings.Premium_SubscribeFor(state?.price ?? "–").string, isPremium: state?.isPremium == true)
|
||||||
|
controller.action = { [weak state] in
|
||||||
|
dismissImpl?()
|
||||||
|
if state?.isPremium == false {
|
||||||
|
buy()
|
||||||
|
}
|
||||||
|
}
|
||||||
controller.disposed = {
|
controller.disposed = {
|
||||||
updateIsFocused(false)
|
updateIsFocused(false)
|
||||||
}
|
}
|
||||||
present(controller)
|
present(controller)
|
||||||
|
dismissImpl = { [weak controller] in
|
||||||
|
controller?.dismiss(animated: true, completion: nil)
|
||||||
|
}
|
||||||
updateIsFocused(true)
|
updateIsFocused(true)
|
||||||
return
|
return
|
||||||
case .moreUpload:
|
case .moreUpload:
|
||||||
@ -1018,15 +1028,13 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
|
|||||||
demoSubject = .appIcons
|
demoSubject = .appIcons
|
||||||
}
|
}
|
||||||
|
|
||||||
var dismissImpl: (() -> Void)?
|
|
||||||
let controller = PremiumDemoScreen(
|
let controller = PremiumDemoScreen(
|
||||||
context: accountContext,
|
context: accountContext,
|
||||||
subject: demoSubject,
|
subject: demoSubject,
|
||||||
source: .intro(state?.price),
|
source: .intro(state?.price),
|
||||||
order: state?.configuration.perks,
|
order: state?.configuration.perks,
|
||||||
action: {
|
action: {
|
||||||
dismissImpl?()
|
if state?.isPremium == false {
|
||||||
if !isPremium {
|
|
||||||
buy()
|
buy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1035,9 +1043,6 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
|
|||||||
updateIsFocused(false)
|
updateIsFocused(false)
|
||||||
}
|
}
|
||||||
present(controller)
|
present(controller)
|
||||||
dismissImpl = { [weak controller] in
|
|
||||||
controller?.dismiss(animated: true, completion: nil)
|
|
||||||
}
|
|
||||||
updateIsFocused(true)
|
updateIsFocused(true)
|
||||||
|
|
||||||
addAppLogEvent(postbox: accountContext.account.postbox, type: "premium.promo_screen_tap", data: ["item": perk.identifier])
|
addAppLogEvent(postbox: accountContext.account.postbox, type: "premium.promo_screen_tap", data: ["item": perk.identifier])
|
||||||
@ -1315,7 +1320,7 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
|
|||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
if let inAppPurchaseManager = context.sharedContext.inAppPurchaseManager {
|
if let inAppPurchaseManager = context.inAppPurchaseManager {
|
||||||
let otherPeerName: Signal<String?, NoError>
|
let otherPeerName: Signal<String?, NoError>
|
||||||
if case let .profile(peerId) = source {
|
if case let .profile(peerId) = source {
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
@ -1353,7 +1358,7 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func buy() {
|
func buy() {
|
||||||
guard let inAppPurchaseManager = self.context.sharedContext.inAppPurchaseManager,
|
guard let inAppPurchaseManager = self.context.inAppPurchaseManager,
|
||||||
let premiumProduct = self.premiumProduct, !self.inProgress else {
|
let premiumProduct = self.premiumProduct, !self.inProgress else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1370,8 +1375,19 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
|
|||||||
if available {
|
if available {
|
||||||
strongSelf.paymentDisposable.set((inAppPurchaseManager.buyProduct(premiumProduct, account: strongSelf.context.account)
|
strongSelf.paymentDisposable.set((inAppPurchaseManager.buyProduct(premiumProduct, account: strongSelf.context.account)
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] status in
|
|> deliverOnMainQueue).start(next: { [weak self] status in
|
||||||
if let strongSelf = self, case let .purchased(transactionId) = status {
|
if let strongSelf = self, case .purchased = status {
|
||||||
strongSelf.activationDisposable.set((strongSelf.context.engine.payments.assignAppStoreTransaction(transactionId: transactionId)
|
strongSelf.activationDisposable.set((strongSelf.context.account.postbox.peerView(id: strongSelf.context.account.peerId)
|
||||||
|
|> castError(AssignAppStoreTransactionError.self)
|
||||||
|
|> take(until: { view in
|
||||||
|
if let peer = view.peers[view.peerId], peer.isPremium {
|
||||||
|
return SignalTakeAction(passthrough: false, complete: true)
|
||||||
|
} else {
|
||||||
|
return SignalTakeAction(passthrough: false, complete: false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|> mapToSignal { _ -> Signal<Never, AssignAppStoreTransactionError> in
|
||||||
|
return .never()
|
||||||
|
}
|
||||||
|> deliverOnMainQueue).start(error: { _ in
|
|> deliverOnMainQueue).start(error: { _ in
|
||||||
|
|
||||||
}, completed: { [weak self] in
|
}, completed: { [weak self] in
|
||||||
@ -1421,7 +1437,7 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
|
|||||||
let star = Child(PremiumStarComponent.self)
|
let star = Child(PremiumStarComponent.self)
|
||||||
let topPanel = Child(BlurredRectangle.self)
|
let topPanel = Child(BlurredRectangle.self)
|
||||||
let topSeparator = Child(Rectangle.self)
|
let topSeparator = Child(Rectangle.self)
|
||||||
let title = Child(Text.self)
|
let title = Child(MultilineTextComponent.self)
|
||||||
let secondaryTitle = Child(MultilineTextComponent.self)
|
let secondaryTitle = Child(MultilineTextComponent.self)
|
||||||
let bottomPanel = Child(BlurredRectangle.self)
|
let bottomPanel = Child(BlurredRectangle.self)
|
||||||
let bottomSeparator = Child(Rectangle.self)
|
let bottomSeparator = Child(Rectangle.self)
|
||||||
@ -1468,10 +1484,11 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let title = title.update(
|
let title = title.update(
|
||||||
component: Text(
|
component: MultilineTextComponent(
|
||||||
text: titleString,
|
text: .plain(NSAttributedString(string: titleString, font: Font.bold(28.0), textColor: environment.theme.rootController.navigationBar.primaryTextColor)),
|
||||||
font: Font.bold(28.0),
|
horizontalAlignment: .center,
|
||||||
color: environment.theme.rootController.navigationBar.primaryTextColor
|
truncationType: .end,
|
||||||
|
maximumNumberOfLines: 1
|
||||||
),
|
),
|
||||||
availableSize: context.availableSize,
|
availableSize: context.availableSize,
|
||||||
transition: context.transition
|
transition: context.transition
|
||||||
|
@ -452,6 +452,10 @@ public class PremimLimitsListScreen: ViewController {
|
|||||||
self.containerView.addSubview(self.scrollView)
|
self.containerView.addSubview(self.scrollView)
|
||||||
self.containerView.addSubnode(self.footerNode)
|
self.containerView.addSubnode(self.footerNode)
|
||||||
self.scrollView.addSubview(self.hostView)
|
self.scrollView.addSubview(self.hostView)
|
||||||
|
|
||||||
|
self.footerNode.action = { [weak self] in
|
||||||
|
self?.controller?.action()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func didLoad() {
|
override func didLoad() {
|
||||||
@ -891,6 +895,7 @@ public class PremimLimitsListScreen: ViewController {
|
|||||||
private let buttonText: String
|
private let buttonText: String
|
||||||
private let buttonGloss: Bool
|
private let buttonGloss: Bool
|
||||||
|
|
||||||
|
var action: () -> Void = {}
|
||||||
var disposed: () -> Void = {}
|
var disposed: () -> Void = {}
|
||||||
|
|
||||||
public convenience init(context: AccountContext, buttonText: String, isPremium: Bool) {
|
public convenience init(context: AccountContext, buttonText: String, isPremium: Bool) {
|
||||||
|
@ -18,6 +18,7 @@ import AsyncDisplayKit
|
|||||||
import PresentationDataUtils
|
import PresentationDataUtils
|
||||||
import MeshAnimationCache
|
import MeshAnimationCache
|
||||||
import FetchManagerImpl
|
import FetchManagerImpl
|
||||||
|
import InAppPurchaseManager
|
||||||
|
|
||||||
private final class DeviceSpecificContactImportContext {
|
private final class DeviceSpecificContactImportContext {
|
||||||
let disposable = MetaDisposable()
|
let disposable = MetaDisposable()
|
||||||
@ -122,6 +123,7 @@ public final class AccountContextImpl: AccountContext {
|
|||||||
public let peersNearbyManager: PeersNearbyManager?
|
public let peersNearbyManager: PeersNearbyManager?
|
||||||
public let wallpaperUploadManager: WallpaperUploadManager?
|
public let wallpaperUploadManager: WallpaperUploadManager?
|
||||||
private let themeUpdateManager: ThemeUpdateManager?
|
private let themeUpdateManager: ThemeUpdateManager?
|
||||||
|
public let inAppPurchaseManager: InAppPurchaseManager?
|
||||||
|
|
||||||
public let peerChannelMemberCategoriesContextsManager = PeerChannelMemberCategoriesContextsManager()
|
public let peerChannelMemberCategoriesContextsManager = PeerChannelMemberCategoriesContextsManager()
|
||||||
|
|
||||||
@ -184,10 +186,16 @@ public final class AccountContextImpl: AccountContext {
|
|||||||
self.prefetchManager = PrefetchManagerImpl(sharedContext: sharedContext, account: account, engine: self.engine, fetchManager: self.fetchManager)
|
self.prefetchManager = PrefetchManagerImpl(sharedContext: sharedContext, account: account, engine: self.engine, fetchManager: self.fetchManager)
|
||||||
self.wallpaperUploadManager = WallpaperUploadManagerImpl(sharedContext: sharedContext, account: account, presentationData: sharedContext.presentationData)
|
self.wallpaperUploadManager = WallpaperUploadManagerImpl(sharedContext: sharedContext, account: account, presentationData: sharedContext.presentationData)
|
||||||
self.themeUpdateManager = ThemeUpdateManagerImpl(sharedContext: sharedContext, account: account)
|
self.themeUpdateManager = ThemeUpdateManagerImpl(sharedContext: sharedContext, account: account)
|
||||||
|
if let premiumProductId = sharedContext.premiumProductId {
|
||||||
|
self.inAppPurchaseManager = InAppPurchaseManager(engine: self.engine, premiumProductId: premiumProductId)
|
||||||
|
} else {
|
||||||
|
self.inAppPurchaseManager = nil
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.prefetchManager = nil
|
self.prefetchManager = nil
|
||||||
self.wallpaperUploadManager = nil
|
self.wallpaperUploadManager = nil
|
||||||
self.themeUpdateManager = nil
|
self.themeUpdateManager = nil
|
||||||
|
self.inAppPurchaseManager = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if let locationManager = self.sharedContextImpl.locationManager, sharedContext.applicationBindings.isMainApp && !temp {
|
if let locationManager = self.sharedContextImpl.locationManager, sharedContext.applicationBindings.isMainApp && !temp {
|
||||||
|
@ -33,7 +33,6 @@ import TelegramAudio
|
|||||||
import DebugSettingsUI
|
import DebugSettingsUI
|
||||||
import BackgroundTasks
|
import BackgroundTasks
|
||||||
import UIKitRuntimeUtils
|
import UIKitRuntimeUtils
|
||||||
import InAppPurchaseManager
|
|
||||||
|
|
||||||
#if canImport(AppCenter)
|
#if canImport(AppCenter)
|
||||||
import AppCenter
|
import AppCenter
|
||||||
@ -711,8 +710,6 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
|||||||
UINavigationController.attemptRotationToDeviceOrientation()
|
UINavigationController.attemptRotationToDeviceOrientation()
|
||||||
})
|
})
|
||||||
|
|
||||||
let inAppPurchaseManager = InAppPurchaseManager(premiumProductId: buildConfig.premiumIAPProductId)
|
|
||||||
|
|
||||||
let accountManager = AccountManager<TelegramAccountManagerTypes>(basePath: rootPath + "/accounts-metadata", isTemporary: false, isReadOnly: false, useCaches: true, removeDatabaseOnError: true)
|
let accountManager = AccountManager<TelegramAccountManagerTypes>(basePath: rootPath + "/accounts-metadata", isTemporary: false, isReadOnly: false, useCaches: true, removeDatabaseOnError: true)
|
||||||
self.accountManager = accountManager
|
self.accountManager = accountManager
|
||||||
|
|
||||||
@ -755,7 +752,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
|||||||
})
|
})
|
||||||
|
|
||||||
var setPresentationCall: ((PresentationCall?) -> Void)?
|
var setPresentationCall: ((PresentationCall?) -> Void)?
|
||||||
let sharedContext = SharedAccountContextImpl(mainWindow: self.mainWindow, sharedContainerPath: legacyBasePath, basePath: rootPath, encryptionParameters: encryptionParameters, accountManager: accountManager, appLockContext: appLockContext, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings, networkArguments: networkArguments, inAppPurchaseManager: inAppPurchaseManager, rootPath: rootPath, legacyBasePath: legacyBasePath, apsNotificationToken: self.notificationTokenPromise.get() |> map(Optional.init), voipNotificationToken: self.voipTokenPromise.get() |> map(Optional.init), setNotificationCall: { call in
|
let sharedContext = SharedAccountContextImpl(mainWindow: self.mainWindow, sharedContainerPath: legacyBasePath, basePath: rootPath, encryptionParameters: encryptionParameters, accountManager: accountManager, appLockContext: appLockContext, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings, networkArguments: networkArguments, premiumProductId: buildConfig.premiumIAPProductId, rootPath: rootPath, legacyBasePath: legacyBasePath, apsNotificationToken: self.notificationTokenPromise.get() |> map(Optional.init), voipNotificationToken: self.voipTokenPromise.get() |> map(Optional.init), setNotificationCall: { call in
|
||||||
setPresentationCall?(call)
|
setPresentationCall?(call)
|
||||||
}, navigateToChat: { accountId, peerId, messageId in
|
}, navigateToChat: { accountId, peerId, messageId in
|
||||||
self.openChatWhenReady(accountId: accountId, peerId: peerId, messageId: messageId)
|
self.openChatWhenReady(accountId: accountId, peerId: peerId, messageId: messageId)
|
||||||
|
@ -138,7 +138,7 @@ public final class NotificationViewControllerImpl {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
sharedAccountContext = SharedAccountContextImpl(mainWindow: nil, sharedContainerPath: self.initializationData.appGroupPath, basePath: rootPath, encryptionParameters: ValueBoxEncryptionParameters(forceEncryptionIfNoSet: false, key: ValueBoxEncryptionParameters.Key(data: self.initializationData.encryptionParameters.0)!, salt: ValueBoxEncryptionParameters.Salt(data: self.initializationData.encryptionParameters.1)!), accountManager: accountManager, appLockContext: appLockContext, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: self.initializationData.apiId, apiHash: self.initializationData.apiHash, languagesCategory: self.initializationData.languagesCategory, appVersion: self.initializationData.appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(self.initializationData.bundleData), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), resolvedDeviceName: nil), inAppPurchaseManager: nil, rootPath: rootPath, legacyBasePath: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in })
|
sharedAccountContext = SharedAccountContextImpl(mainWindow: nil, sharedContainerPath: self.initializationData.appGroupPath, basePath: rootPath, encryptionParameters: ValueBoxEncryptionParameters(forceEncryptionIfNoSet: false, key: ValueBoxEncryptionParameters.Key(data: self.initializationData.encryptionParameters.0)!, salt: ValueBoxEncryptionParameters.Salt(data: self.initializationData.encryptionParameters.1)!), accountManager: accountManager, appLockContext: appLockContext, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: self.initializationData.apiId, apiHash: self.initializationData.apiHash, languagesCategory: self.initializationData.languagesCategory, appVersion: self.initializationData.appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(self.initializationData.bundleData), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), resolvedDeviceName: nil), premiumProductId: nil, rootPath: rootPath, legacyBasePath: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in })
|
||||||
|
|
||||||
presentationDataPromise.set(sharedAccountContext!.presentationData)
|
presentationDataPromise.set(sharedAccountContext!.presentationData)
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ public class ShareRootControllerImpl {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
let sharedContext = SharedAccountContextImpl(mainWindow: nil, sharedContainerPath: self.initializationData.appGroupPath, basePath: rootPath, encryptionParameters: ValueBoxEncryptionParameters(forceEncryptionIfNoSet: false, key: ValueBoxEncryptionParameters.Key(data: self.initializationData.encryptionParameters.0)!, salt: ValueBoxEncryptionParameters.Salt(data: self.initializationData.encryptionParameters.1)!), accountManager: accountManager, appLockContext: appLockContext, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: self.initializationData.apiId, apiHash: self.initializationData.apiHash, languagesCategory: self.initializationData.languagesCategory, appVersion: self.initializationData.appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(self.initializationData.bundleData), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), resolvedDeviceName: nil), inAppPurchaseManager: nil, rootPath: rootPath, legacyBasePath: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in })
|
let sharedContext = SharedAccountContextImpl(mainWindow: nil, sharedContainerPath: self.initializationData.appGroupPath, basePath: rootPath, encryptionParameters: ValueBoxEncryptionParameters(forceEncryptionIfNoSet: false, key: ValueBoxEncryptionParameters.Key(data: self.initializationData.encryptionParameters.0)!, salt: ValueBoxEncryptionParameters.Salt(data: self.initializationData.encryptionParameters.1)!), accountManager: accountManager, appLockContext: appLockContext, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: self.initializationData.apiId, apiHash: self.initializationData.apiHash, languagesCategory: self.initializationData.languagesCategory, appVersion: self.initializationData.appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(self.initializationData.bundleData), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), resolvedDeviceName: nil), premiumProductId: nil, rootPath: rootPath, legacyBasePath: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in })
|
||||||
presentationDataPromise.set(sharedContext.presentationData)
|
presentationDataPromise.set(sharedContext.presentationData)
|
||||||
internalContext = InternalContext(sharedContext: sharedContext)
|
internalContext = InternalContext(sharedContext: sharedContext)
|
||||||
globalInternalContext = internalContext
|
globalInternalContext = internalContext
|
||||||
|
@ -90,7 +90,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
public let contactDataManager: DeviceContactDataManager?
|
public let contactDataManager: DeviceContactDataManager?
|
||||||
public let locationManager: DeviceLocationManager?
|
public let locationManager: DeviceLocationManager?
|
||||||
public var callManager: PresentationCallManager?
|
public var callManager: PresentationCallManager?
|
||||||
public var inAppPurchaseManager: InAppPurchaseManager?
|
let premiumProductId: String?
|
||||||
|
|
||||||
private var callDisposable: Disposable?
|
private var callDisposable: Disposable?
|
||||||
private var callStateDisposable: Disposable?
|
private var callStateDisposable: Disposable?
|
||||||
@ -164,7 +164,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
private var spotlightDataContext: SpotlightDataContext?
|
private var spotlightDataContext: SpotlightDataContext?
|
||||||
private var widgetDataContext: WidgetDataContext?
|
private var widgetDataContext: WidgetDataContext?
|
||||||
|
|
||||||
public init(mainWindow: Window1?, sharedContainerPath: String, basePath: String, encryptionParameters: ValueBoxEncryptionParameters, accountManager: AccountManager<TelegramAccountManagerTypes>, appLockContext: AppLockContext, applicationBindings: TelegramApplicationBindings, initialPresentationDataAndSettings: InitialPresentationDataAndSettings, networkArguments: NetworkInitializationArguments, inAppPurchaseManager: InAppPurchaseManager?, rootPath: String, legacyBasePath: String?, apsNotificationToken: Signal<Data?, NoError>, voipNotificationToken: Signal<Data?, NoError>, setNotificationCall: @escaping (PresentationCall?) -> Void, navigateToChat: @escaping (AccountRecordId, PeerId, MessageId?) -> Void, displayUpgradeProgress: @escaping (Float?) -> Void = { _ in }) {
|
public init(mainWindow: Window1?, sharedContainerPath: String, basePath: String, encryptionParameters: ValueBoxEncryptionParameters, accountManager: AccountManager<TelegramAccountManagerTypes>, appLockContext: AppLockContext, applicationBindings: TelegramApplicationBindings, initialPresentationDataAndSettings: InitialPresentationDataAndSettings, networkArguments: NetworkInitializationArguments, premiumProductId: String?, rootPath: String, legacyBasePath: String?, apsNotificationToken: Signal<Data?, NoError>, voipNotificationToken: Signal<Data?, NoError>, setNotificationCall: @escaping (PresentationCall?) -> Void, navigateToChat: @escaping (AccountRecordId, PeerId, MessageId?) -> Void, displayUpgradeProgress: @escaping (Float?) -> Void = { _ in }) {
|
||||||
assert(Queue.mainQueue().isCurrent())
|
assert(Queue.mainQueue().isCurrent())
|
||||||
|
|
||||||
precondition(!testHasInstance)
|
precondition(!testHasInstance)
|
||||||
@ -178,7 +178,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
self.navigateToChatImpl = navigateToChat
|
self.navigateToChatImpl = navigateToChat
|
||||||
self.displayUpgradeProgress = displayUpgradeProgress
|
self.displayUpgradeProgress = displayUpgradeProgress
|
||||||
self.appLockContext = appLockContext
|
self.appLockContext = appLockContext
|
||||||
self.inAppPurchaseManager = inAppPurchaseManager
|
self.premiumProductId = premiumProductId
|
||||||
|
|
||||||
self.accountManager.mediaBox.fetchCachedResourceRepresentation = { (resource, representation) -> Signal<CachedMediaResourceRepresentationResult, NoError> in
|
self.accountManager.mediaBox.fetchCachedResourceRepresentation = { (resource, representation) -> Signal<CachedMediaResourceRepresentationResult, NoError> in
|
||||||
return fetchCachedSharedResourceRepresentation(accountManager: accountManager, resource: resource, representation: representation)
|
return fetchCachedSharedResourceRepresentation(accountManager: accountManager, resource: resource, representation: representation)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user