Add stories count limit tooltip

This commit is contained in:
Ilya Laktyushin 2023-07-15 21:19:47 +02:00
parent 61c795b95b
commit a9f4258c3e

View File

@ -2535,9 +2535,28 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}
fileprivate func openStoryCamera(fromList: Bool) {
var reachedCountLimit = false
var premiumNeeded = false
let storiesCountLimit = self.context.userLimits.maxExpiringStoriesCount
if let rawStorySubscriptions = self.rawStorySubscriptions, let accountItem = rawStorySubscriptions.accountItem {
if accountItem.storyCount >= self.context.userLimits.maxExpiringStoriesCount {
reachedCountLimit = true
}
}
switch self.storyPostingAvailability {
case .premium:
guard self.isPremium else {
if !self.isPremium {
premiumNeeded = true
}
case .disabled:
return
default:
break
}
if reachedCountLimit || premiumNeeded {
if let componentView = self.chatListHeaderView() {
var sourceFrame: CGRect?
if fromList {
@ -2552,11 +2571,21 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
if let sourceFrame {
let context = self.context
let location = CGRect(origin: CGPoint(x: sourceFrame.midX, y: sourceFrame.maxY), size: CGSize())
let text: String
if premiumNeeded {
text = "Posting stories is currently available only\nto subscribers of [Telegram Premium]()."
} else if reachedCountLimit {
text = "You can't post more than **\(storiesCountLimit)** stories in **24 hours**."
} else {
text = ""
}
let tooltipController = TooltipScreen(
context: context,
account: context.account,
sharedContext: context.sharedContext,
text: .markdown(text: "Posting stories is currently available only\nto subscribers of [Telegram Premium]()."),
text: .markdown(text: text),
style: .customBlur(UIColor(rgb: 0x2a2a2a), 2.0),
icon: .none,
location: .point(location, .top),
@ -2575,11 +2604,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}
return
}
case .disabled:
return
default:
break
}
var cameraTransitionIn: StoryCameraTransitionIn?
if let componentView = self.chatListHeaderView() {