Various fixes

This commit is contained in:
Ilya Laktyushin 2025-08-29 23:34:46 +04:00
parent da7fae6566
commit c54e9fbedf
4 changed files with 83 additions and 31 deletions

View File

@ -104,20 +104,20 @@ public enum ChatTheme: PostboxCoding, Codable, Equatable {
} else { } else {
return false return false
} }
case let .gift(lhsGift, _): case let .gift(lhsGift, lhsThemeSettings):
if case let .gift(rhsGift, _) = rhs { if case let .gift(rhsGift, rhsThemeSettings) = rhs {
switch lhsGift { switch lhsGift {
case .generic(let lhsGeneric): case let .generic(lhsGeneric):
switch rhsGift { switch rhsGift {
case .generic(let rhsGeneric): case let .generic(rhsGeneric):
return lhsGeneric == rhsGeneric return lhsGeneric == rhsGeneric && lhsThemeSettings == rhsThemeSettings
default: default:
return false return false
} }
case .unique(let lhsUnique): case let .unique(lhsUnique):
switch rhsGift { switch rhsGift {
case .unique(let rhsUnique): case let .unique(rhsUnique):
return lhsUnique.slug == rhsUnique.slug return lhsUnique.slug == rhsUnique.slug && lhsThemeSettings == rhsThemeSettings
default: default:
return false return false
} }

View File

@ -53,6 +53,7 @@ swift_library(
"//submodules/ActivityIndicator", "//submodules/ActivityIndicator",
"//submodules/TelegramUI/Components/TabSelectorComponent", "//submodules/TelegramUI/Components/TabSelectorComponent",
"//submodules/TelegramUI/Components/Stars/BalanceNeededScreen", "//submodules/TelegramUI/Components/Stars/BalanceNeededScreen",
"//submodules/TelegramUI/Components/ChatThemeScreen",
"//submodules/ImageBlur", "//submodules/ImageBlur",
], ],
visibility = [ visibility = [

View File

@ -36,6 +36,7 @@ import StarsBalanceOverlayComponent
import BalanceNeededScreen import BalanceNeededScreen
import GiftItemComponent import GiftItemComponent
import GiftAnimationComponent import GiftAnimationComponent
import ChatThemeScreen
private final class GiftViewSheetContent: CombinedComponent { private final class GiftViewSheetContent: CombinedComponent {
typealias EnvironmentType = ViewControllerComponentContainer.Environment typealias EnvironmentType = ViewControllerComponentContainer.Environment
@ -809,27 +810,66 @@ private final class GiftViewSheetContent: CombinedComponent {
} }
let context = self.context let context = self.context
let peerController = self.context.sharedContext.makePeerSelectionController(PeerSelectionControllerParams(context: self.context, filter: [.excludeRecent, .doNotSearchMessages], requestPeerType: [.user(.init(isBot: false, isPremium: false))], hasContactSelector: false, hasCreation: false))
let themePeerId = Promise<EnginePeer.Id?>()
themePeerId.set(
.single(gift.themePeerId)
|> then(
context.engine.payments.getUniqueStarGift(slug: gift.slug)
|> map { gift in
return gift?.themePeerId
}
)
)
let peerController = context.sharedContext.makePeerSelectionController(PeerSelectionControllerParams(context: context, filter: [.excludeRecent, .doNotSearchMessages], requestPeerType: [.user(.init(isBot: false, isPremium: nil))], hasContactSelector: false, hasCreation: false))
peerController.peerSelected = { [weak peerController, weak navigationController] peer, _ in peerController.peerSelected = { [weak peerController, weak navigationController] peer, _ in
let _ = context.engine.themes.setChatTheme(peerId: peer.id, chatTheme: .gift(.unique(gift), [])).start()
peerController?.dismiss()
if let navigationController { if let navigationController {
context.sharedContext.navigateToChatController(NavigateToChatControllerParams( let proceed = {
navigationController: navigationController, let _ = context.engine.themes.setChatTheme(peerId: peer.id, chatTheme: .gift(.unique(gift), [])).start()
chatController: nil, peerController?.dismiss()
context: context,
chatLocation: .peer(peer), context.sharedContext.navigateToChatController(NavigateToChatControllerParams(
subject: nil, navigationController: navigationController,
botStart: nil, chatController: nil,
updateTextInputState: nil, context: context,
keepStack: .always, chatLocation: .peer(peer),
useExisting: true, subject: nil,
purposefulAction: nil, botStart: nil,
scrollToEndIfExists: false, updateTextInputState: nil,
activateMessageSearch: nil, keepStack: .always,
animated: true useExisting: true,
)) purposefulAction: nil,
scrollToEndIfExists: false,
activateMessageSearch: nil,
animated: true
))
}
let _ = (themePeerId.get()
|> deliverOnMainQueue
|> take(1)).start(next: { [weak navigationController] themePeerId in
if let themePeerId, themePeerId != peer.id {
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: themePeerId))
|> deliverOnMainQueue).start(next: { [weak navigationController] peer in
guard let peer else {
proceed()
return
}
let controller = giftThemeTransferAlertController(
context: context,
gift: gift,
previousPeer: peer,
commit: {
proceed()
}
)
(navigationController?.viewControllers.last as? ViewController)?.present(controller, in: .window(.root))
})
} else {
proceed()
}
})
} }
} }
self.dismiss(animated: true) self.dismiss(animated: true)
@ -3278,8 +3318,8 @@ private final class GiftViewSheetContent: CombinedComponent {
component: PlainButtonComponent( component: PlainButtonComponent(
content: AnyComponent( content: AnyComponent(
HeaderButtonComponent( HeaderButtonComponent(
title: uniqueGift.resellAmounts == nil ? strings.Gift_View_Sell : strings.Gift_View_Unlist, title: (uniqueGift.resellAmounts ?? []).isEmpty ? strings.Gift_View_Sell : strings.Gift_View_Unlist,
iconName: uniqueGift.resellAmounts == nil ? "Premium/Collectible/Sell" : "Premium/Collectible/Unlist" iconName: (uniqueGift.resellAmounts ?? []).isEmpty ? "Premium/Collectible/Sell" : "Premium/Collectible/Unlist"
) )
), ),
effectAlignment: .center, effectAlignment: .center,

View File

@ -127,7 +127,7 @@ private enum PeerMembersListEntry: Comparable, Identifiable {
})) }))
} }
let presence: EnginePeer.Presence var presence: EnginePeer.Presence
if member.peer.id == context.account.peerId { if member.peer.id == context.account.peerId {
presence = EnginePeer.Presence(status: .present(until: Int32.max), lastActivity: 0) presence = EnginePeer.Presence(status: .present(until: Int32.max), lastActivity: 0)
} else if let value = member.presence { } else if let value = member.presence {
@ -136,6 +136,17 @@ private enum PeerMembersListEntry: Comparable, Identifiable {
presence = EnginePeer.Presence(status: .longTimeAgo, lastActivity: 0) presence = EnginePeer.Presence(status: .longTimeAgo, lastActivity: 0)
} }
var status: ContactsPeerItemStatus = .presence(presence, presentationData.dateTimeFormat)
if let user = member.peer as? TelegramUser, let botInfo = user.botInfo {
let botStatus: String
if botInfo.flags.contains(.hasAccessToChatHistory) {
botStatus = presentationData.strings.Bot_GroupStatusReadsHistory
} else {
botStatus = presentationData.strings.Bot_GroupStatusDoesNotReadHistory
}
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)
}
return ContactsPeerItem( return ContactsPeerItem(
presentationData: ItemListPresentationData(presentationData), presentationData: ItemListPresentationData(presentationData),
style: .plain, style: .plain,
@ -145,7 +156,7 @@ private enum PeerMembersListEntry: Comparable, Identifiable {
context: context, context: context,
peerMode: .memberList, peerMode: .memberList,
peer: .peer(peer: EnginePeer(member.peer), chatPeer: EnginePeer(member.peer)), peer: .peer(peer: EnginePeer(member.peer), chatPeer: EnginePeer(member.peer)),
status: .presence(presence, presentationData.dateTimeFormat), status: status,
rightLabelText: label, rightLabelText: label,
enabled: true, enabled: true,
selection: .none, selection: .none,