Skip to content

Commit 7a99577

Browse files
committed
Merge branches 'master' and 'master' of gitlab.com:peter-iakovlev/telegram-ios
2 parents 3c87b30 + b625243 commit 7a99577

File tree

43 files changed

+857
-484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+857
-484
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ internal:
2323
- export PATH=`gem environment gemdir`/bin:$PATH
2424
- python3 -u build-system/Make/Make.py remote-build --darwinContainers="$DARWIN_CONTAINERS" --darwinContainersHost="$DARWIN_CONTAINERS_HOST" --cacheHost="$TELEGRAM_BAZEL_CACHE_HOST" --configurationPath="build-system/appcenter-configuration.json" --gitCodesigningRepository="$TELEGRAM_GIT_CODESIGNING_REPOSITORY" --gitCodesigningType=adhoc --configuration=release_arm64
2525
- python3 -u build-system/Make/DeployToFirebase.py --configuration="$TELEGRAM_PRIVATE_DATA_PATH/firebase-configurations/firebase-internal.json" --ipa="build/artifacts/Telegram.ipa" --dsyms="build/artifacts/Telegram.DSYMs.zip"
26+
- rm -rf build-input/configuration-repository-workdir
27+
- rm -rf build-input/configuration-repository
2628
- python3 -u build-system/Make/Make.py remote-build --darwinContainers="$DARWIN_CONTAINERS" --darwinContainersHost="$DARWIN_CONTAINERS_HOST" --cacheHost="$TELEGRAM_BAZEL_CACHE_HOST" --configurationPath="$TELEGRAM_PRIVATE_DATA_PATH/build-configurations/enterprise-configuration.json" --gitCodesigningRepository="$TELEGRAM_GIT_CODESIGNING_REPOSITORY" --gitCodesigningType=enterprise --configuration=release_arm64
2729
- python3 -u build-system/Make/DeployToFirebase.py --configuration="$TELEGRAM_PRIVATE_DATA_PATH/firebase-configurations/firebase-enterprise.json" --ipa="build/artifacts/Telegram.ipa" --dsyms="build/artifacts/Telegram.DSYMs.zip"
2830
environment:

build-system/Make/BuildConfiguration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def load_codesigning_data_from_git(working_dir, repo_url, temp_key_path, branch,
131131
original_working_dir = os.getcwd()
132132
os.chdir(encrypted_working_dir)
133133
if always_fetch:
134-
check_run_system('GIT_SSH_COMMAND="{ssh_command}" git fetch'.format(ssh_command=ssh_command))
134+
check_run_system('GIT_SSH_COMMAND="{ssh_command}" git fetch --all'.format(ssh_command=ssh_command))
135135
check_run_system('git checkout "{branch}"'.format(branch=branch))
136136
if always_fetch:
137137
check_run_system('GIT_SSH_COMMAND="{ssh_command}" git pull'.format(ssh_command=ssh_command))

submodules/AccountContext/Sources/AccountContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ public protocol SharedAccountContext: AnyObject {
11861186
func makeHashtagSearchController(context: AccountContext, peer: EnginePeer?, query: String, stories: Bool, forceDark: Bool) -> ViewController
11871187
func makeStorySearchController(context: AccountContext, scope: StorySearchControllerScope, listContext: SearchStoryListContext?) -> ViewController
11881188
func makeMyStoriesController(context: AccountContext, isArchive: Bool) -> ViewController
1189-
func makeStorySelectionController(context: AccountContext, peerId: EnginePeer.Id, completion: @escaping ([EngineStoryItem]) -> Void) -> ViewController
1189+
func makeStorySelectionController(context: AccountContext, peerId: EnginePeer.Id, excludeIds: [Int32], completion: @escaping ([EngineStoryItem]) -> Void) -> ViewController
11901190
func makeArchiveSettingsController(context: AccountContext) -> ViewController
11911191
func makeFilterSettingsController(context: AccountContext, modal: Bool, scrollToTags: Bool, dismissed: (() -> Void)?) -> ViewController
11921192
func makeBusinessSetupScreen(context: AccountContext) -> ViewController

submodules/AccountContext/Sources/ChatController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public final class ChatMessageItemAssociatedData: Equatable {
4848
public let availableMessageEffects: AvailableMessageEffects?
4949
public let savedMessageTags: SavedMessageTags?
5050
public let defaultReaction: MessageReaction.Reaction?
51+
public let areStarReactionsEnabled: Bool
5152
public let isPremium: Bool
5253
public let forceInlineReactions: Bool
5354
public let alwaysDisplayTranscribeButton: DisplayTranscribeButton
@@ -83,6 +84,7 @@ public final class ChatMessageItemAssociatedData: Equatable {
8384
availableMessageEffects: AvailableMessageEffects?,
8485
savedMessageTags: SavedMessageTags?,
8586
defaultReaction: MessageReaction.Reaction?,
87+
areStarReactionsEnabled: Bool,
8688
isPremium: Bool,
8789
accountPeer: EnginePeer?,
8890
forceInlineReactions: Bool = false,
@@ -117,6 +119,7 @@ public final class ChatMessageItemAssociatedData: Equatable {
117119
self.availableMessageEffects = availableMessageEffects
118120
self.savedMessageTags = savedMessageTags
119121
self.defaultReaction = defaultReaction
122+
self.areStarReactionsEnabled = areStarReactionsEnabled
120123
self.isPremium = isPremium
121124
self.accountPeer = accountPeer
122125
self.forceInlineReactions = forceInlineReactions

submodules/Components/ReactionButtonListComponent/Sources/ReactionButtonListComponent.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -842,11 +842,13 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView {
842842
let compactString = countString(Int64(spec.component.count))
843843
#endif
844844

845-
for character in compactString {
846-
counterComponents.append(String(character))
847-
}
848-
for character in "\(spec.component.count)" {
849-
extractedCounterComponents.append(String(character))
845+
if spec.component.count != 0 {
846+
for character in compactString {
847+
counterComponents.append(String(character))
848+
}
849+
for character in "\(spec.component.count)" {
850+
extractedCounterComponents.append(String(character))
851+
}
850852
}
851853
}
852854

submodules/PremiumUI/Sources/BadgeLabelView.swift

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ private let labelWidth: CGFloat = 16.0
77
private let labelHeight: CGFloat = 36.0
88
private let labelSize = CGSize(width: labelWidth, height: labelHeight)
99
private let font = Font.with(size: 24.0, design: .round, weight: .semibold, traits: [])
10+
private let suffixFont = Font.with(size: 22.0, design: .regular, weight: .regular, traits: [])
1011

1112
final class BadgeLabelView: UIView {
1213
private class StackView: UIView {
@@ -76,7 +77,9 @@ final class BadgeLabelView: UIView {
7677
}
7778

7879
private var itemViews: [Int: StackView] = [:]
79-
private var staticLabel = UILabel()
80+
private var staticLabel = ImmediateTextNode()
81+
82+
private var params: (value: String, suffix: String?)?
8083

8184
init() {
8285
super.init(frame: .zero)
@@ -91,31 +94,49 @@ final class BadgeLabelView: UIView {
9194

9295
var color: UIColor = .white {
9396
didSet {
94-
self.staticLabel.textColor = self.color
97+
if let params {
98+
self.staticLabel.attributedText = BadgeLabelView.makeText(value: params.value, suffix: params.suffix, color: self.color)
99+
let _ = self.staticLabel.updateLayout(CGSize(width: 1000.0, height: 1000.0))
100+
}
95101
for (_, view) in self.itemViews {
96102
view.color = self.color
97103
}
98104
}
99105
}
100106

101-
func update(value: String, transition: ComponentTransition) -> CGSize {
102-
if value.contains(" ") || value.contains(".") || value.contains(where: { !$0.isNumber }) {
107+
static func makeText(value: String, suffix: String?, color: UIColor) -> NSAttributedString {
108+
let string = NSMutableAttributedString()
109+
string.append(NSAttributedString(string: value, font: font, textColor: color))
110+
if let suffix {
111+
string.append(NSAttributedString(string: suffix, font: suffixFont, textColor: color.withMultipliedAlpha(0.6)))
112+
}
113+
return string
114+
}
115+
116+
static func calculateSize(value: String, suffix: String?) -> CGSize {
117+
let textView = ImmediateTextView()
118+
textView.attributedText = BadgeLabelView.makeText(value: value, suffix: suffix, color: .black)
119+
return textView.updateLayout(CGSize(width: 1000.0, height: 1000.0))
120+
}
121+
122+
func update(value: String, suffix: String?, transition: ComponentTransition) -> CGSize {
123+
self.params = (value, suffix)
124+
125+
if value.contains(" ") || value.contains(".") || value.contains(where: { !$0.isNumber }) || suffix != nil {
103126
for (_, view) in self.itemViews {
104127
view.isHidden = true
105128
}
106129

107-
if self.staticLabel.superview == nil {
108-
self.staticLabel.textColor = self.color
109-
self.staticLabel.font = font
110-
111-
self.addSubview(self.staticLabel)
130+
if self.staticLabel.view.superview == nil {
131+
self.addSubview(self.staticLabel.view)
112132
}
113133

114-
self.staticLabel.text = value
115-
let size = self.staticLabel.sizeThatFits(CGSize(width: 100.0, height: 100.0))
116-
self.staticLabel.frame = CGRect(origin: .zero, size: CGSize(width: size.width, height: labelHeight))
134+
self.staticLabel.attributedText = BadgeLabelView.makeText(value: value, suffix: suffix, color: self.color)
135+
136+
let size = self.staticLabel.updateLayout(CGSize(width: 1000.0, height: 1000.0))
137+
self.staticLabel.frame = CGRect(origin: CGPoint(x: 0.0, y: 3.0), size: CGSize(width: size.width, height: labelHeight))
117138

118-
return CGSize(width: ceil(self.staticLabel.bounds.width), height: ceil(self.staticLabel.bounds.height))
139+
return size
119140
}
120141

121142
let string = value

submodules/PremiumUI/Sources/PremiumLimitScreen.swift

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class PremiumLimitDisplayComponent: Component {
5353
private let activeTitleColor: UIColor
5454
private let badgeIconName: String?
5555
private let badgeText: String?
56+
private let badgeTextSuffix: String?
5657
private let badgePosition: CGFloat
5758
private let badgeGraphPosition: CGFloat
5859
private let invertProgress: Bool
@@ -69,6 +70,7 @@ public class PremiumLimitDisplayComponent: Component {
6970
activeTitleColor: UIColor,
7071
badgeIconName: String?,
7172
badgeText: String?,
73+
badgeTextSuffix: String? = nil,
7274
badgePosition: CGFloat,
7375
badgeGraphPosition: CGFloat,
7476
invertProgress: Bool = false,
@@ -84,6 +86,7 @@ public class PremiumLimitDisplayComponent: Component {
8486
self.activeTitleColor = activeTitleColor
8587
self.badgeIconName = badgeIconName
8688
self.badgeText = badgeText
89+
self.badgeTextSuffix = badgeTextSuffix
8790
self.badgePosition = badgePosition
8891
self.badgeGraphPosition = badgeGraphPosition
8992
self.invertProgress = invertProgress
@@ -121,6 +124,9 @@ public class PremiumLimitDisplayComponent: Component {
121124
if lhs.badgeText != rhs.badgeText {
122125
return false
123126
}
127+
if lhs.badgeTextSuffix != rhs.badgeTextSuffix {
128+
return false
129+
}
124130
if lhs.badgePosition != rhs.badgePosition {
125131
return false
126132
}
@@ -197,7 +203,7 @@ public class PremiumLimitDisplayComponent: Component {
197203
self.badgeIcon.contentMode = .center
198204

199205
self.badgeLabel = BadgeLabelView()
200-
let _ = self.badgeLabel.update(value: "0", transition: .immediate)
206+
let _ = self.badgeLabel.update(value: "0", suffix: nil, transition: .immediate)
201207
self.badgeLabel.mask = self.badgeLabelMaskView
202208

203209
super.init(frame: frame)
@@ -312,7 +318,7 @@ public class PremiumLimitDisplayComponent: Component {
312318
if from == nil {
313319
frameTransition = frameTransition.withAnimation(.none)
314320
}
315-
let badgeLabelSize = self.badgeLabel.update(value: badgeText, transition: transition)
321+
let badgeLabelSize = self.badgeLabel.update(value: badgeText, suffix: component.badgeTextSuffix, transition: transition)
316322
frameTransition.setFrame(view: self.badgeLabel, frame: CGRect(origin: CGPoint(x: 14.0 + floorToScreenPixels((badgeFullSize.width - badgeLabelSize.width) / 2.0), y: 5.0), size: badgeLabelSize))
317323
}
318324
}
@@ -514,22 +520,7 @@ public class PremiumLimitDisplayComponent: Component {
514520

515521
let countWidth: CGFloat
516522
if let badgeText = component.badgeText {
517-
switch badgeText.count {
518-
case 1:
519-
countWidth = 20.0
520-
case 2:
521-
countWidth = 35.0
522-
case 3:
523-
countWidth = 51.0
524-
case 4:
525-
countWidth = 60.0
526-
case 5:
527-
countWidth = 74.0
528-
case 6:
529-
countWidth = 88.0
530-
default:
531-
countWidth = 51.0
532-
}
523+
countWidth = BadgeLabelView.calculateSize(value: badgeText, suffix: component.badgeTextSuffix).width + 4.0
533524
} else {
534525
countWidth = 51.0
535526
}
@@ -603,15 +594,15 @@ public class PremiumLimitDisplayComponent: Component {
603594
}
604595

605596
self.badgeIcon.frame = CGRect(x: 10.0, y: 9.0, width: 30.0, height: 30.0)
606-
self.badgeLabelMaskView.frame = CGRect(x: 0.0, y: 0.0, width: 100.0, height: 36.0)
597+
self.badgeLabelMaskView.frame = CGRect(x: 0.0, y: 0.0, width: 200.0, height: 36.0)
607598

608599
if component.isPremiumDisabled {
609600
if !self.didPlayAppearanceAnimation {
610601
self.didPlayAppearanceAnimation = true
611602

612603
self.badgeView.alpha = 1.0
613604
if let badgeText = component.badgeText {
614-
let badgeLabelSize = self.badgeLabel.update(value: badgeText, transition: .immediate)
605+
let badgeLabelSize = self.badgeLabel.update(value: badgeText, suffix: component.badgeTextSuffix, transition: .immediate)
615606
transition.setFrame(view: self.badgeLabel, frame: CGRect(origin: CGPoint(x: 14.0 + floorToScreenPixels((badgeFullSize.width - badgeLabelSize.width) / 2.0), y: 5.0), size: badgeLabelSize))
616607
}
617608
}
@@ -621,7 +612,7 @@ public class PremiumLimitDisplayComponent: Component {
621612
if component.badgePosition < 0.1 {
622613
self.badgeView.alpha = 1.0
623614
if let badgeText = component.badgeText {
624-
let badgeLabelSize = self.badgeLabel.update(value: badgeText, transition: .immediate)
615+
let badgeLabelSize = self.badgeLabel.update(value: badgeText, suffix: component.badgeTextSuffix, transition: .immediate)
625616
transition.setFrame(view: self.badgeLabel, frame: CGRect(origin: CGPoint(x: 14.0 + floorToScreenPixels((badgeFullSize.width - badgeLabelSize.width) / 2.0), y: 5.0), size: badgeLabelSize))
626617
}
627618
} else {

submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ public final class PeerStoryListContext: StoryListContext {
862862

863863
#if DEBUG
864864
if folderId != nil {
865-
signal = signal |> delay(2.0, queue: queue)
865+
//signal = signal |> delay(2.0, queue: queue)
866866
}
867867
#endif
868868

@@ -1412,21 +1412,25 @@ public final class PeerStoryListContext: StoryListContext {
14121412
switch result {
14131413
case let .storyAlbum(_, albumId, _, _, _):
14141414
var state = self.stateValue
1415-
state.availableFolders.insert(StoryListContextState.Folder(id: Int64(albumId), title: title), at: 0)
1415+
state.availableFolders.append(StoryListContextState.Folder(id: Int64(albumId), title: title))
14161416
self.stateValue = state
14171417

14181418
let peerId = self.peerId
1419-
let isArchived = self.isArchived
14201419
let items = state.items
14211420
let pinnedIds = state.pinnedIds
14221421
let totalCount = state.totalCount
1423-
let folders = state.availableFolders
14241422
let _ = (self.account.postbox.transaction { transaction -> Void in
14251423
let key = ValueBoxKey(length: 8 + 1)
14261424
key.setInt64(0, value: peerId.toInt64())
1427-
key.setInt8(8, value: isArchived ? 1 : 0)
1428-
if let entry = CodableEntry(CachedPeerStoryListHead(items: items.prefix(100).map { .item($0.storyItem.asStoryItem()) }, pinnedIds: pinnedIds, totalCount: Int32(totalCount), folders: folders)) {
1429-
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedPeerStoryListHeads, key: key), entry: entry)
1425+
key.setInt8(8, value: 0)
1426+
1427+
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedPeerStoryListHeads, key: key))?.get(CachedPeerStoryListHead.self) {
1428+
var updatedFolders: [State.Folder] = []
1429+
updatedFolders = cached.folders
1430+
updatedFolders.append(StoryListContextState.Folder(id: Int64(albumId), title: title))
1431+
if let entry = CodableEntry(CachedPeerStoryListHead(items: items.prefix(100).map { .item($0.storyItem.asStoryItem()) }, pinnedIds: pinnedIds, totalCount: Int32(totalCount), folders: updatedFolders)) {
1432+
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedPeerStoryListHeads, key: key), entry: entry)
1433+
}
14301434
}
14311435

14321436
let mappedItems = items.map { item in
@@ -1437,7 +1441,7 @@ public final class PeerStoryListContext: StoryListContext {
14371441
folderKey.setInt64(0, value: peerId.toInt64())
14381442
folderKey.setInt8(8, value: 0)
14391443
folderKey.setInt64(8 + 1, value: Int64(albumId))
1440-
if let entry = CodableEntry(CachedPeerStoryListHead(items: [], pinnedIds: [], totalCount: Int32(mappedItems.count), folders: [])) {
1444+
if let entry = CodableEntry(CachedPeerStoryListHead(items: mappedItems.map { .item($0) }, pinnedIds: [], totalCount: Int32(mappedItems.count), folders: [])) {
14411445
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedPeerStoryListHeads, key: folderKey), entry: entry)
14421446
}
14431447
} |> deliverOn(self.queue)).start(completed: {
@@ -2008,6 +2012,21 @@ public final class PeerStoryListContext: StoryListContext {
20082012
return (peerReference, result)
20092013
}
20102014
}
2015+
2016+
public static func cachedFolderState(peerId: EnginePeer.Id, account: Account, folderId: Int64) -> Signal<(count: Int, ids: [Int32])?, NoError> {
2017+
return account.postbox.transaction { transaction -> (count: Int, ids: [Int32])? in
2018+
let key = ValueBoxKey(length: 8 + 1 + 8)
2019+
key.setInt64(0, value: peerId.toInt64())
2020+
key.setInt8(8, value: 0)
2021+
key.setInt64(8 + 1, value: folderId)
2022+
2023+
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedPeerStoryListHeads, key: key))?.get(CachedPeerStoryListHead.self) {
2024+
return (Int(cached.totalCount), cached.items.map(\.id))
2025+
} else {
2026+
return nil
2027+
}
2028+
}
2029+
}
20112030
}
20122031

20132032
public final class SearchStoryListContext: StoryListContext {

submodules/TelegramUI/Components/BottomButtonPanelComponent/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ swift_library(
1515
"//submodules/ComponentFlow",
1616
"//submodules/TelegramPresentationData",
1717
"//submodules/Components/ComponentDisplayAdapters",
18-
"//submodules/Components/SolidRoundedButtonComponent",
18+
"//submodules/Components/MultilineTextComponent",
19+
"//submodules/TelegramUI/Components/ButtonComponent",
1920
],
2021
visibility = [
2122
"//visibility:public",

0 commit comments

Comments
 (0)