mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Update API [skip ci]
This commit is contained in:
@@ -48,6 +48,10 @@ private final class UpdatedRevenueBalancesSubscriberContext {
|
||||
let subscribers = Bag<([PeerId: RevenueStats.Balances]) -> Void>()
|
||||
}
|
||||
|
||||
private final class UpdatedStarsBalanceSubscriberContext {
|
||||
let subscribers = Bag<([PeerId: Int64]) -> Void>()
|
||||
}
|
||||
|
||||
public enum DeletedMessageId: Hashable {
|
||||
case global(Int32)
|
||||
case messageId(MessageId)
|
||||
@@ -282,6 +286,7 @@ public final class AccountStateManager {
|
||||
private var updatedWebpageContexts: [MediaId: UpdatedWebpageSubscriberContext] = [:]
|
||||
private var updatedPeersNearbyContext = UpdatedPeersNearbySubscriberContext()
|
||||
private var updatedRevenueBalancesContext = UpdatedRevenueBalancesSubscriberContext()
|
||||
private var updatedStarsBalanceContext = UpdatedStarsBalanceSubscriberContext()
|
||||
|
||||
private let delayNotificatonsUntil = Atomic<Int32?>(value: nil)
|
||||
private let appliedMaxMessageIdPromise = Promise<Int32?>(nil)
|
||||
@@ -1030,6 +1035,9 @@ public final class AccountStateManager {
|
||||
if !events.updatedRevenueBalances.isEmpty {
|
||||
strongSelf.notifyUpdatedRevenueBalances(events.updatedRevenueBalances)
|
||||
}
|
||||
if !events.updatedStarsBalance.isEmpty {
|
||||
strongSelf.notifyUpdatedStarsBalance(events.updatedStarsBalance)
|
||||
}
|
||||
if !events.updatedCalls.isEmpty {
|
||||
for call in events.updatedCalls {
|
||||
strongSelf.callSessionManager?.updateSession(call, completion: { _ in })
|
||||
@@ -1629,6 +1637,33 @@ public final class AccountStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
public func updatedStarsBalance() -> Signal<[PeerId: Int64], NoError> {
|
||||
let queue = self.queue
|
||||
return Signal { [weak self] subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
queue.async {
|
||||
if let strongSelf = self {
|
||||
let index = strongSelf.updatedStarsBalanceContext.subscribers.add({ starsBalance in
|
||||
subscriber.putNext(starsBalance)
|
||||
})
|
||||
|
||||
disposable.set(ActionDisposable {
|
||||
if let strongSelf = self {
|
||||
strongSelf.updatedStarsBalanceContext.subscribers.remove(index)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return disposable
|
||||
}
|
||||
}
|
||||
|
||||
private func notifyUpdatedStarsBalance(_ updatedStarsBalance: [PeerId: Int64]) {
|
||||
for subscriber in self.updatedStarsBalanceContext.subscribers.copyItems() {
|
||||
subscriber(updatedStarsBalance)
|
||||
}
|
||||
}
|
||||
|
||||
func notifyDeletedMessages(messageIds: [MessageId]) {
|
||||
self.deletedMessagesPipe.putNext(messageIds.map { .messageId($0) })
|
||||
}
|
||||
@@ -1921,6 +1956,12 @@ public final class AccountStateManager {
|
||||
return impl.updatedRevenueBalances().start(next: subscriber.putNext, error: subscriber.putError, completed: subscriber.putCompletion)
|
||||
}
|
||||
}
|
||||
|
||||
public func updatedStarsBalance() -> Signal<[PeerId: Int64], NoError> {
|
||||
return self.impl.signalWith { impl, subscriber in
|
||||
return impl.updatedStarsBalance().start(next: subscriber.putNext, error: subscriber.putError, completed: subscriber.putCompletion)
|
||||
}
|
||||
}
|
||||
|
||||
func addCustomOperation<T, E>(_ f: Signal<T, E>) -> Signal<T, E> {
|
||||
return self.impl.signalWith { impl, subscriber in
|
||||
|
||||
Reference in New Issue
Block a user