Skip to content

Commit ac65d7f

Browse files
author
Isaac
committed
Stories
1 parent 63055d7 commit ac65d7f

File tree

5 files changed

+41
-5
lines changed

5 files changed

+41
-5
lines changed

submodules/TelegramUI/Components/Chat/ChatSendStarsScreen/Sources/ChatSendStarsScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ private final class PeerComponent: Component {
489489
self.addSubview(crownIcon)
490490
}
491491

492-
if topPlace != previousComponent?.topPlace {
492+
if topPlace != previousComponent?.topPlace || previousComponent?.color != component.color {
493493
crownIcon.image = StoryLiveChatMessageComponent.generateCrownImage(place: topPlace, backgroundColor: component.color, foregroundColor: .white, borderColor: component.theme.actionSheet.opaqueItemBackgroundColor)
494494
}
495495
if let image = crownIcon.image {

submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContentLiveChatComponent.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ final class StoryContentLiveChatComponent: Component {
3434
let theme: PresentationTheme
3535
let call: PresentationGroupCall
3636
let storyPeerId: EnginePeer.Id
37+
let canManageMessagesFromPeers: Set<EnginePeer.Id>
3738
let insets: UIEdgeInsets
3839
let isEmbeddedInCamera: Bool
3940
let minPaidStars: Int?
@@ -46,6 +47,7 @@ final class StoryContentLiveChatComponent: Component {
4647
theme: PresentationTheme,
4748
call: PresentationGroupCall,
4849
storyPeerId: EnginePeer.Id,
50+
canManageMessagesFromPeers: Set<EnginePeer.Id>,
4951
insets: UIEdgeInsets,
5052
isEmbeddedInCamera: Bool,
5153
minPaidStars: Int?,
@@ -57,6 +59,7 @@ final class StoryContentLiveChatComponent: Component {
5759
self.theme = theme
5860
self.call = call
5961
self.storyPeerId = storyPeerId
62+
self.canManageMessagesFromPeers = canManageMessagesFromPeers
6063
self.insets = insets
6164
self.isEmbeddedInCamera = isEmbeddedInCamera
6265
self.minPaidStars = minPaidStars
@@ -82,6 +85,9 @@ final class StoryContentLiveChatComponent: Component {
8285
if lhs.storyPeerId != rhs.storyPeerId {
8386
return false
8487
}
88+
if lhs.canManageMessagesFromPeers != rhs.canManageMessagesFromPeers {
89+
return false
90+
}
8591
if lhs.insets != rhs.insets {
8692
return false
8793
}
@@ -452,6 +458,10 @@ final class StoryContentLiveChatComponent: Component {
452458
isMyMessage = true
453459
canDelete = true
454460
}
461+
if let author = message.author, component.canManageMessagesFromPeers.contains(author.id) {
462+
isMyMessage = true
463+
canDelete = true
464+
}
455465
var isMessageFromAdmin = false
456466
if message.isFromAdmin {
457467
isMessageFromAdmin = true

submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemContentComponent.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ final class StoryItemContentComponent: Component {
4040
let isUIHidden: Bool
4141
let preferHighQuality: Bool
4242
let isEmbeddedInCamera: Bool
43+
let canManageLiveChatMessagesFromPeers: Set<EnginePeer.Id>
4344
let activateReaction: (UIView, MessageReaction.Reaction) -> Void
4445
let controller: () -> ViewController?
4546

46-
init(context: AccountContext, strings: PresentationStrings, peer: EnginePeer, item: EngineStoryItem, availableReactions: StoryAvailableReactions?, entityFiles: [MediaId: TelegramMediaFile], audioMode: StoryContentItem.AudioMode, baseRate: Double, isVideoBuffering: Bool, isCurrent: Bool, isUIHidden: Bool, preferHighQuality: Bool, isEmbeddedInCamera: Bool, activateReaction: @escaping (UIView, MessageReaction.Reaction) -> Void, controller: @escaping () -> ViewController?) {
47+
init(context: AccountContext, strings: PresentationStrings, peer: EnginePeer, item: EngineStoryItem, availableReactions: StoryAvailableReactions?, entityFiles: [MediaId: TelegramMediaFile], audioMode: StoryContentItem.AudioMode, baseRate: Double, isVideoBuffering: Bool, isCurrent: Bool, isUIHidden: Bool, preferHighQuality: Bool, isEmbeddedInCamera: Bool, canManageLiveChatMessagesFromPeers: Set<EnginePeer.Id>, activateReaction: @escaping (UIView, MessageReaction.Reaction) -> Void, controller: @escaping () -> ViewController?) {
4748
self.context = context
4849
self.strings = strings
4950
self.peer = peer
@@ -57,6 +58,7 @@ final class StoryItemContentComponent: Component {
5758
self.isUIHidden = isUIHidden
5859
self.preferHighQuality = preferHighQuality
5960
self.isEmbeddedInCamera = isEmbeddedInCamera
61+
self.canManageLiveChatMessagesFromPeers = canManageLiveChatMessagesFromPeers
6062
self.activateReaction = activateReaction
6163
self.controller = controller
6264
}
@@ -95,6 +97,9 @@ final class StoryItemContentComponent: Component {
9597
if lhs.isEmbeddedInCamera != rhs.isEmbeddedInCamera {
9698
return false
9799
}
100+
if lhs.canManageLiveChatMessagesFromPeers != rhs.canManageLiveChatMessagesFromPeers {
101+
return false
102+
}
98103
if lhs.preferHighQuality != rhs.preferHighQuality {
99104
return false
100105
}
@@ -1013,6 +1018,7 @@ final class StoryItemContentComponent: Component {
10131018
theme: environment.theme,
10141019
call: mediaStreamCall,
10151020
storyPeerId: component.peer.id,
1021+
canManageMessagesFromPeers: component.canManageLiveChatMessagesFromPeers,
10161022
insets: environment.containerInsets,
10171023
isEmbeddedInCamera: component.isEmbeddedInCamera,
10181024
minPaidStars: minPaidStars,

submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,12 @@ public final class StoryItemSetContainerComponent: Component {
16291629
component.markAsSeen(id)
16301630
}
16311631
)
1632+
1633+
var canManageLiveChatMessagesFromPeers = Set<EnginePeer.Id>()
1634+
if let sendAsData = self.sendMessageContext.sendAsData {
1635+
canManageLiveChatMessagesFromPeers.formUnion(sendAsData.availablePeers.map(\.peer.id))
1636+
}
1637+
16321638
let _ = visibleItem.view.update(
16331639
transition: itemTransition.withUserData(StoryItemContentComponent.Hint(
16341640
synchronousLoad: index == centralIndex && itemLayout.contentScaleFraction <= 0.0001 && hintAllowSynchronousLoads
@@ -1647,6 +1653,7 @@ public final class StoryItemSetContainerComponent: Component {
16471653
isUIHidden: component.hideUI,
16481654
preferHighQuality: component.slice.additionalPeerData.preferHighQualityStories,
16491655
isEmbeddedInCamera: component.isEmbeddedInCamera,
1656+
canManageLiveChatMessagesFromPeers: canManageLiveChatMessagesFromPeers,
16501657
activateReaction: { [weak self] reactionView, reaction in
16511658
guard let self else {
16521659
return

submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,6 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) {
696696
sendPaidMessageStars = StarsAmount(value: minMessagePrice, nanos: 0)
697697
}
698698
}
699-
isAdmin = liveChatStateValue.isAdmin
700699

701700
if let currentSendAsPeer = self.currentSendAsPeer {
702701
sendAsPeer = currentSendAsPeer
@@ -705,6 +704,14 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) {
705704
return self.sendAsData?.availablePeers.first(where: { $0.peer.id == defaultSendAs })
706705
}
707706
}
707+
708+
if liveChatStateValue.isAdmin {
709+
if let sendAsPeer {
710+
isAdmin = sendAsPeer.peer.id == component.context.account.peerId
711+
} else {
712+
isAdmin = true
713+
}
714+
}
708715
}
709716
}
710717

@@ -4291,15 +4298,21 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) {
42914298
}
42924299
var sendAsPeer: SendAsPeer?
42934300
if let liveChatStateValue = itemView.liveChatState {
4294-
isAdmin = liveChatStateValue.isAdmin
4295-
42964301
if let currentSendAsPeer = self.currentSendAsPeer {
42974302
sendAsPeer = currentSendAsPeer
42984303
} else {
42994304
sendAsPeer = liveChatStateValue.defaultSendAs.flatMap { defaultSendAs in
43004305
return self.sendAsData?.availablePeers.first(where: { $0.peer.id == defaultSendAs })
43014306
}
43024307
}
4308+
4309+
if liveChatStateValue.isAdmin {
4310+
if let sendAsPeer {
4311+
isAdmin = sendAsPeer.peer.id == component.context.account.peerId
4312+
} else {
4313+
isAdmin = true
4314+
}
4315+
}
43034316
}
43044317

43054318
call.sendStars(fromId: sendAsPeer?.peer.id, isAdmin: isAdmin, amount: Int64(count), delay: delay)

0 commit comments

Comments
 (0)