mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-06 17:00:13 +00:00
Various fixes
This commit is contained in:
parent
da7fae6566
commit
c54e9fbedf
@ -104,20 +104,20 @@ public enum ChatTheme: PostboxCoding, Codable, Equatable {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .gift(lhsGift, _):
|
||||
if case let .gift(rhsGift, _) = rhs {
|
||||
case let .gift(lhsGift, lhsThemeSettings):
|
||||
if case let .gift(rhsGift, rhsThemeSettings) = rhs {
|
||||
switch lhsGift {
|
||||
case .generic(let lhsGeneric):
|
||||
case let .generic(lhsGeneric):
|
||||
switch rhsGift {
|
||||
case .generic(let rhsGeneric):
|
||||
return lhsGeneric == rhsGeneric
|
||||
case let .generic(rhsGeneric):
|
||||
return lhsGeneric == rhsGeneric && lhsThemeSettings == rhsThemeSettings
|
||||
default:
|
||||
return false
|
||||
}
|
||||
case .unique(let lhsUnique):
|
||||
case let .unique(lhsUnique):
|
||||
switch rhsGift {
|
||||
case .unique(let rhsUnique):
|
||||
return lhsUnique.slug == rhsUnique.slug
|
||||
case let .unique(rhsUnique):
|
||||
return lhsUnique.slug == rhsUnique.slug && lhsThemeSettings == rhsThemeSettings
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
@ -53,6 +53,7 @@ swift_library(
|
||||
"//submodules/ActivityIndicator",
|
||||
"//submodules/TelegramUI/Components/TabSelectorComponent",
|
||||
"//submodules/TelegramUI/Components/Stars/BalanceNeededScreen",
|
||||
"//submodules/TelegramUI/Components/ChatThemeScreen",
|
||||
"//submodules/ImageBlur",
|
||||
],
|
||||
visibility = [
|
||||
|
||||
@ -36,6 +36,7 @@ import StarsBalanceOverlayComponent
|
||||
import BalanceNeededScreen
|
||||
import GiftItemComponent
|
||||
import GiftAnimationComponent
|
||||
import ChatThemeScreen
|
||||
|
||||
private final class GiftViewSheetContent: CombinedComponent {
|
||||
typealias EnvironmentType = ViewControllerComponentContainer.Environment
|
||||
@ -809,27 +810,66 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
}
|
||||
|
||||
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
|
||||
let _ = context.engine.themes.setChatTheme(peerId: peer.id, chatTheme: .gift(.unique(gift), [])).start()
|
||||
peerController?.dismiss()
|
||||
|
||||
if let navigationController {
|
||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(
|
||||
navigationController: navigationController,
|
||||
chatController: nil,
|
||||
context: context,
|
||||
chatLocation: .peer(peer),
|
||||
subject: nil,
|
||||
botStart: nil,
|
||||
updateTextInputState: nil,
|
||||
keepStack: .always,
|
||||
useExisting: true,
|
||||
purposefulAction: nil,
|
||||
scrollToEndIfExists: false,
|
||||
activateMessageSearch: nil,
|
||||
animated: true
|
||||
))
|
||||
let proceed = {
|
||||
let _ = context.engine.themes.setChatTheme(peerId: peer.id, chatTheme: .gift(.unique(gift), [])).start()
|
||||
peerController?.dismiss()
|
||||
|
||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(
|
||||
navigationController: navigationController,
|
||||
chatController: nil,
|
||||
context: context,
|
||||
chatLocation: .peer(peer),
|
||||
subject: nil,
|
||||
botStart: nil,
|
||||
updateTextInputState: nil,
|
||||
keepStack: .always,
|
||||
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)
|
||||
@ -3278,8 +3318,8 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
component: PlainButtonComponent(
|
||||
content: AnyComponent(
|
||||
HeaderButtonComponent(
|
||||
title: uniqueGift.resellAmounts == nil ? strings.Gift_View_Sell : strings.Gift_View_Unlist,
|
||||
iconName: uniqueGift.resellAmounts == nil ? "Premium/Collectible/Sell" : "Premium/Collectible/Unlist"
|
||||
title: (uniqueGift.resellAmounts ?? []).isEmpty ? strings.Gift_View_Sell : strings.Gift_View_Unlist,
|
||||
iconName: (uniqueGift.resellAmounts ?? []).isEmpty ? "Premium/Collectible/Sell" : "Premium/Collectible/Unlist"
|
||||
)
|
||||
),
|
||||
effectAlignment: .center,
|
||||
|
||||
@ -127,7 +127,7 @@ private enum PeerMembersListEntry: Comparable, Identifiable {
|
||||
}))
|
||||
}
|
||||
|
||||
let presence: EnginePeer.Presence
|
||||
var presence: EnginePeer.Presence
|
||||
if member.peer.id == context.account.peerId {
|
||||
presence = EnginePeer.Presence(status: .present(until: Int32.max), lastActivity: 0)
|
||||
} else if let value = member.presence {
|
||||
@ -136,6 +136,17 @@ private enum PeerMembersListEntry: Comparable, Identifiable {
|
||||
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(
|
||||
presentationData: ItemListPresentationData(presentationData),
|
||||
style: .plain,
|
||||
@ -145,7 +156,7 @@ private enum PeerMembersListEntry: Comparable, Identifiable {
|
||||
context: context,
|
||||
peerMode: .memberList,
|
||||
peer: .peer(peer: EnginePeer(member.peer), chatPeer: EnginePeer(member.peer)),
|
||||
status: .presence(presence, presentationData.dateTimeFormat),
|
||||
status: status,
|
||||
rightLabelText: label,
|
||||
enabled: true,
|
||||
selection: .none,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user