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.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.ChooseFromGallery" = "Choose From Gallery";

View File

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

View File

@ -218,24 +218,26 @@ final class MutableItemCollectionsView {
}
}
let (entries, lower, higher) = aroundEntries(namespaces: namespaces,
aroundIndex: aroundIndex,
count: count, collectionIndexById: { id in
return postbox.itemCollectionInfoTable.getIndex(id: id)
},
lowerCollectionId: { namespaceList, collectionId, collectionIndex in
return self.lowerCollectionId(postbox: postbox, namespaceList: namespaceList, collectionId: collectionId, collectionIndex: collectionIndex)
},
fetchLowerItems: { collectionId, itemIndex, count in
return self.lowerItems(postbox: postbox, collectionId: collectionId, itemIndex: itemIndex, count: count)
},
higherCollectionId: { namespaceList, collectionId, collectionIndex in
return self.higherCollectionId(postbox: postbox, namespaceList: namespaceList, collectionId: collectionId, collectionIndex: collectionIndex)
},
fetchHigherItems: {
collectionId, itemIndex, count in
return self.higherItems(postbox: postbox, collectionId: collectionId, itemIndex: itemIndex, count: count)
})
let (entries, lower, higher) = aroundEntries(
namespaces: namespaces,
aroundIndex: aroundIndex,
count: count, collectionIndexById: { id in
return postbox.itemCollectionInfoTable.getIndex(id: id)
},
lowerCollectionId: { namespaceList, collectionId, collectionIndex in
return self.lowerCollectionId(postbox: postbox, namespaceList: namespaceList, collectionId: collectionId, collectionIndex: collectionIndex)
},
fetchLowerItems: { collectionId, itemIndex, count in
return self.lowerItems(postbox: postbox, collectionId: collectionId, itemIndex: itemIndex, count: count)
},
higherCollectionId: { namespaceList, collectionId, collectionIndex in
return self.higherCollectionId(postbox: postbox, namespaceList: namespaceList, collectionId: collectionId, collectionIndex: collectionIndex)
},
fetchHigherItems: {
collectionId, itemIndex, count in
return self.higherItems(postbox: postbox, collectionId: collectionId, itemIndex: itemIndex, count: count)
}
)
self.entries = entries
self.lower = lower

View File

@ -439,7 +439,7 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
self.giftButton.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)
} else {
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 {
let upgradeFooterRawString: String
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 {
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)
}
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>
if let convertStars, incoming && !converted {
if let convertStars, incoming && !converted && canConvert {
valueComponent = AnyComponent(
HStack([
AnyComponentWithIdentity(
@ -2558,10 +2564,13 @@ public class GiftViewScreen: ViewControllerComponentContainer {
self.dismissAnimated()
let giftsPeerId: EnginePeer.Id?
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
} else {
giftsPeerId = arguments.peerId
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),
elevatedLayout: lastController is ChatController,
action: { [weak navigationController] action in
if case .undo = action, let navigationController {
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId))
if case .undo = action, let navigationController, let giftsPeerId {
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: giftsPeerId))
|> deliverOnMainQueue).start(next: { [weak navigationController] peer in
guard let peer, let navigationController else {
return
@ -2583,7 +2592,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
context: context,
updatedPresentationData: nil,
peer: peer._asPeer(),
mode: .myProfileGifts,
mode: giftsPeerId == context.account.peerId ? .myProfileGifts : .gifts,
avatarInitiallyExpanded: false,
fromChat: false,
requestsContext: nil

View File

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

View File

@ -198,7 +198,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
ribbonText = nil
}
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 {
if case let .backdrop(_, innerColor, outerColor, _, _, _) = attribute {
ribbonColor = .custom(outerColor, innerColor)

View File

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

View File

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