mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
072c6bc3c4
commit
00516523a4
@ -170,7 +170,7 @@ public final class MultilineTextWithEntitiesComponent: Component {
|
||||
self.textNode.highlightAttributeAction = component.highlightAction
|
||||
self.textNode.tapAttributeAction = component.tapAction
|
||||
self.textNode.longTapAttributeAction = component.longTapAction
|
||||
|
||||
|
||||
if case let .curve(duration, _) = transition.animation, let previousText = previousText, previousText != attributedString.string {
|
||||
if let snapshotView = self.snapshotContentTree() {
|
||||
snapshotView.center = self.center
|
||||
|
@ -123,8 +123,6 @@ class CaptionScrollWrapperNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScrollViewDelegate {
|
||||
private let context: AccountContext
|
||||
private var presentationData: PresentationData
|
||||
@ -1106,8 +1104,11 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
|
||||
|
||||
let dustNode = InvisibleInkDustNode(textNode: spoilerTextNode, enableAnimations: self.context.sharedContext.energyUsageSettings.fullTranslucency)
|
||||
self.dustNode = dustNode
|
||||
spoilerTextNode.supernode?.insertSubnode(dustNode, aboveSubnode: spoilerTextNode)
|
||||
|
||||
if let textSelectionNode = self.textSelectionNode {
|
||||
spoilerTextNode.supernode?.insertSubnode(dustNode, aboveSubnode: textSelectionNode)
|
||||
} else {
|
||||
spoilerTextNode.supernode?.insertSubnode(dustNode, aboveSubnode: spoilerTextNode)
|
||||
}
|
||||
}
|
||||
if let dustNode = self.dustNode {
|
||||
dustNode.update(size: textFrame.size, color: .white, textColor: .white, rects: textLayout.spoilers.map { $0.1.offsetBy(dx: 3.0, dy: 3.0).insetBy(dx: 0.0, dy: 1.0) }, wordRects: textLayout.spoilerWords.map { $0.1.offsetBy(dx: 3.0, dy: 3.0).insetBy(dx: 0.0, dy: 1.0) })
|
||||
|
@ -207,6 +207,22 @@ func _internal_convertStarGift(account: Account, messageId: EngineMessage.Id) ->
|
||||
|> `catch` { _ -> Signal<Api.Bool?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { result in
|
||||
if let result, case .boolTrue = result {
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
transaction.updatePeerCachedData(peerIds: Set([account.peerId]), update: { _, cachedData -> CachedPeerData? in
|
||||
if let cachedData = cachedData as? CachedUserData, let starGiftsCount = cachedData.starGiftsCount {
|
||||
var updatedData = cachedData
|
||||
updatedData = updatedData.withUpdatedStarGiftsCount(max(0, starGiftsCount - 1))
|
||||
return updatedData
|
||||
} else {
|
||||
return cachedData
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ final class GiftOptionsScreenComponent: Component {
|
||||
}
|
||||
|
||||
var controllers = navigationController.viewControllers
|
||||
controllers = controllers.filter { !($0 is GiftOptionsScreen) }
|
||||
controllers = controllers.filter { !($0 is GiftOptionsScreen) && !($0 is PeerInfoScreen) && !($0 is ContactSelectionController) }
|
||||
var foundController = false
|
||||
for controller in controllers.reversed() {
|
||||
if let chatController = controller as? ChatController, case .peer(id: component.peerId) = chatController.chatLocation {
|
||||
|
@ -214,7 +214,7 @@ final class GiftSetupScreenComponent: Component {
|
||||
}
|
||||
|
||||
var controllers = navigationController.viewControllers
|
||||
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) }
|
||||
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) && !($0 is PeerInfoScreen) && !($0 is ContactSelectionController) }
|
||||
var foundController = false
|
||||
for controller in controllers.reversed() {
|
||||
if let chatController = controller as? ChatController, case .peer(id: component.peerId) = chatController.chatLocation {
|
||||
|
@ -70,6 +70,7 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
var initialized = false
|
||||
|
||||
var peerMap: [EnginePeer.Id: EnginePeer] = [:]
|
||||
var starGiftsMap: [Int64: StarGift] = [:]
|
||||
|
||||
var cachedCloseImage: (UIImage, PresentationTheme)?
|
||||
var cachedChevronImage: (UIImage, PresentationTheme)?
|
||||
@ -86,14 +87,15 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
if let fromPeerId = arguments.fromPeerId {
|
||||
peerIds.append(fromPeerId)
|
||||
}
|
||||
self.disposable = (context.engine.data.get(
|
||||
EngineDataMap(
|
||||
|
||||
self.disposable = combineLatest(queue: Queue.mainQueue(),
|
||||
context.engine.data.get(EngineDataMap(
|
||||
peerIds.map { peerId -> TelegramEngine.EngineData.Item.Peer.Peer in
|
||||
return TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)
|
||||
}
|
||||
)
|
||||
)
|
||||
|> deliverOnMainQueue).startStrict(next: { [weak self] peers in
|
||||
)),
|
||||
context.engine.payments.cachedStarGifts()
|
||||
).startStrict(next: { [weak self] peers, starGifts in
|
||||
if let strongSelf = self {
|
||||
var peersMap: [EnginePeer.Id: EnginePeer] = [:]
|
||||
for peerId in peerIds {
|
||||
@ -103,6 +105,14 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
}
|
||||
strongSelf.peerMap = peersMap
|
||||
|
||||
var starGiftsMap: [Int64: StarGift] = [:]
|
||||
if let starGifts {
|
||||
for gift in starGifts {
|
||||
starGiftsMap[gift.id] = gift
|
||||
}
|
||||
}
|
||||
strongSelf.starGiftsMap = starGiftsMap
|
||||
|
||||
strongSelf.initialized = true
|
||||
|
||||
strongSelf.updated(transition: .immediate)
|
||||
@ -170,33 +180,30 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
let convertStars: Int64
|
||||
let text: String?
|
||||
let entities: [MessageTextEntity]?
|
||||
let limitNumber: Int32?
|
||||
let limitTotal: Int32?
|
||||
var incoming = false
|
||||
var savedToProfile = false
|
||||
var converted = false
|
||||
var giftId: Int64 = 0
|
||||
if let arguments = component.subject.arguments {
|
||||
animationFile = arguments.gift.file
|
||||
stars = arguments.gift.price
|
||||
text = arguments.text
|
||||
entities = arguments.entities
|
||||
limitNumber = arguments.gift.availability?.remains
|
||||
limitTotal = arguments.gift.availability?.total
|
||||
convertStars = arguments.convertStars
|
||||
incoming = arguments.incoming || arguments.peerId == component.context.account.peerId
|
||||
savedToProfile = arguments.savedToProfile
|
||||
converted = arguments.converted
|
||||
giftId = arguments.gift.id
|
||||
} else {
|
||||
animationFile = nil
|
||||
stars = 0
|
||||
text = nil
|
||||
entities = nil
|
||||
limitNumber = nil
|
||||
limitTotal = nil
|
||||
convertStars = 0
|
||||
}
|
||||
let _ = entities
|
||||
let _ = limitNumber
|
||||
|
||||
var descriptionText: String
|
||||
if incoming {
|
||||
@ -326,11 +333,15 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
))
|
||||
|
||||
if let limitTotal {
|
||||
var remains: Int32 = 0
|
||||
if let gift = state.starGiftsMap[giftId], let availability = gift.availability {
|
||||
remains = availability.remains
|
||||
}
|
||||
tableItems.append(.init(
|
||||
id: "availability",
|
||||
title: "Availability",
|
||||
component: AnyComponent(
|
||||
MultilineTextComponent(text: .plain(NSAttributedString(string: "1 of \(limitTotal)", font: tableFont, textColor: tableTextColor)))
|
||||
MultilineTextComponent(text: .plain(NSAttributedString(string: "\(remains) of \(limitTotal)", font: tableFont, textColor: tableTextColor)))
|
||||
)
|
||||
))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user