Skip to content

Commit faa765b

Browse files
author
Isaac
committed
Various optimizations
1 parent 1cd77c7 commit faa765b

File tree

38 files changed

+421
-125
lines changed

38 files changed

+421
-125
lines changed

‎submodules/ArchivedStickerPacksNotice/Sources/ArchivedStickerPacksNoticeController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ItemListStickerPackItem
1515

1616
private struct ArchivedStickersNoticeEntry: Comparable, Identifiable {
1717
let index: Int
18-
let info: StickerPackCollectionInfo
18+
let info: StickerPackCollectionInfo.Accessor
1919
let topItem: StickerPackItem?
2020
let count: String
2121

@@ -135,7 +135,7 @@ private final class ArchivedStickersNoticeAlertContentNode: AlertContentNode {
135135
} else {
136136
countTitle = presentationData.strings.StickerPack_StickerCount(pack.0.count)
137137
}
138-
entries.append(ArchivedStickersNoticeEntry(index: index, info: pack.0, topItem: pack.1, count: countTitle))
138+
entries.append(ArchivedStickersNoticeEntry(index: index, info: StickerPackCollectionInfo.Accessor(pack.0), topItem: pack.1, count: countTitle))
139139
index += 1
140140
}
141141

‎submodules/FeaturedStickersScreen/Sources/ChatMediaInputTrendingPane.swift

+7-6
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public final class TrendingPaneInteraction {
3030

3131
public final class TrendingPanePackEntry: Identifiable, Comparable {
3232
public let index: Int
33-
public let info: StickerPackCollectionInfo
33+
public let info: StickerPackCollectionInfo.Accessor
3434
public let theme: PresentationTheme
3535
public let strings: PresentationStrings
3636
public let topItems: [StickerPackItem]
3737
public let installed: Bool
3838
public let unread: Bool
3939
public let topSeparator: Bool
4040

41-
public init(index: Int, info: StickerPackCollectionInfo, theme: PresentationTheme, strings: PresentationStrings, topItems: [StickerPackItem], installed: Bool, unread: Bool, topSeparator: Bool) {
41+
public init(index: Int, info: StickerPackCollectionInfo.Accessor, theme: PresentationTheme, strings: PresentationStrings, topItems: [StickerPackItem], installed: Bool, unread: Bool, topSeparator: Bool) {
4242
self.index = index
4343
self.info = info
4444
self.theme = theme
@@ -88,9 +88,9 @@ public final class TrendingPanePackEntry: Identifiable, Comparable {
8888
public func item(context: AccountContext, interaction: TrendingPaneInteraction, grid: Bool) -> GridItem {
8989
let info = self.info
9090
return StickerPaneSearchGlobalItem(context: context, theme: self.theme, strings: self.strings, listAppearance: false, info: self.info, topItems: self.topItems, topSeparator: self.topSeparator, regularInsets: false, installed: self.installed, unread: self.unread, open: {
91-
interaction.openPack(info)
91+
interaction.openPack(info._parse())
9292
}, install: {
93-
interaction.installPack(info)
93+
interaction.installPack(info._parse())
9494
}, getItemIsPreviewed: { item in
9595
return interaction.getItemIsPreviewed(item)
9696
}, itemContext: interaction.itemContext)
@@ -272,16 +272,17 @@ public final class ChatMediaInputTrendingPane: ChatMediaInputPane {
272272
if installed {
273273
return .complete()
274274
} else {
275+
let parsedInfo = info._parse()
275276
return preloadedStickerPackThumbnail(account: context.account, info: info, items: items)
276277
|> filter { $0 }
277278
|> ignoreValues
278279
|> then(
279-
context.engine.stickers.addStickerPackInteractively(info: info, items: items)
280+
context.engine.stickers.addStickerPackInteractively(info: parsedInfo, items: items)
280281
|> ignoreValues
281282
)
282283
|> mapToSignal { _ -> Signal<(StickerPackCollectionInfo, [StickerPackItem]), NoError> in
283284
}
284-
|> then(.single((info, items)))
285+
|> then(.single((parsedInfo, items)))
285286
}
286287
case .fetching:
287288
break

‎submodules/FeaturedStickersScreen/Sources/FeaturedStickersScreen.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private final class FeaturedInteraction {
3535

3636
private final class FeaturedPackEntry: Identifiable, Comparable {
3737
let index: Int
38-
let info: StickerPackCollectionInfo
38+
let info: StickerPackCollectionInfo.Accessor
3939
let theme: PresentationTheme
4040
let strings: PresentationStrings
4141
let topItems: [StickerPackItem]
@@ -44,7 +44,7 @@ private final class FeaturedPackEntry: Identifiable, Comparable {
4444
let topSeparator: Bool
4545
let regularInsets: Bool
4646

47-
init(index: Int, info: StickerPackCollectionInfo, theme: PresentationTheme, strings: PresentationStrings, topItems: [StickerPackItem], installed: Bool, unread: Bool, topSeparator: Bool, regularInsets: Bool = false) {
47+
init(index: Int, info: StickerPackCollectionInfo.Accessor, theme: PresentationTheme, strings: PresentationStrings, topItems: [StickerPackItem], installed: Bool, unread: Bool, topSeparator: Bool, regularInsets: Bool = false) {
4848
self.index = index
4949
self.info = info
5050
self.theme = theme
@@ -98,9 +98,9 @@ private final class FeaturedPackEntry: Identifiable, Comparable {
9898
func item(context: AccountContext, interaction: FeaturedInteraction, isOther: Bool) -> GridItem {
9999
let info = self.info
100100
return StickerPaneSearchGlobalItem(context: context, theme: self.theme, strings: self.strings, listAppearance: true, fillsRow: false, info: self.info, topItems: self.topItems, topSeparator: self.topSeparator, regularInsets: self.regularInsets, installed: self.installed, unread: self.unread, open: {
101-
interaction.openPack(info)
101+
interaction.openPack(info._parse())
102102
}, install: {
103-
interaction.installPack(info, !self.installed)
103+
interaction.installPack(info._parse(), !self.installed)
104104
}, getItemIsPreviewed: { item in
105105
return interaction.getItemIsPreviewed(item)
106106
}, itemContext: interaction.itemContext, sectionTitle: isOther ? self.strings.FeaturedStickers_OtherSection : nil)
@@ -1041,7 +1041,7 @@ private enum FeaturedSearchEntryId: Equatable, Hashable {
10411041

10421042
private enum FeaturedSearchEntry: Identifiable, Comparable {
10431043
case sticker(index: Int, code: String?, stickerItem: FoundStickerItem, theme: PresentationTheme)
1044-
case global(index: Int, info: StickerPackCollectionInfo, topItems: [StickerPackItem], installed: Bool, topSeparator: Bool)
1044+
case global(index: Int, info: StickerPackCollectionInfo.Accessor, topItems: [StickerPackItem], installed: Bool, topSeparator: Bool)
10451045

10461046
var stableId: FeaturedSearchEntryId {
10471047
switch self {
@@ -1108,9 +1108,9 @@ private enum FeaturedSearchEntry: Identifiable, Comparable {
11081108
})
11091109
case let .global(_, info, topItems, installed, topSeparator):
11101110
return StickerPaneSearchGlobalItem(context: context, theme: theme, strings: strings, listAppearance: true, fillsRow: true, info: info, topItems: topItems, topSeparator: topSeparator, regularInsets: false, installed: installed, unread: false, open: {
1111-
interaction.open(info)
1111+
interaction.open(info._parse())
11121112
}, install: {
1113-
interaction.install(info, topItems, !installed)
1113+
interaction.install(info._parse(), topItems, !installed)
11141114
}, getItemIsPreviewed: { item in
11151115
return interaction.getItemIsPreviewed(item)
11161116
}, itemContext: itemContext)
@@ -1436,7 +1436,7 @@ private final class FeaturedPaneSearchContentNode: ASDisplayNode {
14361436
}
14371437
}
14381438
}
1439-
entries.append(.global(index: index, info: info, topItems: topItems, installed: installed, topSeparator: !isFirstGlobal))
1439+
entries.append(.global(index: index, info: StickerPackCollectionInfo.Accessor(info), topItems: topItems, installed: installed, topSeparator: !isFirstGlobal))
14401440
isFirstGlobal = false
14411441
index += 1
14421442
}

‎submodules/FeaturedStickersScreen/Sources/StickerPaneSearchGlobaltem.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public final class StickerPaneSearchGlobalItem: GridItem {
8484
public let strings: PresentationStrings
8585
public let listAppearance: Bool
8686
public let fillsRow: Bool
87-
public let info: StickerPackCollectionInfo
87+
public let info: StickerPackCollectionInfo.Accessor
8888
public let topItems: [StickerPackItem]
8989
public let topSeparator: Bool
9090
public let regularInsets: Bool
@@ -111,7 +111,7 @@ public final class StickerPaneSearchGlobalItem: GridItem {
111111
return (128.0 + additionalHeight, self.fillsRow)
112112
}
113113

114-
public init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, listAppearance: Bool, fillsRow: Bool = true, info: StickerPackCollectionInfo, topItems: [StickerPackItem], topSeparator: Bool, regularInsets: Bool, installed: Bool, installing: Bool = false, unread: Bool, open: @escaping () -> Void, install: @escaping () -> Void, getItemIsPreviewed: @escaping (StickerPackItem) -> Bool, itemContext: StickerPaneSearchGlobalItemContext, sectionTitle: String? = nil) {
114+
public init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, listAppearance: Bool, fillsRow: Bool = true, info: StickerPackCollectionInfo.Accessor, topItems: [StickerPackItem], topSeparator: Bool, regularInsets: Bool, installed: Bool, installing: Bool = false, unread: Bool, open: @escaping () -> Void, install: @escaping () -> Void, getItemIsPreviewed: @escaping (StickerPackItem) -> Bool, itemContext: StickerPaneSearchGlobalItemContext, sectionTitle: String? = nil) {
115115
self.context = context
116116
self.theme = theme
117117
self.strings = strings

‎submodules/ItemListStickerPackItem/Sources/ItemListStickerPackItem.swift

+9-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public enum ItemListStickerPackItemControl: Equatable {
4040
public final class ItemListStickerPackItem: ListViewItem, ItemListItem {
4141
let presentationData: ItemListPresentationData
4242
let context: AccountContext
43-
let packInfo: StickerPackCollectionInfo
43+
let packInfo: StickerPackCollectionInfo.Accessor
4444
let itemCount: String
4545
let topItem: StickerPackItem?
4646
let unread: Bool
@@ -56,7 +56,7 @@ public final class ItemListStickerPackItem: ListViewItem, ItemListItem {
5656
let removePack: () -> Void
5757
let toggleSelected: () -> Void
5858

59-
public init(presentationData: ItemListPresentationData, context: AccountContext, packInfo: StickerPackCollectionInfo, itemCount: String, topItem: StickerPackItem?, unread: Bool, control: ItemListStickerPackItemControl, editing: ItemListStickerPackItemEditing, enabled: Bool, playAnimatedStickers: Bool, style: ItemListStyle = .blocks, sectionId: ItemListSectionId, action: (() -> Void)?, setPackIdWithRevealedOptions: @escaping (ItemCollectionId?, ItemCollectionId?) -> Void, addPack: @escaping () -> Void, removePack: @escaping () -> Void, toggleSelected: @escaping () -> Void) {
59+
public init(presentationData: ItemListPresentationData, context: AccountContext, packInfo: StickerPackCollectionInfo.Accessor, itemCount: String, topItem: StickerPackItem?, unread: Bool, control: ItemListStickerPackItemControl, editing: ItemListStickerPackItemEditing, enabled: Bool, playAnimatedStickers: Bool, style: ItemListStyle = .blocks, sectionId: ItemListSectionId, action: (() -> Void)?, setPackIdWithRevealedOptions: @escaping (ItemCollectionId?, ItemCollectionId?) -> Void, addPack: @escaping () -> Void, removePack: @escaping () -> Void, toggleSelected: @escaping () -> Void) {
6060
self.presentationData = presentationData
6161
self.context = context
6262
self.packInfo = packInfo
@@ -487,7 +487,7 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
487487

488488
var thumbnailItem: StickerPackThumbnailItem?
489489
var resourceReference: MediaResourceReference?
490-
if let thumbnail = item.packInfo.thumbnail {
490+
if item.packInfo.hasThumbnail, let thumbnail = item.packInfo._parse().thumbnail {
491491
if thumbnail.typeHint != .generic {
492492
thumbnailItem = .animated(thumbnail.resource, thumbnail.dimensions, thumbnail.typeHint == .video, item.packInfo.flags.contains(.isCustomTemplateEmoji))
493493
} else {
@@ -845,7 +845,12 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
845845
var imageSize = PixelDimensions(width: 512, height: 512)
846846
var immediateThumbnailData: Data?
847847
if let data = item.packInfo.immediateThumbnailData {
848-
if item.packInfo.thumbnail?.typeHint == .video || item.topItem?.file.isVideoSticker == true {
848+
var isVideoTypeHint = false
849+
if item.packInfo.hasThumbnail, let thumbnail = item.packInfo._parse().thumbnail {
850+
isVideoTypeHint = thumbnail.typeHint == .video
851+
}
852+
853+
if isVideoTypeHint || item.topItem?.file.isVideoSticker == true {
849854
imageSize = PixelDimensions(width: 100, height: 100)
850855
}
851856
immediateThumbnailData = data

‎submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,7 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate {
17411741
if let strongSelf = self {
17421742
strongSelf.scheduledEmojiContentAnimationHint = EmojiPagerContentComponent.ContentAnimation(type: .groupInstalled(id: collectionId, scrollToGroup: true))
17431743
}
1744-
let _ = strongSelf.context.engine.stickers.addStickerPackInteractively(info: featuredEmojiPack.info, items: featuredEmojiPack.topItems).start()
1744+
let _ = strongSelf.context.engine.stickers.addStickerPackInteractively(info: featuredEmojiPack.info._parse(), items: featuredEmojiPack.topItems).start()
17451745

17461746
break
17471747
}

‎submodules/SettingsUI/Sources/Stickers/ArchivedStickerPacksController.swift

+7-5
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private enum ArchivedStickerPacksEntry: ItemListNodeEntry {
141141
case let .info(_, text):
142142
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
143143
case let .pack(_, _, _, info, topItem, count, animatedStickers, enabled, editing, selected):
144-
return ItemListStickerPackItem(presentationData: presentationData, context: arguments.context, packInfo: info, itemCount: count, topItem: topItem, unread: false, control: editing.editing ? .check(checked: selected ?? false) : .installation(installed: false), editing: editing, enabled: enabled, playAnimatedStickers: animatedStickers, sectionId: self.section, action: {
144+
return ItemListStickerPackItem(presentationData: presentationData, context: arguments.context, packInfo: StickerPackCollectionInfo.Accessor(info), itemCount: count, topItem: topItem, unread: false, control: editing.editing ? .check(checked: selected ?? false) : .installation(installed: false), editing: editing, enabled: enabled, playAnimatedStickers: animatedStickers, sectionId: self.section, action: {
145145
arguments.openStickerPack(info)
146146
}, setPackIdWithRevealedOptions: { current, previous in
147147
arguments.setPackIdWithRevealedOptions(current, previous)
@@ -323,11 +323,12 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
323323
if installed {
324324
return .complete()
325325
} else {
326-
return context.engine.stickers.addStickerPackInteractively(info: info, items: items)
326+
let parsedInfo = info._parse()
327+
return context.engine.stickers.addStickerPackInteractively(info: parsedInfo, items: items)
327328
|> ignoreValues
328329
|> mapToSignal { _ -> Signal<(StickerPackCollectionInfo, [StickerPackItem]), NoError> in
329330
}
330-
|> then(.single((info, items)))
331+
|> then(.single((parsedInfo, items)))
331332
}
332333
case .fetching:
333334
break
@@ -489,11 +490,12 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
489490
if installed {
490491
return .complete()
491492
} else {
492-
return context.engine.stickers.addStickerPackInteractively(info: info, items: items)
493+
let parsedInfo = info._parse()
494+
return context.engine.stickers.addStickerPackInteractively(info: parsedInfo, items: items)
493495
|> ignoreValues
494496
|> mapToSignal { _ -> Signal<(StickerPackCollectionInfo, [StickerPackItem]), NoError> in
495497
}
496-
|> then(.single((info, items)))
498+
|> then(.single((parsedInfo, items)))
497499
}
498500
case .fetching:
499501
break

‎submodules/SettingsUI/Sources/Stickers/FeaturedStickerPacksController.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private enum FeaturedStickerPacksEntryId: Hashable {
3434
}
3535

3636
private enum FeaturedStickerPacksEntry: ItemListNodeEntry {
37-
case pack(Int32, PresentationTheme, PresentationStrings, StickerPackCollectionInfo, Bool, StickerPackItem?, String, Bool, Bool)
37+
case pack(Int32, PresentationTheme, PresentationStrings, StickerPackCollectionInfo.Accessor, Bool, StickerPackItem?, String, Bool, Bool)
3838

3939
var section: ItemListSectionId {
4040
switch self {
@@ -103,10 +103,10 @@ private enum FeaturedStickerPacksEntry: ItemListNodeEntry {
103103
switch self {
104104
case let .pack(_, _, _, info, unread, topItem, count, playAnimatedStickers, installed):
105105
return ItemListStickerPackItem(presentationData: presentationData, context: arguments.context, packInfo: info, itemCount: count, topItem: topItem, unread: unread, control: .installation(installed: installed), editing: ItemListStickerPackItemEditing(editable: false, editing: false, revealed: false, reorderable: false, selectable: false), enabled: true, playAnimatedStickers: playAnimatedStickers, sectionId: self.section, action: {
106-
arguments.openStickerPack(info)
106+
arguments.openStickerPack(info._parse())
107107
}, setPackIdWithRevealedOptions: { _, _ in
108108
}, addPack: {
109-
arguments.addPack(info)
109+
arguments.addPack(info._parse())
110110
}, removePack: {
111111
}, toggleSelected: {
112112
})
@@ -178,7 +178,7 @@ public func featuredStickerPacksController(context: AccountContext) -> ViewContr
178178
if installed {
179179
return .complete()
180180
} else {
181-
return context.engine.stickers.addStickerPackInteractively(info: info, items: items)
181+
return context.engine.stickers.addStickerPackInteractively(info: info._parse(), items: items)
182182
}
183183
case .fetching:
184184
break

0 commit comments

Comments
 (0)