Various fixes

This commit is contained in:
Ilya Laktyushin 2023-01-23 18:07:50 +04:00
parent 681dffbee7
commit ab9bc3e655
3 changed files with 19 additions and 12 deletions

View File

@ -8649,7 +8649,7 @@ Sorry for the inconvenience.";
"RequestPeer.Requirement.Group.HasUsernameOn" = "The group should be public."; "RequestPeer.Requirement.Group.HasUsernameOn" = "The group should be public.";
"RequestPeer.Requirement.Group.ForumOff" = "The group should have topics turned off."; "RequestPeer.Requirement.Group.ForumOff" = "The group should have topics turned off.";
"RequestPeer.Requirement.Group.ForumOn" = "The group should have topics turned on."; "RequestPeer.Requirement.Group.ForumOn" = "The group should have topics turned on.";
"RequestPeer.Requirement.Group.ParticipantOn" = "Bot should be in the group."; "RequestPeer.Requirement.Group.ParticipantOn" = "Bot should be in the group.";
"RequestPeer.Requirement.Group.CreatorOn" = "You should be the owner of the group."; "RequestPeer.Requirement.Group.CreatorOn" = "You should be the owner of the group.";

View File

@ -4162,7 +4162,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return return
} }
let attributedTitle: NSAttributedString? var attributedTitle: NSAttributedString?
let attributedText: NSAttributedString let attributedText: NSAttributedString
let theme = AlertControllerTheme(presentationData: strongSelf.presentationData) let theme = AlertControllerTheme(presentationData: strongSelf.presentationData)
@ -4198,12 +4198,17 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
attributedText = formattedString attributedText = formattedString
} }
} else { } else {
let stringWithRanges = strongSelf.presentationData.strings.RequestPeer_SelectionConfirmationInviteText(botName, peerName) if case let .group(group) = peerType, group.botParticipant {
let formattedString = NSMutableAttributedString(string: stringWithRanges.string, font: Font.regular(13.0), textColor: theme.primaryColor, paragraphAlignment: .center) let stringWithRanges = strongSelf.presentationData.strings.RequestPeer_SelectionConfirmationInviteText(botName, peerName)
for range in stringWithRanges.ranges.prefix(2) { let formattedString = NSMutableAttributedString(string: stringWithRanges.string, font: Font.regular(13.0), textColor: theme.primaryColor, paragraphAlignment: .center)
formattedString.addAttribute(.font, value: Font.semibold(13.0), range: range.range) for range in stringWithRanges.ranges.prefix(2) {
formattedString.addAttribute(.font, value: Font.semibold(13.0), range: range.range)
}
attributedText = formattedString
} else {
attributedTitle = nil
attributedText = NSAttributedString(string: strongSelf.presentationData.strings.RequestPeer_SelectionConfirmationTitle(peerName, botName).string, font: Font.medium(17.0), textColor: theme.primaryColor, paragraphAlignment: .center)
} }
attributedText = formattedString
} }
} }
@ -4233,7 +4238,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
case .user: case .user:
break break
case let .group(group): case let .group(group):
let createGroupController = createGroupControllerImpl(context: context, peerIds: peerId.flatMap { [$0] } ?? [], mode: .requestPeer(group), willComplete: { peerName, complete in let createGroupController = createGroupControllerImpl(context: context, peerIds: group.botParticipant || group.botAdminRights != nil ? (peerId.flatMap { [$0] } ?? []) : [], mode: .requestPeer(group), willComplete: { peerName, complete in
presentConfirmation(peerName, false, { presentConfirmation(peerName, false, {
complete() complete()
}) })

View File

@ -148,7 +148,7 @@ public func chatTranslationState(context: AccountContext, peerId: EnginePeer.Id)
} else { } else {
return .single(nil) return .single(nil)
|> then( |> then(
context.account.viewTracker.aroundMessageHistoryViewForLocation(.peer(peerId: peerId, threadId: nil), index: .upperBound, anchorIndex: .upperBound, count: 10, fixedCombinedReadStates: nil) context.account.viewTracker.aroundMessageHistoryViewForLocation(.peer(peerId: peerId, threadId: nil), index: .upperBound, anchorIndex: .upperBound, count: 16, fixedCombinedReadStates: nil)
|> filter { messageHistoryView -> Bool in |> filter { messageHistoryView -> Bool in
return messageHistoryView.0.entries.count > 1 return messageHistoryView.0.entries.count > 1
} }
@ -175,7 +175,7 @@ public func chatTranslationState(context: AccountContext, peerId: EnginePeer.Id)
} }
count += 1 count += 1
} }
if count >= 5 { if count >= 10 {
break break
} }
} }
@ -186,8 +186,10 @@ public func chatTranslationState(context: AccountContext, peerId: EnginePeer.Id)
var mostFrequent: (String, Int)? var mostFrequent: (String, Int)?
for (lang, count) in fromLangs { for (lang, count) in fromLangs {
if let current = mostFrequent, count > current.1 { if let current = mostFrequent {
mostFrequent = (lang, count) if count > current.1 {
mostFrequent = (lang, count)
}
} else { } else {
mostFrequent = (lang, count) mostFrequent = (lang, count)
} }