Various fixes

This commit is contained in:
Ilya Laktyushin 2026-03-03 23:18:54 +04:00
parent 551a74fd61
commit b2d33d6a57
7 changed files with 49 additions and 10 deletions

View file

@ -389,10 +389,11 @@ public func incomingMessagePrivacyScreen(context: AccountContext, value: GlobalP
if case let .paidMessages(value) = stateValue.with({ $0 }).updatedValue {
currentAmount = value
}
let fractionAfterCommission = configuration.paidMessageCommissionPermille / 10
let starsScreen = context.sharedContext.makeStarsWithdrawalScreen(context: context, subject: .enterAmount(
current: currentAmount,
minValue: StarsAmount(value: 1, nanos: 0),
fractionAfterCommission: 80, kind: .privacy,
fractionAfterCommission: Int(fractionAfterCommission), kind: .privacy,
completion: { amount in
updateState { state in
var state = state

View file

@ -12,7 +12,7 @@ public enum UpdateChatRankError {
case notParticipant
}
func _internal_updateChatRank(account: Account, peerId: PeerId, userId: PeerId, rank: String?) -> Signal<(ChannelParticipant?, RenderedChannelParticipant)?, UpdateChatRankError> {
func _internal_updateChatRank(account: Account, peerId: PeerId, userId: PeerId, messageId: MessageId?, rank: String?) -> Signal<(ChannelParticipant?, RenderedChannelParticipant)?, UpdateChatRankError> {
return account.postbox.transaction { transaction -> Signal<(ChannelParticipant?, RenderedChannelParticipant)?, UpdateChatRankError> in
if let user = transaction.getPeer(userId), let inputUser = apiInputPeer(user), let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
let currentParticipant: Signal<ChannelParticipant?, NoError>
@ -57,7 +57,6 @@ func _internal_updateChatRank(account: Account, peerId: PeerId, userId: PeerId,
return nil
} else {
let updatedParticipant = currentParticipant?.withUpdated(rank: rank) ?? .member(id: userId, invitedAt: 0, adminInfo: nil, banInfo: nil, rank: rank, subscriptionUntilDate: nil)
var peers: [PeerId: Peer] = [:]
var presences: [PeerId: PeerPresence] = [:]
peers[user.id] = user
@ -69,6 +68,30 @@ func _internal_updateChatRank(account: Account, peerId: PeerId, userId: PeerId,
peers[peer.id] = peer
}
}
let historyView = transaction.getMessagesHistoryViewState(input: .single(peerId: peerId, threadId: nil), ignoreMessagesInTimestampRange: nil, ignoreMessageIds: Set(), count: 50, clipHoles: true, anchor: .upperBound, namespaces: .just(Set([Namespaces.Message.Cloud])))
var messageIds: [MessageId] = []
if let messageId {
messageIds.append(messageId)
}
for entry in historyView.entries {
if entry.message.id != messageId, let author = entry.message.author, author.id == userId {
messageIds.append(entry.message.id)
}
}
for messageId in messageIds {
transaction.updateMessage(messageId, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature, psaType: forwardInfo.psaType, flags: forwardInfo.flags)
}
var attributes = currentMessage.attributes
attributes.removeAll(where: { $0 is ParticipantRankMessageAttribute })
if let rank, !rank.isEmpty {
attributes.append(ParticipantRankMessageAttribute(rank: rank))
}
return .update(StoreMessage(id: currentMessage.id, customStableId: nil, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, threadId: currentMessage.threadId, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: attributes, media: currentMessage.media))
})
}
return (currentParticipant, RenderedChannelParticipant(participant: updatedParticipant, peer: user, peers: peers, presences: presences))
}
}

View file

@ -617,8 +617,8 @@ public extension TelegramEngine {
return _internal_getFutureCreatorAfterLeave(account: self.account, peerId: peerId)
}
public func updateChatRank(peerId: PeerId, userId: PeerId, rank: String?) -> Signal<(ChannelParticipant?, RenderedChannelParticipant)?, UpdateChatRankError> {
return _internal_updateChatRank(account: account, peerId: peerId, userId: userId, rank: rank)
public func updateChatRank(peerId: PeerId, userId: PeerId, messageId: MessageId? = nil, rank: String?) -> Signal<(ChannelParticipant?, RenderedChannelParticipant)?, UpdateChatRankError> {
return _internal_updateChatRank(account: account, peerId: peerId, userId: userId, messageId: messageId, rank: rank)
}
public func terminateSecretChat(peerId: PeerId, requestRemoteHistoryRemoval: Bool) -> Signal<Never, NoError> {

View file

@ -27,6 +27,7 @@ private struct PeerMembersListTransaction {
enum PeerMembersListAction {
case open
case editRank
case promote
case restrict
case remove
@ -174,6 +175,10 @@ private enum PeerMembersListEntry: Comparable, Identifiable {
status = .custom(string: NSAttributedString(string: botStatus, font: Font.regular(floor(presentationData.listsFontSize.itemListBaseFontSize * 14.0 / 17.0)), textColor: presentationData.theme.list.itemSecondaryTextColor), multiline: false, isActive: false, icon: nil)
}
var canEditRank = false
if actions.contains(.editRank) {
canEditRank = true
}
return ContactsPeerItem(
presentationData: ItemListPresentationData(presentationData),
style: .plain,
@ -195,8 +200,12 @@ private enum PeerMembersListEntry: Comparable, Identifiable {
index: nil,
header: nil,
hideBackground: true,
action: member.peer.id == context.account.peerId ? nil : { _ in
action(member, .open)
action: member.peer.id == context.account.peerId && !canEditRank ? nil : { _ in
if member.peer.id == context.account.peerId && canEditRank {
action(member, .editRank)
} else {
action(member, .open)
}
},
disabledAction: nil,
setPeerIdWithRevealedOptions: { _, _ in

View file

@ -71,7 +71,7 @@ final class PeerInfoAvatarListNode: ASDisplayNode {
|> take(1)
let combinedSignal: Signal<Bool, NoError>
if readyWhenGalleryLoads {
if !"".isEmpty, readyWhenGalleryLoads {
combinedSignal = combineLatest(queue: .mainQueue(),
avatarReady,
galleryReady

View file

@ -1453,6 +1453,8 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
strongSelf.performMemberAction(member: member, action: .promote)
case .restrict:
strongSelf.performMemberAction(member: member, action: .restrict)
case .editRank:
strongSelf.performMemberAction(member: member, action: .editRank)
case .remove:
strongSelf.performMemberAction(member: member, action: .remove)
case let .openStories(sourceView):

View file

@ -27,10 +27,14 @@ extension ChatControllerImpl {
getCaptionPanelView: { [weak self] in
return self?.getCaptionPanelView(isFile: false, hasTimer: false)
},
sendMessagesWithSignals: { [weak self] signals, _, _, _ in
sendMessagesWithSignals: { [weak self] signals, _, _, isCaptionAbove in
guard let self else {
return
}
let parameters = ChatSendMessageActionSheetController.SendParameters(
effect: nil,
textIsAboveMedia: isCaptionAbove
)
self.enqueueMediaMessages(
fromGallery: false,
signals: signals,
@ -38,7 +42,7 @@ extension ChatControllerImpl {
silentPosting: false,
scheduleTime: nil,
replyToSubject: nil,
parameters: nil,
parameters: parameters,
getAnimatedTransitionSource: nil,
completion: {}
)