mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Animated emoji improvements
This commit is contained in:
@@ -59,7 +59,7 @@ public enum RestoreAppStoreReceiptError {
|
||||
}
|
||||
|
||||
func _internal_canPurchasePremium(account: Account) -> Signal<Bool, NoError> {
|
||||
return account.network.request(Api.functions.payments.canPurchasePremium())
|
||||
return account.network.request(Api.functions.payments.canPurchasePremium(purpose: .inputStorePaymentPremiumSubscription(flags: 0)))
|
||||
|> map { result -> Bool in
|
||||
switch result {
|
||||
case .boolTrue:
|
||||
|
||||
@@ -213,7 +213,7 @@ func _internal_fetchBotPaymentInvoice(postbox: Postbox, network: Network, source
|
||||
|> mapToSignal { result -> Signal<TelegramMediaInvoice, BotPaymentFormRequestError> in
|
||||
return postbox.transaction { transaction -> TelegramMediaInvoice in
|
||||
switch result {
|
||||
case let .paymentForm(_, _, _, title, description, photo, invoice, _, _, _, _, _, _, _):
|
||||
case let .paymentForm(_, _, _, title, description, photo, invoice, _, _, _, _, _, _, _, _):
|
||||
let parsedInvoice = BotPaymentInvoice(apiInvoice: invoice)
|
||||
|
||||
var parsedFlags = TelegramMediaInvoiceFlags()
|
||||
@@ -266,10 +266,11 @@ func _internal_fetchBotPaymentForm(postbox: Postbox, network: Network, source: B
|
||||
|> mapToSignal { result -> Signal<BotPaymentForm, BotPaymentFormRequestError> in
|
||||
return postbox.transaction { transaction -> BotPaymentForm in
|
||||
switch result {
|
||||
case let .paymentForm(flags, id, botId, title, description, photo, invoice, providerId, url, nativeProvider, nativeParams, savedInfo, savedCredentials, apiUsers):
|
||||
case let .paymentForm(flags, id, botId, title, description, photo, invoice, providerId, url, nativeProvider, nativeParams, additionalMethods, savedInfo, savedCredentials, apiUsers):
|
||||
let _ = title
|
||||
let _ = description
|
||||
let _ = photo
|
||||
let _ = additionalMethods
|
||||
|
||||
var peers: [Peer] = []
|
||||
for user in apiUsers {
|
||||
|
||||
@@ -306,7 +306,7 @@ func _internal_searchStickerSetsRemotely(network: Network, query: String) -> Sig
|
||||
case let .foundStickerSets(_, sets: sets):
|
||||
var result = FoundStickerSets()
|
||||
for set in sets {
|
||||
let parsed = parsePreviewStickerSet(set)
|
||||
let parsed = parsePreviewStickerSet(set, namespace: Namespaces.ItemCollection.CloudStickerPacks)
|
||||
let values = parsed.1.map({ ItemCollectionViewEntry(index: ItemCollectionViewEntryIndex(collectionIndex: index, collectionId: parsed.0.id, itemIndex: $0.index), item: $0) })
|
||||
result = result.withUpdatedInfosAndEntries(infos: [(parsed.0.id, parsed.0, parsed.1.first, false)], entries: values)
|
||||
index += 1
|
||||
|
||||
@@ -105,7 +105,7 @@ func _internal_stickerPacksAttachedToMedia(account: Account, media: AnyMediaRefe
|
||||
|> map { result -> [StickerPackReference] in
|
||||
return result.map { pack in
|
||||
switch pack {
|
||||
case let .stickerSetCovered(set, _), let .stickerSetMultiCovered(set, _):
|
||||
case let .stickerSetCovered(set, _), let .stickerSetMultiCovered(set, _), let .stickerSetFullCovered(set, _, _):
|
||||
let info = StickerPackCollectionInfo(apiSet: set, namespace: Namespaces.ItemCollection.CloudStickerPacks)
|
||||
return .id(id: info.id.id, accessHash: info.accessHash)
|
||||
}
|
||||
|
||||
@@ -140,64 +140,69 @@ public final class CoveredStickerSet : Equatable {
|
||||
func _internal_installStickerSetInteractively(account: Account, info: StickerPackCollectionInfo, items: [ItemCollectionItem]) -> Signal<InstallStickerSetResult, InstallStickerSetError> {
|
||||
return account.network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash), archived: .boolFalse)) |> mapError { _ -> InstallStickerSetError in
|
||||
return .generic
|
||||
} |> mapToSignal { result -> Signal<InstallStickerSetResult, InstallStickerSetError> in
|
||||
let addResult:InstallStickerSetResult
|
||||
switch result {
|
||||
case .stickerSetInstallResultSuccess:
|
||||
addResult = .successful
|
||||
case let .stickerSetInstallResultArchive(sets: archived):
|
||||
var coveredSets:[CoveredStickerSet] = []
|
||||
for archived in archived {
|
||||
let apiDocuments:[Api.Document]
|
||||
let apiSet:Api.StickerSet
|
||||
switch archived {
|
||||
case let .stickerSetCovered(set: set, cover: cover):
|
||||
apiSet = set
|
||||
apiDocuments = [cover]
|
||||
case let .stickerSetMultiCovered(set: set, covers: covers):
|
||||
apiSet = set
|
||||
apiDocuments = covers
|
||||
}
|
||||
|> mapToSignal { result -> Signal<InstallStickerSetResult, InstallStickerSetError> in
|
||||
let addResult:InstallStickerSetResult
|
||||
switch result {
|
||||
case .stickerSetInstallResultSuccess:
|
||||
addResult = .successful
|
||||
case let .stickerSetInstallResultArchive(sets: archived):
|
||||
var coveredSets:[CoveredStickerSet] = []
|
||||
for archived in archived {
|
||||
let apiDocuments:[Api.Document]
|
||||
let apiSet:Api.StickerSet
|
||||
switch archived {
|
||||
case let .stickerSetCovered(set: set, cover: cover):
|
||||
apiSet = set
|
||||
apiDocuments = [cover]
|
||||
case let .stickerSetMultiCovered(set: set, covers: covers):
|
||||
apiSet = set
|
||||
apiDocuments = covers
|
||||
case let .stickerSetFullCovered(set, _, documents):
|
||||
apiSet = set
|
||||
apiDocuments = documents
|
||||
}
|
||||
|
||||
let info = StickerPackCollectionInfo(apiSet: apiSet, namespace: Namespaces.ItemCollection.CloudStickerPacks)
|
||||
|
||||
var items:[StickerPackItem] = []
|
||||
for apiDocument in apiDocuments {
|
||||
if let file = telegramMediaFileFromApiDocument(apiDocument), let id = file.id {
|
||||
items.append(StickerPackItem(index: ItemCollectionItemIndex(index: Int32(items.count), id: id.id), file: file, indexKeys: []))
|
||||
}
|
||||
|
||||
let info = StickerPackCollectionInfo(apiSet: apiSet, namespace: Namespaces.ItemCollection.CloudStickerPacks)
|
||||
|
||||
var items:[StickerPackItem] = []
|
||||
for apiDocument in apiDocuments {
|
||||
if let file = telegramMediaFileFromApiDocument(apiDocument), let id = file.id {
|
||||
items.append(StickerPackItem(index: ItemCollectionItemIndex(index: Int32(items.count), id: id.id), file: file, indexKeys: []))
|
||||
}
|
||||
coveredSets.append(CoveredStickerSet(info: info, items: items))
|
||||
}
|
||||
addResult = .archived(coveredSets)
|
||||
}
|
||||
|
||||
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
var collections = transaction.getCollectionsItems(namespace: info.id.namespace)
|
||||
|
||||
var removableIndexes:[Int] = []
|
||||
for i in 0 ..< collections.count {
|
||||
if collections[i].0 == info.id {
|
||||
removableIndexes.append(i)
|
||||
}
|
||||
if case let .archived(sets) = addResult {
|
||||
for set in sets {
|
||||
if collections[i].0 == set.info.id {
|
||||
removableIndexes.append(i)
|
||||
}
|
||||
}
|
||||
coveredSets.append(CoveredStickerSet(info: info, items: items))
|
||||
}
|
||||
addResult = .archived(coveredSets)
|
||||
}
|
||||
|
||||
for index in removableIndexes.reversed() {
|
||||
collections.remove(at: index)
|
||||
}
|
||||
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
var collections = transaction.getCollectionsItems(namespace: info.id.namespace)
|
||||
|
||||
var removableIndexes:[Int] = []
|
||||
for i in 0 ..< collections.count {
|
||||
if collections[i].0 == info.id {
|
||||
removableIndexes.append(i)
|
||||
}
|
||||
if case let .archived(sets) = addResult {
|
||||
for set in sets {
|
||||
if collections[i].0 == set.info.id {
|
||||
removableIndexes.append(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for index in removableIndexes.reversed() {
|
||||
collections.remove(at: index)
|
||||
}
|
||||
|
||||
collections.insert((info.id, info, items), at: 0)
|
||||
|
||||
transaction.replaceItemCollections(namespace: info.id.namespace, itemCollections: collections)
|
||||
} |> map { _ in return addResult} |> mapError { _ -> InstallStickerSetError in }
|
||||
collections.insert((info.id, info, items), at: 0)
|
||||
|
||||
transaction.replaceItemCollections(namespace: info.id.namespace, itemCollections: collections)
|
||||
}
|
||||
|> map { _ in return addResult} |> mapError { _ -> InstallStickerSetError in }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,6 +133,13 @@ public extension TelegramEngine {
|
||||
|> ignoreValues
|
||||
}
|
||||
|
||||
public func clearRecentlyUsedEmoji() -> Signal<Never, NoError> {
|
||||
return self.account.postbox.transaction { transaction -> Void in
|
||||
_internal_clearRecentlyUsedEmoji(transaction: transaction)
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
|
||||
public func reorderStickerPacks(namespace: ItemCollectionId.Namespace, itemIds: [ItemCollectionId]) -> Signal<Never, NoError> {
|
||||
return self.account.postbox.transaction { transaction -> Void in
|
||||
let infos = transaction.getItemCollectionsInfos(namespace: namespace)
|
||||
|
||||
Reference in New Issue
Block a user