mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
e13934209c
commit
3f8152d0b1
@ -2516,6 +2516,8 @@ public final class ShareController: ViewController {
|
||||
peers.append(EngineRenderedPeer(entryData.renderedPeer))
|
||||
if let user = peer as? TelegramUser, user.flags.contains(.requirePremium) || user.flags.contains(.requireStars) {
|
||||
possiblePremiumRequiredPeers.insert(user.id)
|
||||
} else if let channel = peer as? TelegramChannel, let _ = channel.sendPaidMessageStars {
|
||||
possiblePremiumRequiredPeers.insert(channel.id)
|
||||
}
|
||||
}
|
||||
default:
|
||||
@ -2529,6 +2531,7 @@ public final class ShareController: ViewController {
|
||||
keys.append(peerPresencesKey)
|
||||
|
||||
for id in possiblePremiumRequiredPeers {
|
||||
keys.append(.basicPeer(id))
|
||||
keys.append(.cachedPeerData(peerId: id))
|
||||
}
|
||||
|
||||
@ -2546,6 +2549,8 @@ public final class ShareController: ViewController {
|
||||
if let view = views.views[.cachedPeerData(peerId: id)] as? CachedPeerDataView, let data = view.cachedPeerData as? CachedUserData {
|
||||
requiresPremiumForMessaging[id] = data.flags.contains(.premiumRequired)
|
||||
requiresStars[id] = data.sendPaidMessageStars?.value
|
||||
} else if let view = views.views[.basicPeer(id)] as? BasicPeerView, let channel = view.peer as? TelegramChannel {
|
||||
requiresStars[id] = channel.sendPaidMessageStars?.value
|
||||
} else {
|
||||
requiresPremiumForMessaging[id] = false
|
||||
}
|
||||
|
@ -254,6 +254,7 @@ public final class PendingMessageManager {
|
||||
context.sendDisposable.dispose()
|
||||
context.uploadDisposable.dispose()
|
||||
context.activityDisposable.dispose()
|
||||
context.postponeDisposable.dispose()
|
||||
|
||||
if context.status != nil {
|
||||
context.status = nil
|
||||
|
@ -9041,40 +9041,45 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
let replyMessageSubject = strongSelf.presentationInterfaceState.interfaceState.replyMessageSubject
|
||||
strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({
|
||||
if let strongSelf = self {
|
||||
strongSelf.chatDisplayNode.collapseInput()
|
||||
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: false, {
|
||||
$0.updatedInterfaceState { $0.withUpdatedReplyMessageSubject(nil).withUpdatedSendMessageEffect(nil) }
|
||||
})
|
||||
strongSelf.presentPaidMessageAlertIfNeeded(completion: { [weak self] postpone in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
}, nil)
|
||||
let message: EnqueueMessage = .message(
|
||||
text: "",
|
||||
attributes: [],
|
||||
inlineStickers: [:],
|
||||
mediaReference: .standalone(media: TelegramMediaPoll(
|
||||
pollId: MediaId(namespace: Namespaces.Media.LocalPoll, id: Int64.random(in: Int64.min ... Int64.max)),
|
||||
publicity: poll.publicity,
|
||||
kind: poll.kind,
|
||||
text: poll.text.string,
|
||||
textEntities: poll.text.entities,
|
||||
options: poll.options,
|
||||
correctAnswers: poll.correctAnswers,
|
||||
results: poll.results,
|
||||
isClosed: false,
|
||||
deadlineTimeout: poll.deadlineTimeout
|
||||
)),
|
||||
threadId: strongSelf.chatLocation.threadId,
|
||||
replyToMessageId: nil,
|
||||
replyToStoryId: nil,
|
||||
localGroupingKey: nil,
|
||||
correlationId: nil,
|
||||
bubbleUpEmojiOrStickersets: []
|
||||
)
|
||||
strongSelf.sendMessages([message.withUpdatedReplyToMessageId(replyMessageSubject?.subjectModel)])
|
||||
let replyMessageSubject = strongSelf.presentationInterfaceState.interfaceState.replyMessageSubject
|
||||
strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({
|
||||
if let strongSelf = self {
|
||||
strongSelf.chatDisplayNode.collapseInput()
|
||||
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: false, {
|
||||
$0.updatedInterfaceState { $0.withUpdatedReplyMessageSubject(nil).withUpdatedSendMessageEffect(nil) }
|
||||
})
|
||||
}
|
||||
}, nil)
|
||||
let message: EnqueueMessage = .message(
|
||||
text: "",
|
||||
attributes: [],
|
||||
inlineStickers: [:],
|
||||
mediaReference: .standalone(media: TelegramMediaPoll(
|
||||
pollId: MediaId(namespace: Namespaces.Media.LocalPoll, id: Int64.random(in: Int64.min ... Int64.max)),
|
||||
publicity: poll.publicity,
|
||||
kind: poll.kind,
|
||||
text: poll.text.string,
|
||||
textEntities: poll.text.entities,
|
||||
options: poll.options,
|
||||
correctAnswers: poll.correctAnswers,
|
||||
results: poll.results,
|
||||
isClosed: false,
|
||||
deadlineTimeout: poll.deadlineTimeout
|
||||
)),
|
||||
threadId: strongSelf.chatLocation.threadId,
|
||||
replyToMessageId: nil,
|
||||
replyToStoryId: nil,
|
||||
localGroupingKey: nil,
|
||||
correlationId: nil,
|
||||
bubbleUpEmojiOrStickersets: []
|
||||
)
|
||||
strongSelf.sendMessages([message.withUpdatedReplyToMessageId(replyMessageSubject?.subjectModel)])
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -9283,6 +9288,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
var attributes = attributes
|
||||
|
||||
if let sendPaidMessageStars = self.presentationInterfaceState.sendPaidMessageStars {
|
||||
for i in (0 ..< attributes.count).reversed() {
|
||||
if attributes[i] is PaidStarsMessageAttribute {
|
||||
attributes.remove(at: i)
|
||||
}
|
||||
}
|
||||
attributes.append(PaidStarsMessageAttribute(stars: sendPaidMessageStars, postponeSending: postpone))
|
||||
}
|
||||
|
||||
|
@ -886,12 +886,14 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
|
||||
self.controllerInteraction.scheduleCurrentMessage(nil)
|
||||
} else {
|
||||
if let _ = self.chatPresentationInterfaceState.sendPaidMessageStars {
|
||||
var count: Int32 = 1
|
||||
var count: Int32
|
||||
if let forwardedCount = self.chatPresentationInterfaceState.interfaceState.forwardMessageIds?.count, forwardedCount > 0 {
|
||||
count = Int32(forwardedCount)
|
||||
if self.chatPresentationInterfaceState.interfaceState.effectiveInputState.inputText.length > 0 {
|
||||
count += 1
|
||||
}
|
||||
} else {
|
||||
count = Int32(ceil(CGFloat(self.chatPresentationInterfaceState.interfaceState.effectiveInputState.inputText.length) / 4096.0))
|
||||
}
|
||||
controller.presentPaidMessageAlertIfNeeded(count: count, completion: { [weak self] postpone in
|
||||
self?.sendCurrentMessage(postpone: postpone)
|
||||
|
@ -566,11 +566,11 @@ extension ChatControllerImpl {
|
||||
}
|
||||
}
|
||||
enqueueMessages.append(.message(text: "", attributes: attributes, inlineStickers: [:], mediaReference: .standalone(media: media), threadId: strongSelf.chatLocation.threadId, replyToMessageId: replyMessageSubject?.subjectModel, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []))
|
||||
strongSelf.presentPaidMessageAlertIfNeeded(completion: { [weak self] postpone in
|
||||
strongSelf.presentPaidMessageAlertIfNeeded(count: Int32(enqueueMessages.count), completion: { [weak self] postpone in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.sendMessages(strongSelf.transformEnqueueMessages(enqueueMessages, silentPosting: silent, scheduleTime: scheduleTime), postpone: postpone)
|
||||
strongSelf.sendMessages(strongSelf.transformEnqueueMessages(enqueueMessages, silentPosting: silent, scheduleTime: scheduleTime, postpone: postpone), postpone: postpone)
|
||||
})
|
||||
} else {
|
||||
let contactController = strongSelf.context.sharedContext.makeDeviceContactInfoController(context: ShareControllerAppAccountContext(context: strongSelf.context), environment: ShareControllerAppEnvironment(sharedContext: strongSelf.context.sharedContext), subject: .filter(peer: peerAndContactData.0, contactId: nil, contactData: contactData, completion: { peer, contactData in
|
||||
@ -596,11 +596,11 @@ extension ChatControllerImpl {
|
||||
enqueueMessages.append(textEnqueueMessage)
|
||||
}
|
||||
enqueueMessages.append(.message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: media), threadId: strongSelf.chatLocation.threadId, replyToMessageId: replyMessageSubject?.subjectModel, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []))
|
||||
strongSelf.presentPaidMessageAlertIfNeeded(completion: { [weak self] postpone in
|
||||
strongSelf.presentPaidMessageAlertIfNeeded(count: Int32(enqueueMessages.count), completion: { [weak self] postpone in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.sendMessages(strongSelf.transformEnqueueMessages(enqueueMessages, silentPosting: silent, scheduleTime: scheduleTime), postpone: postpone)
|
||||
strongSelf.sendMessages(strongSelf.transformEnqueueMessages(enqueueMessages, silentPosting: silent, scheduleTime: scheduleTime, postpone: postpone), postpone: postpone)
|
||||
})
|
||||
}
|
||||
}), completed: nil, cancelled: nil)
|
||||
|
@ -276,12 +276,19 @@ final class ChatTextInputActionButtonsNode: ASDisplayNode, ChatSendMessageAction
|
||||
self.sendButton.imageNode.alpha = 0.0
|
||||
self.textNode.isHidden = false
|
||||
|
||||
var amount = sendPaidMessageStars.value
|
||||
var amount: Int64
|
||||
if let forwardedCount = interfaceState.interfaceState.forwardMessageIds?.count, forwardedCount > 0 {
|
||||
amount = sendPaidMessageStars.value * Int64(forwardedCount)
|
||||
if interfaceState.interfaceState.effectiveInputState.inputText.length > 0 {
|
||||
amount += sendPaidMessageStars.value
|
||||
}
|
||||
} else {
|
||||
if interfaceState.interfaceState.effectiveInputState.inputText.length > 4096 {
|
||||
let messageCount = Int32(ceil(CGFloat(interfaceState.interfaceState.effectiveInputState.inputText.length) / 4096.0))
|
||||
amount = sendPaidMessageStars.value * Int64(messageCount)
|
||||
} else {
|
||||
amount = sendPaidMessageStars.value
|
||||
}
|
||||
}
|
||||
|
||||
let text = "\(amount)"
|
||||
|
Loading…
x
Reference in New Issue
Block a user