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.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.CreatorOn" = "You should be the owner of the group.";

View File

@ -4162,7 +4162,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return
}
let attributedTitle: NSAttributedString?
var attributedTitle: NSAttributedString?
let attributedText: NSAttributedString
let theme = AlertControllerTheme(presentationData: strongSelf.presentationData)
@ -4198,12 +4198,17 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
attributedText = formattedString
}
} else {
let stringWithRanges = strongSelf.presentationData.strings.RequestPeer_SelectionConfirmationInviteText(botName, peerName)
let formattedString = NSMutableAttributedString(string: stringWithRanges.string, font: Font.regular(13.0), textColor: theme.primaryColor, paragraphAlignment: .center)
for range in stringWithRanges.ranges.prefix(2) {
formattedString.addAttribute(.font, value: Font.semibold(13.0), range: range.range)
if case let .group(group) = peerType, group.botParticipant {
let stringWithRanges = strongSelf.presentationData.strings.RequestPeer_SelectionConfirmationInviteText(botName, peerName)
let formattedString = NSMutableAttributedString(string: stringWithRanges.string, font: Font.regular(13.0), textColor: theme.primaryColor, paragraphAlignment: .center)
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:
break
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, {
complete()
})

View File

@ -148,7 +148,7 @@ public func chatTranslationState(context: AccountContext, peerId: EnginePeer.Id)
} else {
return .single(nil)
|> 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
return messageHistoryView.0.entries.count > 1
}
@ -175,7 +175,7 @@ public func chatTranslationState(context: AccountContext, peerId: EnginePeer.Id)
}
count += 1
}
if count >= 5 {
if count >= 10 {
break
}
}
@ -186,8 +186,10 @@ public func chatTranslationState(context: AccountContext, peerId: EnginePeer.Id)
var mostFrequent: (String, Int)?
for (lang, count) in fromLangs {
if let current = mostFrequent, count > current.1 {
mostFrequent = (lang, count)
if let current = mostFrequent {
if count > current.1 {
mostFrequent = (lang, count)
}
} else {
mostFrequent = (lang, count)
}