Merge commit '399933bc5e681018a21941b27081142caed9cb0b'

This commit is contained in:
Isaac
2025-03-13 00:35:11 +01:00
143 changed files with 3629 additions and 755 deletions

View File

@@ -4102,7 +4102,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
strongSelf.secretIconNode = iconNode
}
iconNode.image = currentSecretIconImage
transition.updateFrame(node: iconNode, frame: CGRect(origin: CGPoint(x: contentRect.origin.x, y: contentRect.origin.y + floor((titleLayout.size.height - currentSecretIconImage.size.height) / 2.0)), size: currentSecretIconImage.size))
transition.updateFrame(node: iconNode, frame: CGRect(origin: CGPoint(x: contentRect.origin.x + titleLeftOffset, y: contentRect.origin.y + floor((titleLayout.size.height - currentSecretIconImage.size.height) / 2.0)), size: currentSecretIconImage.size))
titleOffset += currentSecretIconImage.size.width + 3.0
} else if let secretIconNode = strongSelf.secretIconNode {
strongSelf.secretIconNode = nil

View File

@@ -115,6 +115,7 @@ public final class ChatListNodeInteraction {
let openWebApp: (TelegramUser) -> Void
let openPhotoSetup: () -> Void
let openAdInfo: (ASDisplayNode) -> Void
let openAccountFreezeInfo: () -> Void
public var searchTextHighightState: String?
var highlightedChatLocation: ChatListHighlightedLocation?
@@ -173,7 +174,8 @@ public final class ChatListNodeInteraction {
editPeer: @escaping (ChatListItem) -> Void,
openWebApp: @escaping (TelegramUser) -> Void,
openPhotoSetup: @escaping () -> Void,
openAdInfo: @escaping (ASDisplayNode) -> Void
openAdInfo: @escaping (ASDisplayNode) -> Void,
openAccountFreezeInfo: @escaping () -> Void
) {
self.activateSearch = activateSearch
self.peerSelected = peerSelected
@@ -220,6 +222,7 @@ public final class ChatListNodeInteraction {
self.openWebApp = openWebApp
self.openPhotoSetup = openPhotoSetup
self.openAdInfo = openAdInfo
self.openAccountFreezeInfo = openAccountFreezeInfo
}
}
@@ -770,6 +773,8 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
nodeInteraction?.openStarsTopup(amount.value)
case .setupPhoto:
nodeInteraction?.openPhotoSetup()
case .accountFreeze:
nodeInteraction?.openAccountFreezeInfo()
}
case .hide:
nodeInteraction?.dismissNotice(notice)
@@ -1116,6 +1121,8 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
nodeInteraction?.openStarsTopup(amount.value)
case .setupPhoto:
nodeInteraction?.openPhotoSetup()
case .accountFreeze:
nodeInteraction?.openAccountFreezeInfo()
}
case .hide:
nodeInteraction?.dismissNotice(notice)
@@ -1239,6 +1246,7 @@ public final class ChatListNode: ListView {
public var openWebApp: ((TelegramUser) -> Void)?
public var openPhotoSetup: (() -> Void)?
public var openAdInfo: ((ASDisplayNode) -> Void)?
public var openAccountFreezeInfo: (() -> Void)?
private var theme: PresentationTheme
@@ -1899,6 +1907,8 @@ public final class ChatListNode: ListView {
self.openPhotoSetup?()
}, openAdInfo: { [weak self] node in
self?.openAdInfo?(node)
}, openAccountFreezeInfo: { [weak self] in
self?.openAccountFreezeInfo?()
})
nodeInteraction.isInlineMode = isInlineMode
@@ -1988,6 +1998,16 @@ public final class ChatListNode: ListView {
let twoStepData: Signal<TwoStepVerificationConfiguration?, NoError> = .single(nil) |> then(context.engine.auth.twoStepVerificationConfiguration() |> map(Optional.init))
let accountFreezeConfiguration = (context.account.postbox.preferencesView(keys: [PreferencesKeys.appConfiguration])
|> map { view -> AppConfiguration in
let appConfiguration: AppConfiguration = view.values[PreferencesKeys.appConfiguration]?.get(AppConfiguration.self) ?? AppConfiguration.defaultValue
return appConfiguration
}
|> distinctUntilChanged
|> map { appConfiguration -> AccountFreezeConfiguration in
return AccountFreezeConfiguration.with(appConfiguration: appConfiguration)
})
let suggestedChatListNoticeSignal: Signal<ChatListNotice?, NoError> = combineLatest(
context.engine.notices.getServerProvidedSuggestions(),
context.engine.notices.getServerDismissedSuggestions(),
@@ -1998,11 +2018,12 @@ public final class ChatListNode: ListView {
TelegramEngine.EngineData.Item.Peer.Birthday(id: context.account.peerId)
),
context.account.stateManager.contactBirthdays,
starsSubscriptionsContextPromise.get()
starsSubscriptionsContextPromise.get(),
accountFreezeConfiguration
)
|> mapToSignal { suggestions, dismissedSuggestions, configuration, newSessionReviews, data, birthdays, starsSubscriptionsContext -> Signal<ChatListNotice?, NoError> in
|> mapToSignal { suggestions, dismissedSuggestions, configuration, newSessionReviews, data, birthdays, starsSubscriptionsContext, accountFreezeConfiguration -> Signal<ChatListNotice?, NoError> in
let (accountPeer, birthday) = data
if let newSessionReview = newSessionReviews.first {
return .single(.reviewLogin(newSessionReview: newSessionReview, totalCount: newSessionReviews.count))
}
@@ -2035,8 +2056,10 @@ public final class ChatListNode: ListView {
if dismissedSuggestions.contains(.todayBirthdays) {
todayBirthdayPeerIds = []
}
if suggestions.contains(.starsSubscriptionLowBalance) {
if let _ = accountFreezeConfiguration.freezeUntilDate {
return .single(.accountFreeze)
} else if suggestions.contains(.starsSubscriptionLowBalance) {
if let starsSubscriptionsContext {
return starsSubscriptionsContext.state
|> map { state in

View File

@@ -92,6 +92,7 @@ public enum ChatListNotice: Equatable {
case premiumGrace
case starsSubscriptionLowBalance(amount: StarsAmount, peers: [EnginePeer])
case setupPhoto(EnginePeer)
case accountFreeze
}
enum ChatListNodeEntry: Comparable, Identifiable {

View File

@@ -288,6 +288,10 @@ final class ChatListNoticeItemNode: ItemListRevealOptionsItemNode {
titleString = NSAttributedString(string: item.strings.ChatList_AddPhoto_Title, font: titleFont, textColor: item.theme.rootController.navigationBar.primaryTextColor)
textString = NSAttributedString(string: item.strings.ChatList_AddPhoto_Text, font: smallTextFont, textColor: item.theme.rootController.navigationBar.secondaryTextColor)
avatarPeer = accountPeer
case .accountFreeze:
//TODO:localize
titleString = NSAttributedString(string: "Your account is frozen", font: titleFont, textColor: item.theme.list.itemDestructiveColor)
textString = NSAttributedString(string: "Tap to view details and submit an appeal.", font: smallTextFont, textColor: item.theme.rootController.navigationBar.secondaryTextColor)
}
var leftInset: CGFloat = sideInset