Various fixes

This commit is contained in:
Ilya Laktyushin 2024-09-12 15:21:37 +04:00
parent 1e56520356
commit 941d45ccb8
9 changed files with 39 additions and 28 deletions

View file

@ -610,6 +610,12 @@ private final class MainButtonNode: HighlightTrackingButtonNode {
self.setupShimmering()
let colorUpdated = previousState.textColor != state.textColor
if let progressNode = self.progressNode, colorUpdated {
let diameter: CGFloat = size.height - 22.0
progressNode.image = generateIndefiniteActivityIndicatorImage(color: state.textColor, diameter: diameter, lineWidth: 3.0)
}
if let text = state.text {
let font: UIFont
switch state.font {

View file

@ -566,6 +566,7 @@ private func parseDetails(_ item: [String: Any], _ url: String, _ media: inout [
)
}
private let nonListCharacters = CharacterSet(charactersIn: "0123456789").inverted
private func parseList(_ input: [String: Any], _ url: String, _ media: inout [MediaId: Media]) -> InstantPageBlock? {
guard let content = input["content"] as? [Any], let tag = input["tag"] as? String else {
return nil
@ -598,7 +599,10 @@ private func parseList(_ input: [String: Any], _ url: String, _ media: inout [Me
if case let .text(text, _) = item {
if case .empty = text {
} else {
allEmpty = false
let plainText = text.plainText
if !plainText.isEmpty && plainText.rangeOfCharacter(from: nonListCharacters) != nil {
allEmpty = false
}
break
}
} else {

View file

@ -895,8 +895,7 @@ func layoutTextItemWithString(_ string: NSAttributedString, boundingWidth: CGFlo
for var item in additionalItems {
item.frame = item.frame.offsetBy(dx: 0.0, dy: abs(topInset))
}
let scrollableItem = InstantPageScrollableTextItem(frame: CGRect(x: 0.0, y: 0.0, width: boundingWidth + horizontalInset * 2.0, height: height + abs(topInset) + bottomInset), item: textItem, additionalItems: additionalItems, totalWidth: textWidth, horizontalInset: horizontalInset, rtl: textItem.containsRTL)
let scrollableItem = InstantPageScrollableTextItem(frame: CGRect(origin: offset, size: CGSize(width: boundingWidth + horizontalInset * 2.0, height: height + abs(topInset) + bottomInset)), item: textItem, additionalItems: additionalItems, totalWidth: textWidth, horizontalInset: horizontalInset, rtl: textItem.containsRTL)
items.append(scrollableItem)
} else {
items.append(contentsOf: additionalItems)

View file

@ -268,7 +268,7 @@ private enum InviteLinkViewEntry: Comparable, Identifiable {
} else {
interaction.shareLink(invite)
}
}, contextAction: { node, gesture in
}, contextAction: invite.link?.hasSuffix("...") == true ? nil : { node, gesture in
interaction.contextAction(invite, node, gesture)
}, viewAction: {
})

View file

@ -641,7 +641,7 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode {
constrainedSize: textConstrainedSize,
availableReactions: item.associatedData.availableReactions,
savedMessageTags: item.associatedData.savedMessageTags,
reactions: dateReactionsAndPeers.reactions,
reactions: item.presentationData.isPreview ? [] : dateReactionsAndPeers.reactions,
reactionPeers: dateReactionsAndPeers.peers,
displayAllReactionPeers: item.message.id.peerId.namespace == Namespaces.Peer.CloudUser,
areReactionsTags: item.topMessage.areReactionsTags(accountPeerId: item.context.account.peerId),

View file

@ -188,27 +188,29 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
return true
}
case let .editExportedInvitation(_, invite), let .revokeExportedInvitation(invite), let .deleteExportedInvitation(invite), let .participantJoinedViaInvite(invite, _), let .participantJoinByRequest(invite, _):
if let inviteLink = invite.link, !inviteLink.hasSuffix("...") {
if let inviteLink = invite.link {
if invite.isPermanent {
let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData)
var items: [ActionSheetItem] = []
items.append(ActionSheetTextItem(title: inviteLink))
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.InviteLink_ContextRevoke, color: .destructive, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
if let strongSelf = self {
let _ = (strongSelf.context.engine.peers.revokePeerExportedInvitation(peerId: peer.id, link: inviteLink)
|> deliverOnMainQueue).startStandalone(completed: { [weak self] in
self?.eventLogContext.reload()
})
}
}))
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
if !inviteLink.hasSuffix("...") {
let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData)
var items: [ActionSheetItem] = []
items.append(ActionSheetTextItem(title: inviteLink))
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.InviteLink_ContextRevoke, color: .destructive, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
})
])])
strongSelf.presentController(actionSheet, .window(.root), nil)
if let strongSelf = self {
let _ = (strongSelf.context.engine.peers.revokePeerExportedInvitation(peerId: peer.id, link: inviteLink)
|> deliverOnMainQueue).startStandalone(completed: { [weak self] in
self?.eventLogContext.reload()
})
}
}))
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
})
])])
strongSelf.presentController(actionSheet, .window(.root), nil)
}
} else {
let controller = InviteLinkViewController(
context: strongSelf.context,

View file

@ -505,7 +505,7 @@ private final class SheetContent: CombinedComponent {
}
if let range = buttonAttributedString.string.range(of: "#"), let starImage = state.cachedStarImage?.0 {
buttonAttributedString.addAttribute(.attachment, value: starImage, range: NSRange(range, in: buttonAttributedString.string))
buttonAttributedString.addAttribute(.foregroundColor, value: UIColor(rgb: 0xffffff), range: NSRange(range, in: buttonAttributedString.string))
buttonAttributedString.addAttribute(.foregroundColor, value: environment.theme.list.itemCheckColors.foregroundColor, range: NSRange(range, in: buttonAttributedString.string))
buttonAttributedString.addAttribute(.baselineOffset, value: 1.0, range: NSRange(range, in: buttonAttributedString.string))
}
@ -603,7 +603,7 @@ private final class SheetContent: CombinedComponent {
})
}
),
availableSize: CGSize(width: 361.0, height: 50),
availableSize: CGSize(width: context.availableSize.width - 16.0 * 2.0, height: 50),
transition: .immediate
)
context.add(button

View file

@ -348,7 +348,7 @@ private final class SheetContent: CombinedComponent {
}
}
),
availableSize: CGSize(width: 361.0, height: 50),
availableSize: CGSize(width: context.availableSize.width - sideInset * 2.0, height: 50),
transition: .immediate
)
context.add(button

View file

@ -13,7 +13,7 @@
const readability = new Readability(cleanDoc)
const result = readability.parse()
if (result.length && result.length < 1000) {
if (result.length && result.length < 500) {
return null
}