Various improvements

This commit is contained in:
Isaac 2024-08-18 23:33:25 +08:00
parent cfa910b5ea
commit 2ce2151b12
8 changed files with 18 additions and 11 deletions

View File

@ -12814,3 +12814,6 @@ Sorry for the inconvenience.";
"Chat.ToastStarsSent.Text" = "You have reacted with %1$@ %2$@.";
"Chat.ToastStarsSent.TextStarAmount_1" = "star";
"Chat.ToastStarsSent.TextStarAmount_any" = "stars";
"Stars.Purchase.StarsReactionsNeededInfo" = "Buy Stars to send paid reactions **%@** and other channels.";
"Chat.ToastStarsReactionsDisabled" = "Star Reactions were disabled in %@";"

View File

@ -126,6 +126,7 @@ public enum StarsPurchasePurpose: Equatable {
case generic
case topUp(requiredStars: Int64, purpose: String?)
case transfer(peerId: EnginePeer.Id, requiredStars: Int64)
case reactions(peerId: EnginePeer.Id, requiredStars: Int64)
case subscription(peerId: EnginePeer.Id, requiredStars: Int64, renew: Bool)
case gift(peerId: EnginePeer.Id)
case unlockMedia(requiredStars: Int64)

View File

@ -1962,7 +1962,7 @@ private final class ChatSendStarsScreenComponent: Component {
return
}
let purchaseScreen = component.context.sharedContext.makeStarsPurchaseScreen(context: component.context, starsContext: starsContext, options: options, purpose: .transfer(peerId: component.peer.id, requiredStars: Int64(self.amount.realValue)), completion: { result in
let purchaseScreen = component.context.sharedContext.makeStarsPurchaseScreen(context: component.context, starsContext: starsContext, options: options, purpose: .reactions(peerId: component.peer.id, requiredStars: Int64(self.amount.realValue)), completion: { result in
let _ = result
//TODO:release
})

View File

@ -230,6 +230,8 @@ private final class StarsPurchaseScreenContentComponent: CombinedComponent {
textString = strings.Stars_Purchase_GiftInfo(component.peers.first?.value.compactDisplayTitle ?? "").string
case .transfer:
textString = strings.Stars_Purchase_StarsNeededInfo(component.peers.first?.value.compactDisplayTitle ?? "").string
case .reactions:
textString = strings.Stars_Purchase_StarsReactionsNeededInfo(component.peers.first?.value.compactDisplayTitle ?? "").string
case let .subscription(_, _, renew):
textString = renew ? strings.Stars_Purchase_SubscriptionRenewInfo(component.peers.first?.value.compactDisplayTitle ?? "").string : strings.Stars_Purchase_SubscriptionInfo(component.peers.first?.value.compactDisplayTitle ?? "").string
case .unlockMedia:
@ -837,7 +839,7 @@ private final class StarsPurchaseScreenComponent: CombinedComponent {
titleText = strings.Stars_Purchase_StarsNeeded(Int32(requiredStars))
case .gift:
titleText = strings.Stars_Purchase_GiftStars
case let .transfer(_, requiredStars), let .subscription(_, requiredStars, _), let .unlockMedia(requiredStars):
case let .transfer(_, requiredStars), let .reactions(_, requiredStars), let .subscription(_, requiredStars, _), let .unlockMedia(requiredStars):
titleText = strings.Stars_Purchase_StarsNeeded(Int32(requiredStars))
}
@ -1230,6 +1232,8 @@ private extension StarsPurchasePurpose {
return [peerId]
case let .transfer(peerId, _):
return [peerId]
case let .reactions(peerId, _):
return [peerId]
case let .subscription(peerId, _, _):
return [peerId]
default:
@ -1243,6 +1247,8 @@ private extension StarsPurchasePurpose {
return requiredStars
case let .transfer(_, requiredStars):
return requiredStars
case let .reactions(_, requiredStars):
return requiredStars
case let .subscription(_, requiredStars, _):
return requiredStars
case let .unlockMedia(requiredStars):

View File

@ -294,7 +294,7 @@ extension ChatControllerImpl {
if !hasAnonymousPeer {
allPeers?.insert(SendAsPeer(peer: channel, subscribers: 0, isPremiumRequired: false), at: 0)
}
} else if let channel = peerViewMainPeer(peerView) as? TelegramChannel, case .broadcast = channel.info {
} else if let channel = peerViewMainPeer(peerView) as? TelegramChannel, case let .broadcast(info) = channel.info, (info.flags.contains(.messagesShouldHaveSignatures) || info.flags.contains(.messagesShouldHaveProfiles)) {
allPeers = peers
var hasAnonymousPeer = false

View File

@ -407,8 +407,7 @@ extension ChatControllerImpl {
if case let .known(reactionSettings) = reactionSettings, let starsAllowed = reactionSettings.starsAllowed, !starsAllowed {
if let peer = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer {
//TODO:localize
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: "Star Reactions were disabled in \(peer.debugDisplayTitle).", actions: [
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: strongSelf.presentationData.strings.Chat_ToastStarsReactionsDisabled(peer.debugDisplayTitle).string, actions: [
TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_OK, action: {})
]), in: .window(.root))
}
@ -431,7 +430,7 @@ extension ChatControllerImpl {
return
}
let purchaseScreen = strongSelf.context.sharedContext.makeStarsPurchaseScreen(context: strongSelf.context, starsContext: starsContext, options: options, purpose: .transfer(peerId: peerId, requiredStars: 1), completion: { result in
let purchaseScreen = strongSelf.context.sharedContext.makeStarsPurchaseScreen(context: strongSelf.context, starsContext: starsContext, options: options, purpose: .reactions(peerId: peerId, requiredStars: 1), completion: { result in
let _ = result
//TODO:release
})

View File

@ -1716,8 +1716,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if case let .known(reactionSettings) = reactionSettings, let starsAllowed = reactionSettings.starsAllowed, !starsAllowed {
if let peer = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer {
//TODO:localize
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: "Star Reactions were disabled in \(peer.debugDisplayTitle).", actions: [
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: strongSelf.presentationData.strings.Chat_ToastStarsReactionsDisabled(peer.debugDisplayTitle).string, actions: [
TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_OK, action: {})
]), in: .window(.root))
}
@ -1735,7 +1734,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return
}
let purchaseScreen = strongSelf.context.sharedContext.makeStarsPurchaseScreen(context: strongSelf.context, starsContext: starsContext, options: options, purpose: .transfer(peerId: peerId, requiredStars: 1), completion: { result in
let purchaseScreen = strongSelf.context.sharedContext.makeStarsPurchaseScreen(context: strongSelf.context, starsContext: starsContext, options: options, purpose: .reactions(peerId: peerId, requiredStars: 1), completion: { result in
let _ = result
//TODO:release
})

View File

@ -398,8 +398,7 @@ extension ChatControllerImpl {
if case let .known(reactionSettings) = reactionSettings, let starsAllowed = reactionSettings.starsAllowed, !starsAllowed {
if let peer = self.presentationInterfaceState.renderedPeer?.chatMainPeer {
//TODO:localize
self.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: self.presentationData), title: nil, text: "Star Reactions were disabled in \(peer.debugDisplayTitle).", actions: [
self.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: self.presentationData), title: nil, text: self.presentationData.strings.Chat_ToastStarsReactionsDisabled(peer.debugDisplayTitle).string, actions: [
TextAlertAction(type: .genericAction, title: self.presentationData.strings.Common_OK, action: {})
]), in: .window(.root))
}