Various fixes

This commit is contained in:
Ilya Laktyushin 2025-01-25 02:33:41 +04:00
parent 2f8e6a4809
commit 3032fe0738
10 changed files with 44 additions and 39 deletions

View File

@ -13747,6 +13747,7 @@ Sorry for the inconvenience.";
"Gift.SendChannel.Title" = "Gift Preview"; "Gift.SendChannel.Title" = "Gift Preview";
"Gift.SendChannel.HideMyName.Info" = "Hide my name and message from visitors of this channel. The channel admins will still see them."; "Gift.SendChannel.HideMyName.Info" = "Hide my name and message from visitors of this channel. The channel admins will still see them.";
"Gift.SendChannel.Upgrade.Info" = "Enable this to let the admins of %@ turn your gift into a unique collectible. [Learn More >]()";
"Media.EditCover" = "Edit Cover"; "Media.EditCover" = "Edit Cover";
"Media.ChooseFromGallery" = "Choose From Gallery"; "Media.ChooseFromGallery" = "Choose From Gallery";

View File

@ -590,6 +590,7 @@ public enum PeerInfoControllerMode {
case forumTopic(thread: ChatReplyThreadMessage) case forumTopic(thread: ChatReplyThreadMessage)
case recommendedChannels case recommendedChannels
case myProfile case myProfile
case gifts
case myProfileGifts case myProfileGifts
} }

View File

@ -218,7 +218,8 @@ final class MutableItemCollectionsView {
} }
} }
let (entries, lower, higher) = aroundEntries(namespaces: namespaces, let (entries, lower, higher) = aroundEntries(
namespaces: namespaces,
aroundIndex: aroundIndex, aroundIndex: aroundIndex,
count: count, collectionIndexById: { id in count: count, collectionIndexById: { id in
return postbox.itemCollectionInfoTable.getIndex(id: id) return postbox.itemCollectionInfoTable.getIndex(id: id)
@ -235,7 +236,8 @@ final class MutableItemCollectionsView {
fetchHigherItems: { fetchHigherItems: {
collectionId, itemIndex, count in collectionId, itemIndex, count in
return self.higherItems(postbox: postbox, collectionId: collectionId, itemIndex: itemIndex, count: count) return self.higherItems(postbox: postbox, collectionId: collectionId, itemIndex: itemIndex, count: count)
}) }
)
self.entries = entries self.entries = entries
self.lower = lower self.lower = lower

View File

@ -439,7 +439,7 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
self.giftButton.isHidden = true self.giftButton.isHidden = true
self.helpButton.isHidden = true self.helpButton.isHidden = true
} }
self.giftButton.frame = CGRect(x: width - rightInset - panelHeight - 5.0, y: -3.0, width: panelHeight, height: panelHeight) self.giftButton.frame = CGRect(x: width - rightInset - panelHeight - 5.0, y: 0.0, width: panelHeight, height: panelHeight)
self.helpButton.frame = CGRect(x: width - rightInset - panelHeight, y: 0.0, width: panelHeight, height: panelHeight) self.helpButton.frame = CGRect(x: width - rightInset - panelHeight, y: 0.0, width: panelHeight, height: panelHeight)
} else { } else {
self.giftButton.isHidden = true self.giftButton.isHidden = true

View File

@ -914,7 +914,7 @@ final class GiftSetupScreenComponent: Component {
if let upgradeStars = gift.upgradeStars, component.peerId != component.context.account.peerId { if let upgradeStars = gift.upgradeStars, component.peerId != component.context.account.peerId {
let upgradeFooterRawString: String let upgradeFooterRawString: String
if isChannelGift { if isChannelGift {
upgradeFooterRawString = "Enable this to let the admins of \(peerName) turn your gift into a unique collectible. [Learn More >]()" upgradeFooterRawString = environment.strings.Gift_SendChannel_Upgrade_Info(peerName).string
} else { } else {
upgradeFooterRawString = environment.strings.Gift_Send_Upgrade_Info(peerName).string upgradeFooterRawString = environment.strings.Gift_Send_Upgrade_Info(peerName).string
} }

View File

@ -1728,8 +1728,14 @@ private final class GiftViewSheetContent: CombinedComponent {
valueAttributedString.addAttribute(.baselineOffset, value: 1.0, range: range) valueAttributedString.addAttribute(.baselineOffset, value: 1.0, range: range)
} }
var canConvert = true
if let reference = subject.arguments?.reference, case let .peer(peerId, _) = reference {
if let peer = state.peerMap[peerId], case let .channel(channel) = peer, !channel.flags.contains(.isCreator) {
canConvert = false
}
}
let valueComponent: AnyComponent<Empty> let valueComponent: AnyComponent<Empty>
if let convertStars, incoming && !converted { if let convertStars, incoming && !converted && canConvert {
valueComponent = AnyComponent( valueComponent = AnyComponent(
HStack([ HStack([
AnyComponentWithIdentity( AnyComponentWithIdentity(
@ -2558,10 +2564,13 @@ public class GiftViewScreen: ViewControllerComponentContainer {
self.dismissAnimated() self.dismissAnimated()
let giftsPeerId: EnginePeer.Id?
let text: String let text: String
if arguments.peerId?.namespace == Namespaces.Peer.CloudChannel { if case let .peer(peerId, _) = arguments.reference, peerId == Namespaces.Peer.CloudChannel {
giftsPeerId = peerId
text = added ? presentationData.strings.Gift_Displayed_ChannelText : presentationData.strings.Gift_Hidden_ChannelText text = added ? presentationData.strings.Gift_Displayed_ChannelText : presentationData.strings.Gift_Hidden_ChannelText
} else { } else {
giftsPeerId = arguments.peerId
text = added ? presentationData.strings.Gift_Displayed_NewText : presentationData.strings.Gift_Hidden_NewText text = added ? presentationData.strings.Gift_Displayed_NewText : presentationData.strings.Gift_Hidden_NewText
} }
@ -2573,8 +2582,8 @@ public class GiftViewScreen: ViewControllerComponentContainer {
content: .sticker(context: context, file: animationFile, loop: false, title: nil, text: text, undoText: updateSavedToProfile == nil ? presentationData.strings.Gift_Displayed_View : nil, customAction: nil), content: .sticker(context: context, file: animationFile, loop: false, title: nil, text: text, undoText: updateSavedToProfile == nil ? presentationData.strings.Gift_Displayed_View : nil, customAction: nil),
elevatedLayout: lastController is ChatController, elevatedLayout: lastController is ChatController,
action: { [weak navigationController] action in action: { [weak navigationController] action in
if case .undo = action, let navigationController { if case .undo = action, let navigationController, let giftsPeerId {
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId)) let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: giftsPeerId))
|> deliverOnMainQueue).start(next: { [weak navigationController] peer in |> deliverOnMainQueue).start(next: { [weak navigationController] peer in
guard let peer, let navigationController else { guard let peer, let navigationController else {
return return
@ -2583,7 +2592,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
context: context, context: context,
updatedPresentationData: nil, updatedPresentationData: nil,
peer: peer._asPeer(), peer: peer._asPeer(),
mode: .myProfileGifts, mode: giftsPeerId == context.account.peerId ? .myProfileGifts : .gifts,
avatarInitiallyExpanded: false, avatarInitiallyExpanded: false,
fromChat: false, fromChat: false,
requestsContext: nil requestsContext: nil

View File

@ -4440,11 +4440,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
PeerInfoScreenImpl.openSavedMessagesMoreMenu(context: strongSelf.context, sourceController: controller, isViewingAsTopics: true, sourceView: source.view, gesture: gesture) PeerInfoScreenImpl.openSavedMessagesMoreMenu(context: strongSelf.context, sourceController: controller, isViewingAsTopics: true, sourceView: source.view, gesture: gesture)
} }
default: default:
break
}
} else {
strongSelf.displayMediaGalleryContextMenu(source: source, gesture: gesture) strongSelf.displayMediaGalleryContextMenu(source: source, gesture: gesture)
} }
}
case .sort: case .sort:
guard let source else { guard let source else {
return return

View File

@ -198,7 +198,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
ribbonText = nil ribbonText = nil
} }
case let .unique(gift): case let .unique(gift):
ribbonText = params.presentationData.strings.PeerInfo_Gifts_OneOf(compactNumericCountString(Int(gift.availability.total), decimalSeparator: params.presentationData.dateTimeFormat.decimalSeparator)).string ribbonText = params.presentationData.strings.PeerInfo_Gifts_OneOf(compactNumericCountString(Int(gift.availability.issued), decimalSeparator: params.presentationData.dateTimeFormat.decimalSeparator)).string
for attribute in gift.attributes { for attribute in gift.attributes {
if case let .backdrop(_, innerColor, outerColor, _, _, _) = attribute { if case let .backdrop(_, innerColor, outerColor, _, _, _) = attribute {
ribbonColor = .custom(outerColor, innerColor) ribbonColor = .custom(outerColor, innerColor)

View File

@ -188,8 +188,6 @@ final class ChannelAppearanceScreenComponent: Component {
private let emojiPackSection = ComponentView<Empty>() private let emojiPackSection = ComponentView<Empty>()
private let stickerPackSection = ComponentView<Empty>() private let stickerPackSection = ComponentView<Empty>()
private var chatPreviewItemNode: PeerNameColorChatPreviewItemNode?
private var isUpdating: Bool = false private var isUpdating: Bool = false
private var component: ChannelAppearanceScreenComponent? private var component: ChannelAppearanceScreenComponent?
@ -227,7 +225,6 @@ final class ChannelAppearanceScreenComponent: Component {
private var applyDisposable: Disposable? private var applyDisposable: Disposable?
private weak var emojiStatusSelectionController: ViewController? private weak var emojiStatusSelectionController: ViewController?
private weak var currentUndoController: UndoOverlayController?
override init(frame: CGRect) { override init(frame: CGRect) {
self.scrollView = ScrollView() self.scrollView = ScrollView()
@ -469,11 +466,6 @@ final class ChannelAppearanceScreenComponent: Component {
return return
} }
if resolvedState.changes.isEmpty {
self.environment?.controller()?.dismiss()
return
}
self.isApplyingSettings = true self.isApplyingSettings = true
self.state?.updated(transition: .immediate) self.state?.updated(transition: .immediate)

View File

@ -3230,6 +3230,8 @@ private func peerInfoControllerImpl(context: AccountContext, updatedPresentation
forumTopicThread = thread forumTopicThread = thread
case .myProfile: case .myProfile:
isMyProfile = true isMyProfile = true
case .gifts:
switchToGifts = true
case .myProfileGifts: case .myProfileGifts:
isMyProfile = true isMyProfile = true
switchToGifts = true switchToGifts = true