Bug fixes

This commit is contained in:
Isaac 2024-03-28 20:01:25 +04:00
parent 12d239ebbf
commit 83de81228a
7 changed files with 55 additions and 17 deletions

View File

@ -11824,9 +11824,9 @@ Sorry for the inconvenience.";
"Business.Links.CreateAction" = "Create a Link to Chat";
"Business.Links.LinksSectionHeader" = "LINKS TO CHAT";
"Business.Links.SimpleLinkInfoUsernamePhone" = "You can also use a simple link for a chat with you — [t.me/%1$@](username) or [t.me/\u{2060}+\u{2060}%2$@](phone).";
"Business.Links.SimpleLinkInfoUsernamePhone" = "You can also use a simple link for a chat with you — [t.me/%1$@](username) or [t.me/\\u{2060}+\\u{2060}%2$@](phone).";
"Business.Links.SimpleLinkInfoUsername" = "You can also use a simple link for a chat with you — [t.me/%@](username).";
"Business.Links.SimpleLinkInfoPhone" = "You can also use a simple link for a chat with you — [t.me/\u{2060}+\u{2060}%@](phone).";
"Business.Links.SimpleLinkInfoPhone" = "You can also use a simple link for a chat with you — [t.me/\\u{2060}+\\u{2060}%@](phone).";
"Business.Links.LinkNameTitle" = "Link Name";
"Business.Links.LinkNameText" = "Add a name for this link that only you will see.";

View File

@ -956,8 +956,11 @@ final class PeerInfoHeaderNode: ASDisplayNode {
let navigationSeparatorAlpha: CGFloat
if isMediaOnly {
navigationSeparatorAlpha = 0.0
} else if state.isEditing && self.isSettings {
//navigationSeparatorAlpha = min(1.0, contentOffset / (navigationHeight * 0.5))
navigationSeparatorAlpha = 0.0
} else {
navigationSeparatorAlpha = state.isEditing && self.isSettings ? min(1.0, contentOffset / (navigationHeight * 0.5)) : 0.0
navigationSeparatorAlpha = 0.0
}
transition.updateAlpha(node: self.navigationBackgroundBackgroundNode, alpha: 1.0 - navigationSeparatorAlpha)
transition.updateAlpha(node: self.navigationSeparatorNode, alpha: navigationSeparatorAlpha)

View File

@ -1117,7 +1117,7 @@ private func settingsEditingItems(data: PeerInfoScreenData?, state: PeerInfoStat
personalChannelTitle = personalChannel.peer.compactDisplayTitle
}
items[.info]!.append(PeerInfoScreenDisclosureItem(id: ItemPeerPersonalChannel, label: .text(personalChannelTitle ?? presentationData.strings.Settings_PersonalChannelItem), text: presentationData.strings.Settings_PersonalChannelEmptyValue, icon: nil, action: {
items[.info]!.append(PeerInfoScreenDisclosureItem(id: ItemPeerPersonalChannel, label: .text(personalChannelTitle ?? presentationData.strings.Settings_PersonalChannelEmptyValue), text: presentationData.strings.Settings_PersonalChannelItem, icon: nil, action: {
interaction.editingOpenPersonalChannel()
}))
}

View File

@ -426,11 +426,11 @@ final class BusinessLinksSetupScreenComponent: Component {
))))
let footerText: String
if let addressName = component.initialData.accountPeer?.addressName, let phoneNumber = component.initialData.accountPeer?.phone {
if let addressName = component.initialData.accountPeer?.addressName, let phoneNumber = component.initialData.accountPeer?.phone, component.initialData.displayPhone {
footerText = environment.strings.Business_Links_SimpleLinkInfoUsernamePhone(addressName, phoneNumber).string
} else if let addressName = component.initialData.accountPeer?.addressName {
footerText = environment.strings.Business_Links_SimpleLinkInfoUsername(addressName).string
} else if let phoneNumber = component.initialData.accountPeer?.phone {
} else if let phoneNumber = component.initialData.accountPeer?.phone, component.initialData.displayPhone {
footerText = environment.strings.Business_Links_SimpleLinkInfoPhone(phoneNumber).string
} else {
footerText = ""
@ -440,7 +440,7 @@ final class BusinessLinksSetupScreenComponent: Component {
component: AnyComponent(ListSectionComponent(
theme: environment.theme,
header: nil,
footer: AnyComponent(MultilineTextComponent(
footer: footerText.isEmpty ? nil : AnyComponent(MultilineTextComponent(
text: .markdown(text: footerText, attributes: MarkdownAttributes(
body: MarkdownAttributeSet(font: Font.regular(15.0), textColor: environment.theme.list.freeTextColor),
bold: MarkdownAttributeSet(font: Font.semibold(15.0), textColor: environment.theme.list.freeTextColor),
@ -613,10 +613,12 @@ public final class BusinessLinksSetupScreen: ViewControllerComponentContainer {
public final class InitialData: BusinessLinksSetupScreenInitialData {
fileprivate let accountPeer: TelegramUser?
fileprivate let businessLinks: TelegramBusinessChatLinks?
fileprivate let displayPhone: Bool
fileprivate init(accountPeer: TelegramUser?, businessLinks: TelegramBusinessChatLinks?) {
fileprivate init(accountPeer: TelegramUser?, businessLinks: TelegramBusinessChatLinks?, displayPhone: Bool) {
self.accountPeer = accountPeer
self.businessLinks = businessLinks
self.displayPhone = displayPhone
}
}
@ -661,18 +663,39 @@ public final class BusinessLinksSetupScreen: ViewControllerComponentContainer {
}
public static func makeInitialData(context: AccountContext) -> Signal<BusinessLinksSetupScreenInitialData, NoError> {
return context.engine.data.get(
TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId),
TelegramEngine.EngineData.Item.Peer.BusinessChatLinks(id: context.account.peerId)
let settingsPromise: Promise<AccountPrivacySettings?>
if let rootController = context.sharedContext.mainWindow?.viewController as? TelegramRootControllerInterface, let current = rootController.getPrivacySettings() {
settingsPromise = current
} else {
settingsPromise = Promise()
settingsPromise.set(.single(nil))
}
return combineLatest(
context.engine.data.get(
TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId),
TelegramEngine.EngineData.Item.Peer.BusinessChatLinks(id: context.account.peerId)
),
settingsPromise.get()
|> take(1)
)
|> map { peer, businessLinks in
|> map { data, settings in
let (peer, businessLinks) = data
var accountPeer: TelegramUser?
if case let .user(user) = peer {
accountPeer = user
}
var displayPhone = true
if let settings {
displayPhone = settings.phoneDiscoveryEnabled
}
return InitialData(
accountPeer: accountPeer,
businessLinks: businessLinks
businessLinks: businessLinks,
displayPhone: displayPhone
)
}
}

View File

@ -674,6 +674,9 @@ final class BusinessIntroSetupScreenComponent: Component {
contentHeight += environment.navigationHeight
contentHeight += 26.0
let maxTitleLength = 32
let maxTextLength = 70
self.recenterOnTag = nil
if let hint = transition.userData(TextFieldComponent.AnimationHint.self), let targetView = hint.view {
if let titleView = self.introSection.findTaggedView(tag: self.titleInputTag) {
@ -703,7 +706,7 @@ final class BusinessIntroSetupScreenComponent: Component {
autocapitalizationType: .none,
autocorrectionType: .no,
returnKeyType: .next,
characterLimit: 32,
characterLimit: maxTitleLength,
displayCharacterLimit: true,
emptyLineHandling: .notAllowed,
updated: { _ in
@ -839,14 +842,16 @@ final class BusinessIntroSetupScreenComponent: Component {
if self.titleInputState.text.string.isEmpty {
titleText = environment.strings.Conversation_EmptyPlaceholder
} else {
titleText = self.titleInputState.text.string
let rawTitle = self.titleInputState.text.string
titleText = rawTitle.count <= maxTitleLength ? rawTitle : String(rawTitle[rawTitle.startIndex ..< rawTitle.index(rawTitle.startIndex, offsetBy: maxTitleLength)])
}
let textText: String
if self.textInputState.text.string.isEmpty {
textText = environment.strings.Conversation_GreetingText
} else {
textText = self.textInputState.text.string
let rawText = self.textInputState.text.string
textText = rawText.count <= maxTextLength ? rawText : String(rawText[rawText.startIndex ..< rawText.index(rawText.startIndex, offsetBy: maxTextLength)])
}
let introContentSize = self.introContent.update(

View File

@ -331,6 +331,12 @@ public final class TextFieldComponent: Component {
}
if let attributedString = attributedString {
let current = self.inputState
let range = NSMakeRange(current.selectionRange.lowerBound, current.selectionRange.count)
if !self.chatInputTextNode(shouldChangeTextIn: range, replacementText: attributedString.string) {
return false
}
self.updateInputState { current in
if let inputText = current.inputText.mutableCopy() as? NSMutableAttributedString {
inputText.replaceCharacters(in: NSMakeRange(current.selectionRange.lowerBound, current.selectionRange.count), with: attributedString)

View File

@ -761,7 +761,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return false
}
case let .businessLinkSetup(link):
let inputText = strongSelf.presentationInterfaceState.interfaceState.effectiveInputState.inputText
var inputText = convertMarkdownToAttributes(strongSelf.presentationInterfaceState.interfaceState.effectiveInputState.inputText)
inputText = trimChatInputText(inputText)
let entities = generateChatInputTextEntities(inputText, generateLinks: false)
let message = inputText.string