mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 05:51:42 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
efaa2a71af
@ -104,9 +104,8 @@
|
||||
"PUSH_MESSAGES_1" = "%1$@|sent you a message";
|
||||
"PUSH_MESSAGES_any" = "%1$@|sent you %2$d messages";
|
||||
"PUSH_ALBUM" = "%1$@|sent you an album";
|
||||
"PUSH_MESSAGE_DOCS" = "%1$@|sent you %2$d files";
|
||||
"PUSH_MESSAGE_DOCS_1" = "%1$@|sent you a file";
|
||||
"PUSH_MESSAGE_DOCS_any" = "%1$@|sent you %2$d files";
|
||||
"PUSH_MESSAGE_FILES_1" = "%1$@|sent you a file";
|
||||
"PUSH_MESSAGE_FILES_any" = "%1$@|sent you %2$d files";
|
||||
|
||||
|
||||
"PUSH_CHANNEL_MESSAGE_TEXT" = "%1$@|%2$@";
|
||||
|
||||
@ -565,7 +565,18 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
||||
ensureTipInputVisibleImpl?()
|
||||
})
|
||||
|
||||
let signal: Signal<(ItemListPresentationData, (ItemListNodeState, Any)), NoError> = combineLatest(context.sharedContext.presentationData, self.state.get(), paymentFormAndInfo.get(), context.account.postbox.loadedPeerWithId(messageId.peerId))
|
||||
let paymentBotPeer = paymentFormAndInfo.get()
|
||||
|> map { paymentFormAndInfo -> PeerId? in
|
||||
return paymentFormAndInfo?.0.paymentBotId
|
||||
}
|
||||
|> distinctUntilChanged
|
||||
|> mapToSignal { peerId -> Signal<Peer?, NoError> in
|
||||
return context.account.postbox.transaction { transaction -> Peer? in
|
||||
return peerId.flatMap(transaction.getPeer)
|
||||
}
|
||||
}
|
||||
|
||||
let signal: Signal<(ItemListPresentationData, (ItemListNodeState, Any)), NoError> = combineLatest(queue: .mainQueue(), context.sharedContext.presentationData, self.state.get(), paymentFormAndInfo.get(), paymentBotPeer)
|
||||
|> map { presentationData, state, paymentFormAndInfo, botPeer -> (ItemListPresentationData, (ItemListNodeState, Any)) in
|
||||
let nodeState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: botCheckoutControllerEntries(presentationData: presentationData, state: state, invoice: invoice, paymentForm: paymentFormAndInfo?.0, formInfo: paymentFormAndInfo?.1, validatedFormInfo: paymentFormAndInfo?.2, currentShippingOptionId: paymentFormAndInfo?.3, currentPaymentMethod: paymentFormAndInfo?.4, currentTip: paymentFormAndInfo?.5, botPeer: botPeer), style: .blocks, focusItemTag: nil, emptyStateItem: nil, animateChanges: false)
|
||||
|
||||
@ -1184,7 +1195,7 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
||||
}
|
||||
return nil
|
||||
}
|
||||
let _ = (combineLatest(ApplicationSpecificNotice.getBotPaymentLiability(accountManager: self.context.sharedContext.accountManager, peerId: self.messageId.peerId), botPeer, self.context.account.postbox.loadedPeerWithId(paymentForm.providerId))
|
||||
let _ = (combineLatest(ApplicationSpecificNotice.getBotPaymentLiability(accountManager: self.context.sharedContext.accountManager, peerId: paymentForm.paymentBotId), botPeer, self.context.account.postbox.loadedPeerWithId(paymentForm.providerId))
|
||||
|> deliverOnMainQueue).start(next: { [weak self] value, botPeer, providerPeer in
|
||||
if let strongSelf = self, let botPeer = botPeer {
|
||||
if value {
|
||||
|
||||
@ -348,7 +348,7 @@ final class MutableGlobalMessageTagsView: MutablePostboxView {
|
||||
}
|
||||
|
||||
if let later = self.later {
|
||||
addedEntries += postbox.messageHistoryTable.laterEntries(globalTagMask: self.globalTag, index: later.predecessor(), count: self.count).map { entry -> InternalGlobalMessageTagsEntry in
|
||||
addedEntries += postbox.messageHistoryTable.laterEntries(globalTagMask: self.globalTag, index: later.globalPredecessor(), count: self.count).map { entry -> InternalGlobalMessageTagsEntry in
|
||||
switch entry {
|
||||
case let .message(message):
|
||||
return .intermediateMessage(message)
|
||||
@ -358,7 +358,7 @@ final class MutableGlobalMessageTagsView: MutablePostboxView {
|
||||
}
|
||||
}
|
||||
if let earlier = self.earlier {
|
||||
addedEntries += postbox.messageHistoryTable.earlierEntries(globalTagMask: self.globalTag, index: earlier.successor(), count: self.count).map { entry -> InternalGlobalMessageTagsEntry in
|
||||
addedEntries += postbox.messageHistoryTable.earlierEntries(globalTagMask: self.globalTag, index: earlier.globalSuccessor(), count: self.count).map { entry -> InternalGlobalMessageTagsEntry in
|
||||
switch entry {
|
||||
case let .message(message):
|
||||
return .intermediateMessage(message)
|
||||
|
||||
@ -103,12 +103,12 @@ public struct MessageIndex: Comparable, Hashable {
|
||||
self.timestamp = timestamp
|
||||
}
|
||||
|
||||
public func predecessor() -> MessageIndex {
|
||||
public func globalPredecessor() -> MessageIndex {
|
||||
let previousPeerId = self.id.peerId.predecessor
|
||||
if previousPeerId != self.id.peerId {
|
||||
return MessageIndex(id: MessageId(peerId: previousPeerId, namespace: self.id.namespace, id: self.id.id), timestamp: self.timestamp)
|
||||
} else if self.id.id != 0 {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace, id: self.id.id), timestamp: self.timestamp)
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace, id: self.id.id - 1), timestamp: self.timestamp)
|
||||
} else if self.id.namespace != 0 {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace - 1, id: Int32.max - 1), timestamp: self.timestamp)
|
||||
} else if self.timestamp != 0 {
|
||||
@ -118,7 +118,19 @@ public struct MessageIndex: Comparable, Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
public func successor() -> MessageIndex {
|
||||
public func peerLocalPredecessor() -> MessageIndex {
|
||||
if self.id.id != 0 {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace, id: self.id.id - 1), timestamp: self.timestamp)
|
||||
} else if self.id.namespace != 0 {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace - 1, id: Int32.max - 1), timestamp: self.timestamp)
|
||||
} else if self.timestamp != 0 {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: Int32(Int8.max) - 1, id: Int32.max - 1), timestamp: self.timestamp - 1)
|
||||
} else {
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
public func globalSuccessor() -> MessageIndex {
|
||||
let nextPeerId = self.id.peerId.successor
|
||||
if nextPeerId != self.id.peerId {
|
||||
return MessageIndex(id: MessageId(peerId: nextPeerId, namespace: self.id.namespace, id: self.id.id), timestamp: self.timestamp)
|
||||
@ -127,6 +139,10 @@ public struct MessageIndex: Comparable, Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
public func peerLocalSuccessor() -> MessageIndex {
|
||||
return MessageIndex(id: MessageId(peerId: self.id.peerId, namespace: self.id.namespace, id: self.id.id == Int32.max ? self.id.id : (self.id.id + 1)), timestamp: self.timestamp)
|
||||
}
|
||||
|
||||
public static func absoluteUpperBound() -> MessageIndex {
|
||||
return MessageIndex(id: MessageId(peerId: PeerId.max, namespace: Int32(Int8.max), id: Int32.max), timestamp: Int32.max)
|
||||
}
|
||||
@ -217,11 +233,11 @@ public struct ChatListIndex: Comparable, Hashable {
|
||||
}
|
||||
|
||||
public var predecessor: ChatListIndex {
|
||||
return ChatListIndex(pinningIndex: self.pinningIndex, messageIndex: self.messageIndex.predecessor())
|
||||
return ChatListIndex(pinningIndex: self.pinningIndex, messageIndex: self.messageIndex.globalPredecessor())
|
||||
}
|
||||
|
||||
public var successor: ChatListIndex {
|
||||
return ChatListIndex(pinningIndex: self.pinningIndex, messageIndex: self.messageIndex.successor())
|
||||
return ChatListIndex(pinningIndex: self.pinningIndex, messageIndex: self.messageIndex.globalSuccessor())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -315,7 +315,7 @@ final class MessageHistoryReadStateTable: Table {
|
||||
readPastTopIndex = true
|
||||
}
|
||||
if maxIncomingReadIndex < messageIndex || markedUnread || readPastTopIndex {
|
||||
let (realDeltaCount, holes, messageIds) = incomingStatsInRange(maxIncomingReadIndex.successor(), messageIndex)
|
||||
let (realDeltaCount, holes, messageIds) = incomingStatsInRange(maxIncomingReadIndex.peerLocalSuccessor(), messageIndex)
|
||||
var deltaCount = realDeltaCount
|
||||
if readPastTopIndex {
|
||||
deltaCount = max(Int(count), deltaCount)
|
||||
@ -366,7 +366,7 @@ final class MessageHistoryReadStateTable: Table {
|
||||
break
|
||||
case let .indexBased(maxIncomingReadIndex, maxOutgoingReadIndex, count, markedUnread):
|
||||
if maxOutgoingReadIndex < messageIndex {
|
||||
let messageIds: [MessageId] = outgoingIndexStatsInRange(maxOutgoingReadIndex.successor(), messageIndex)
|
||||
let messageIds: [MessageId] = outgoingIndexStatsInRange(maxOutgoingReadIndex.peerLocalSuccessor(), messageIndex)
|
||||
|
||||
self.markReadStatesAsUpdated(messageIndex.id.peerId, namespaces: states.namespaces)
|
||||
states.namespaces[messageIndex.id.namespace] = .indexBased(maxIncomingReadIndex: maxIncomingReadIndex, maxOutgoingReadIndex: messageIndex, count: count, markedUnread: markedUnread)
|
||||
|
||||
@ -1053,7 +1053,7 @@ public final class MessageHistoryView {
|
||||
index = 0
|
||||
for entry in entries {
|
||||
if entry.index.id.peerId == peerId && entry.index.id.namespace == namespace {
|
||||
maxNamespaceIndex = entry.index.predecessor()
|
||||
maxNamespaceIndex = entry.index.peerLocalPredecessor()
|
||||
break
|
||||
}
|
||||
index += 1
|
||||
@ -1109,7 +1109,7 @@ public final class MessageHistoryView {
|
||||
index = 0
|
||||
for entry in entries {
|
||||
if entry.index.id.peerId == peerId && entry.index.id.namespace == namespace {
|
||||
maxNamespaceIndex = entry.index.predecessor()
|
||||
maxNamespaceIndex = entry.index.peerLocalPredecessor()
|
||||
break
|
||||
}
|
||||
index += 1
|
||||
|
||||
@ -468,11 +468,11 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if items.higherThanAnchor.count == 0 {
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... MessageIndex.absoluteUpperBound())
|
||||
} else {
|
||||
let clipIndex = items.higherThanAnchor[0].index.predecessor()
|
||||
let clipIndex = items.higherThanAnchor[0].index.peerLocalPredecessor()
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... clipIndex)
|
||||
}
|
||||
} else {
|
||||
let clipIndex = items.lowerOrAtAnchor[0].index.predecessor()
|
||||
let clipIndex = items.lowerOrAtAnchor[0].index.peerLocalPredecessor()
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... clipIndex)
|
||||
}
|
||||
} else {
|
||||
@ -480,7 +480,7 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if items.higherThanAnchor.count == 0 {
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... MessageIndex.absoluteUpperBound())
|
||||
} else {
|
||||
let clipIndex = items.higherThanAnchor[0].index.predecessor()
|
||||
let clipIndex = items.higherThanAnchor[0].index.peerLocalPredecessor()
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... clipIndex)
|
||||
}
|
||||
} else {
|
||||
@ -488,7 +488,7 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if indices.contains(Int(items.lowerOrAtAnchor[i + 1].index.id.id)) {
|
||||
clipIndex = items.lowerOrAtAnchor[i + 1].index
|
||||
} else {
|
||||
clipIndex = items.lowerOrAtAnchor[i + 1].index.predecessor()
|
||||
clipIndex = items.lowerOrAtAnchor[i + 1].index.peerLocalPredecessor()
|
||||
}
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... clipIndex)
|
||||
}
|
||||
@ -536,11 +536,11 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if items.lowerOrAtAnchor.count == 0 {
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... MessageIndex.absoluteUpperBound())
|
||||
} else {
|
||||
let clipIndex = items.lowerOrAtAnchor[items.lowerOrAtAnchor.count - 1].index.successor()
|
||||
let clipIndex = items.lowerOrAtAnchor[items.lowerOrAtAnchor.count - 1].index.peerLocalSuccessor()
|
||||
clipRanges.append(clipIndex ... MessageIndex.absoluteUpperBound())
|
||||
}
|
||||
} else {
|
||||
let clipIndex = items.higherThanAnchor[items.higherThanAnchor.count - 1].index.successor()
|
||||
let clipIndex = items.higherThanAnchor[items.higherThanAnchor.count - 1].index.peerLocalSuccessor()
|
||||
clipRanges.append(clipIndex ... MessageIndex.absoluteUpperBound())
|
||||
}
|
||||
} else {
|
||||
@ -548,7 +548,7 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if items.lowerOrAtAnchor.count == 0 {
|
||||
clipRanges.append(MessageIndex.absoluteLowerBound() ... MessageIndex.absoluteUpperBound())
|
||||
} else {
|
||||
let clipIndex = items.lowerOrAtAnchor[items.lowerOrAtAnchor.count - 1].index.successor()
|
||||
let clipIndex = items.lowerOrAtAnchor[items.lowerOrAtAnchor.count - 1].index.peerLocalSuccessor()
|
||||
clipRanges.append(clipIndex ... MessageIndex.absoluteUpperBound())
|
||||
}
|
||||
} else {
|
||||
@ -556,7 +556,7 @@ private func sampleHoleRanges(input: MessageHistoryInput, orderedEntriesBySpace:
|
||||
if indices.contains(Int(items.higherThanAnchor[i - 1].index.id.id)) {
|
||||
clipIndex = items.higherThanAnchor[i - 1].index
|
||||
} else {
|
||||
clipIndex = items.higherThanAnchor[i - 1].index.successor()
|
||||
clipIndex = items.higherThanAnchor[i - 1].index.peerLocalSuccessor()
|
||||
}
|
||||
clipRanges.append(clipIndex ... MessageIndex.absoluteUpperBound())
|
||||
}
|
||||
|
||||
@ -434,7 +434,7 @@ public func dataPrivacyController(context: AccountContext) -> ViewController {
|
||||
return state
|
||||
}
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.Privacy_ContactsSync_ContactsDeleted), elevatedLayout: false, action: { _ in return false }))
|
||||
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.Privacy_ContactsReset_ContactsDeleted), elevatedLayout: false, action: { _ in return false }))
|
||||
}))
|
||||
}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {})]))
|
||||
}
|
||||
|
||||
@ -106,6 +106,7 @@ public struct BotPaymentForm : Equatable {
|
||||
public let canSaveCredentials: Bool
|
||||
public let passwordMissing: Bool
|
||||
public let invoice: BotPaymentInvoice
|
||||
public let paymentBotId: PeerId
|
||||
public let providerId: PeerId
|
||||
public let url: String
|
||||
public let nativeProvider: BotPaymentNativeProvider?
|
||||
@ -198,7 +199,7 @@ public func fetchBotPaymentForm(postbox: Postbox, network: Network, messageId: M
|
||||
|> mapToSignal { result -> Signal<BotPaymentForm, BotPaymentFormRequestError> in
|
||||
return postbox.transaction { transaction -> BotPaymentForm in
|
||||
switch result {
|
||||
case let .paymentForm(flags, id, _, invoice, providerId, url, nativeProvider, nativeParams, savedInfo, savedCredentials, apiUsers):
|
||||
case let .paymentForm(flags, id, botId, invoice, providerId, url, nativeProvider, nativeParams, savedInfo, savedCredentials, apiUsers):
|
||||
var peers: [Peer] = []
|
||||
for user in apiUsers {
|
||||
let parsed = TelegramUser(user: user)
|
||||
@ -224,7 +225,7 @@ public func fetchBotPaymentForm(postbox: Postbox, network: Network, messageId: M
|
||||
parsedSavedCredentials = .card(id: id, title: title)
|
||||
}
|
||||
}
|
||||
return BotPaymentForm(id: id, canSaveCredentials: (flags & (1 << 2)) != 0, passwordMissing: (flags & (1 << 3)) != 0, invoice: parsedInvoice, providerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(providerId)), url: url, nativeProvider: parsedNativeProvider, savedInfo: parsedSavedInfo, savedCredentials: parsedSavedCredentials)
|
||||
return BotPaymentForm(id: id, canSaveCredentials: (flags & (1 << 2)) != 0, passwordMissing: (flags & (1 << 3)) != 0, invoice: parsedInvoice, paymentBotId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(botId)), providerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(providerId)), url: url, nativeProvider: parsedNativeProvider, savedInfo: parsedSavedInfo, savedCredentials: parsedSavedCredentials)
|
||||
}
|
||||
}
|
||||
|> mapError { _ -> BotPaymentFormRequestError in }
|
||||
@ -429,7 +430,7 @@ public struct BotPaymentReceipt : Equatable {
|
||||
public let credentialsTitle: String
|
||||
public let invoiceMedia: TelegramMediaInvoice
|
||||
public let tipAmount: Int64?
|
||||
|
||||
public let botPaymentId: PeerId
|
||||
public static func ==(lhs: BotPaymentReceipt, rhs: BotPaymentReceipt) -> Bool {
|
||||
if lhs.invoice != rhs.invoice {
|
||||
return false
|
||||
@ -449,6 +450,9 @@ public struct BotPaymentReceipt : Equatable {
|
||||
if lhs.tipAmount != rhs.tipAmount {
|
||||
return false
|
||||
}
|
||||
if lhs.botPaymentId != rhs.botPaymentId {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -516,7 +520,9 @@ public func requestBotPaymentReceipt(account: Account, messageId: MessageId) ->
|
||||
flags: []
|
||||
)
|
||||
|
||||
return BotPaymentReceipt(invoice: parsedInvoice, info: parsedInfo, shippingOption: shippingOption, credentialsTitle: credentialsTitle, invoiceMedia: invoiceMedia, tipAmount: tipAmount)
|
||||
let botPaymentId = PeerId.init(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(botId))
|
||||
|
||||
return BotPaymentReceipt(invoice: parsedInvoice, info: parsedInfo, shippingOption: shippingOption, credentialsTitle: credentialsTitle, invoiceMedia: invoiceMedia, tipAmount: tipAmount, botPaymentId: botPaymentId)
|
||||
}
|
||||
}
|
||||
|> castError(RequestBotPaymentReceiptError.self)
|
||||
|
||||
@ -698,7 +698,7 @@ func fetchCallListHole(network: Network, postbox: Postbox, accountPeerId: PeerId
|
||||
|
||||
var updatedIndex: MessageIndex?
|
||||
if let topIndex = topIndex {
|
||||
updatedIndex = topIndex.predecessor()
|
||||
updatedIndex = topIndex.globalPredecessor()
|
||||
}
|
||||
|
||||
transaction.replaceGlobalMessageTagsHole(globalTags: [.Calls, .MissedCalls], index: holeIndex, with: updatedIndex, messages: storeMessages)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -341,7 +341,7 @@ final class ChatMessageNotificationItemNode: NotificationItemNode {
|
||||
messageText = rawText
|
||||
}
|
||||
case .file:
|
||||
let rawText = presentationData.strings.PUSH_MESSAGE_DOCS(Int32(item.messages.count), peer.displayTitle(strings: item.strings, displayOrder: item.nameDisplayOrder), Int32(item.messages.count))
|
||||
let rawText = presentationData.strings.PUSH_MESSAGE_FILES(Int32(item.messages.count), peer.displayTitle(strings: item.strings, displayOrder: item.nameDisplayOrder), Int32(item.messages.count))
|
||||
if let index = rawText.firstIndex(of: "|") {
|
||||
title = String(rawText[rawText.startIndex ..< index])
|
||||
messageText = String(rawText[rawText.index(after: index)...])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user