Skip to content

Commit e91809a

Browse files
author
Isaac
committed
Various improvements
1 parent 7377b81 commit e91809a

File tree

7 files changed

+72
-34
lines changed

7 files changed

+72
-34
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,14 +1424,13 @@ public final class PeerStoryListContext: StoryListContext {
14241424
key.setInt64(0, value: peerId.toInt64())
14251425
key.setInt8(8, value: 0)
14261426

1427-
var updatedFolders: [State.Folder] = []
14281427
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedPeerStoryListHeads, key: key))?.get(CachedPeerStoryListHead.self) {
1428+
var updatedFolders: [State.Folder] = []
14291429
updatedFolders = cached.folders
1430-
}
1431-
updatedFolders.append(StoryListContextState.Folder(id: Int64(albumId), title: title))
1432-
1433-
if let entry = CodableEntry(CachedPeerStoryListHead(items: items.prefix(100).map { .item($0.storyItem.asStoryItem()) }, pinnedIds: pinnedIds, totalCount: Int32(totalCount), folders: updatedFolders)) {
1434-
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedPeerStoryListHeads, key: key), entry: entry)
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+
}
14351434
}
14361435

14371436
let mappedItems = items.map { item in
@@ -1442,7 +1441,7 @@ public final class PeerStoryListContext: StoryListContext {
14421441
folderKey.setInt64(0, value: peerId.toInt64())
14431442
folderKey.setInt8(8, value: 0)
14441443
folderKey.setInt64(8 + 1, value: Int64(albumId))
1445-
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: [])) {
14461445
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedPeerStoryListHeads, key: folderKey), entry: entry)
14471446
}
14481447
} |> deliverOn(self.queue)).start(completed: {

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",

submodules/TelegramUI/Components/BottomButtonPanelComponent/Sources/BottomButtonPanelComponent.swift

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import AsyncDisplayKit
55
import ComponentFlow
66
import ComponentDisplayAdapters
77
import TelegramPresentationData
8-
import SolidRoundedButtonComponent
8+
import ButtonComponent
9+
import MultilineTextComponent
910

1011
public final class BottomButtonPanelComponent: Component {
1112
let theme: PresentationTheme
1213
let title: String
1314
let label: String?
15+
let icon: AnyComponentWithIdentity<Empty>?
1416
let isEnabled: Bool
1517
let insets: UIEdgeInsets
1618
let action: () -> Void
@@ -19,13 +21,15 @@ public final class BottomButtonPanelComponent: Component {
1921
theme: PresentationTheme,
2022
title: String,
2123
label: String?,
24+
icon: AnyComponentWithIdentity<Empty>? = nil,
2225
isEnabled: Bool,
2326
insets: UIEdgeInsets,
2427
action: @escaping () -> Void
2528
) {
2629
self.theme = theme
2730
self.title = title
2831
self.label = label
32+
self.icon = icon
2933
self.isEnabled = isEnabled
3034
self.insets = insets
3135
self.action = action
@@ -41,6 +45,9 @@ public final class BottomButtonPanelComponent: Component {
4145
if lhs.label != rhs.label {
4246
return false
4347
}
48+
if lhs.icon != rhs.icon {
49+
return false
50+
}
4451
if lhs.isEnabled != rhs.isEnabled {
4552
return false
4653
}
@@ -98,25 +105,39 @@ public final class BottomButtonPanelComponent: Component {
98105

99106
transition.setFrame(layer: self.separatorLayer, frame: CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: availableSize.width, height: UIScreenPixel)))
100107

108+
var buttonTitleVStack: [AnyComponentWithIdentity<Empty>] = []
109+
110+
let titleString = NSMutableAttributedString(string: component.title, font: Font.semibold(17.0), textColor: component.theme.list.itemCheckColors.foregroundColor, paragraphAlignment: .center)
111+
buttonTitleVStack.append(AnyComponentWithIdentity(id: AnyHashable(0), component: AnyComponent(MultilineTextComponent(text: .plain(titleString)))))
112+
113+
if let label = component.label {
114+
let labelString = NSMutableAttributedString(string: label, font: Font.semibold(11.0), textColor: component.theme.list.itemCheckColors.foregroundColor.withAlphaComponent(0.7), paragraphAlignment: .center)
115+
buttonTitleVStack.append(AnyComponentWithIdentity(id: AnyHashable(1), component: AnyComponent(MultilineTextComponent(text: .plain(labelString)))))
116+
}
117+
118+
var buttonTitleContent: AnyComponent<Empty> = AnyComponent(VStack(buttonTitleVStack, spacing: 1.0))
119+
if let icon = component.icon {
120+
buttonTitleContent = AnyComponent(HStack([
121+
icon,
122+
AnyComponentWithIdentity(id: "_title", component: buttonTitleContent)
123+
], spacing: 7.0))
124+
}
125+
101126
let actionButtonSize = self.actionButton.update(
102127
transition: transition,
103-
component: AnyComponent(SolidRoundedButtonComponent(
104-
title: component.title,
105-
label: component.label,
106-
theme: SolidRoundedButtonComponent.Theme(
107-
backgroundColor: component.theme.list.itemCheckColors.fillColor,
108-
backgroundColors: [],
109-
foregroundColor: component.theme.list.itemCheckColors.foregroundColor
128+
component: AnyComponent(ButtonComponent(
129+
background: ButtonComponent.Background(
130+
color: component.theme.list.itemCheckColors.fillColor,
131+
foreground: component.theme.list.itemCheckColors.foregroundColor,
132+
pressedColor: component.theme.list.itemCheckColors.fillColor.withMultipliedAlpha(0.9),
133+
cornerRadius: 10.0
134+
),
135+
content: AnyComponentWithIdentity(
136+
id: 0,
137+
component: buttonTitleContent
110138
),
111-
font: .bold,
112-
fontSize: 17.0,
113-
height: 50.0,
114-
cornerRadius: 10.0,
115-
gloss: false,
116139
isEnabled: component.isEnabled,
117-
animationName: nil,
118-
iconPosition: .right,
119-
iconSpacing: 4.0,
140+
displaysProgress: false,
120141
action: { [weak self] in
121142
guard let self else {
122143
return

submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import TabSelectorComponent
4646
import LanguageSelectionScreen
4747
import PromptUI
4848
import BottomButtonPanelComponent
49+
import BundleIconComponent
4950

5051
private let mediaBadgeBackgroundColor = UIColor(white: 0.0, alpha: 0.6)
5152
private let mediaBadgeTextColor = UIColor.white
@@ -4483,6 +4484,11 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
44834484
theme: presentationData.theme,
44844485
title: "Add Stories",
44854486
label: nil,
4487+
icon: AnyComponentWithIdentity(id: 0, component: AnyComponent(BundleIconComponent(
4488+
name: "Item List/AddItemIcon",
4489+
tintColor: presentationData.theme.list.itemCheckColors.foregroundColor,
4490+
maxSize: CGSize(width: 18.0, height: 18.0)
4491+
))),
44864492
isEnabled: true,
44874493
insets: UIEdgeInsets(top: 0.0, left: sideInset + 12.0, bottom: bottomInset, right: sideInset + 12.0),
44884494
action: { [weak self] in
@@ -5018,14 +5024,11 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
50185024
}
50195025
if let value {
50205026
if let listSource = self.listSource as? PeerStoryListContext {
5021-
let _ = listSource.addFolder(title: value, items: [], completion: { [weak self] id in
5027+
let _ = listSource.addFolder(title: value, items: addItems, completion: { [weak self] id in
50225028
Queue.mainQueue().async {
5023-
guard let self, let id, let listSource = self.listSource as? PeerStoryListContext else {
5029+
guard let self, let id else {
50245030
return
50255031
}
5026-
if !addItems.isEmpty {
5027-
let _ = listSource.addToFolder(id: id, items: addItems)
5028-
}
50295032
self.isSwitchingToCreatedFolder = true
50305033
self.setStoryFolder(id: id, assumeEmpty: addItems.isEmpty)
50315034
}
@@ -5386,7 +5389,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
53865389

53875390
let shareController = ShareController(
53885391
context: self.context,
5389-
subject: .url("https://t.me/\(urlBase)?stories=\(id)"),
5392+
subject: .url("https://t.me/\(urlBase)/a/\(id)"),
53905393
presetText: nil,
53915394
preferredAction: .default,
53925395
showInChat: nil,

submodules/TelegramUI/Sources/OpenUrl.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
755755
var text: String?
756756
var profile: Bool = false
757757
var referrer: String?
758+
var albumId: Int64?
758759
if let queryItems = components.queryItems {
759760
for queryItem in queryItems {
760761
if let value = queryItem.value {
@@ -790,6 +791,8 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
790791
text = value
791792
} else if queryItem.name == "ref" {
792793
referrer = value
794+
} else if queryItem.name == "album" {
795+
albumId = Int64(value)
793796
}
794797
} else if ["voicechat", "videochat", "livestream"].contains(queryItem.name) {
795798
voiceChat = ""
@@ -861,6 +864,8 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
861864
}
862865
} else if let attach = attach {
863866
result += "?attach=\(attach)"
867+
} else if let albumId {
868+
result += "/a/\(albumId)"
864869
}
865870
if let startAttach = startAttach {
866871
if attach == nil {

submodules/TelegramUI/Sources/SharedAccountContext.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3992,6 +3992,9 @@ private func peerInfoControllerImpl(context: AccountContext, updatedPresentation
39923992
sharedMediaFromForumTopic = (peerId, peer.id.toInt64())
39933993
case let .storyAlbum(id):
39943994
switchToStoryFolder = id
3995+
if peer.id == context.account.peerId {
3996+
isMyProfile = true
3997+
}
39953998
default:
39963999
break
39974000
}

submodules/UrlHandling/Sources/UrlHandling.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,12 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, context: Accou
344344
if let id = Int32(value) {
345345
return .peer(.name(peerName), .story(id))
346346
}
347+
} else if queryItem.name == "album" {
348+
if let id = Int64(value) {
349+
return .peer(.name(peerName), .storyFolder(id))
350+
}
347351
} else if queryItem.name == "ref", let referrer = queryItem.value {
348352
return .peer(.name(peerName), .referrer(referrer))
349-
} else if queryItem.name == "stories", let value = queryItem.value, let folderId = Int64(value) {
350-
return .peer(.name(peerName), .storyFolder(folderId))
351353
}
352354
} else if ["voicechat", "videochat", "livestream"].contains(queryItem.name) {
353355
return .peer(.name(peerName), .voiceChat(nil))
@@ -404,8 +406,6 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, context: Accou
404406
return .peer(.name(peerName), .appStart("", queryItem.value, mode))
405407
} else if queryItem.name == "ref", let referrer = queryItem.value {
406408
return .peer(.name(peerName), .referrer(referrer))
407-
} else if queryItem.name == "stories", let value = queryItem.value, let folderId = Int64(value) {
408-
return .peer(.name(peerName), .storyFolder(folderId))
409409
}
410410
}
411411
}
@@ -658,6 +658,12 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, context: Accou
658658
} else {
659659
return nil
660660
}
661+
} else if pathComponents.count >= 3 && pathComponents[1] == "a" {
662+
if let folderId = Int64(pathComponents[2]) {
663+
return .peer(.name(pathComponents[0]), .storyFolder(folderId))
664+
} else {
665+
return nil
666+
}
661667
} else if let value = Int32(pathComponents[1]) {
662668
var threadId: Int32?
663669
var commentId: Int32?

0 commit comments

Comments
 (0)