mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 06:10:03 +00:00
Stories
This commit is contained in:
parent
63055d7ba8
commit
ac65d7f443
@ -489,7 +489,7 @@ private final class PeerComponent: Component {
|
|||||||
self.addSubview(crownIcon)
|
self.addSubview(crownIcon)
|
||||||
}
|
}
|
||||||
|
|
||||||
if topPlace != previousComponent?.topPlace {
|
if topPlace != previousComponent?.topPlace || previousComponent?.color != component.color {
|
||||||
crownIcon.image = StoryLiveChatMessageComponent.generateCrownImage(place: topPlace, backgroundColor: component.color, foregroundColor: .white, borderColor: component.theme.actionSheet.opaqueItemBackgroundColor)
|
crownIcon.image = StoryLiveChatMessageComponent.generateCrownImage(place: topPlace, backgroundColor: component.color, foregroundColor: .white, borderColor: component.theme.actionSheet.opaqueItemBackgroundColor)
|
||||||
}
|
}
|
||||||
if let image = crownIcon.image {
|
if let image = crownIcon.image {
|
||||||
|
|||||||
@ -34,6 +34,7 @@ final class StoryContentLiveChatComponent: Component {
|
|||||||
let theme: PresentationTheme
|
let theme: PresentationTheme
|
||||||
let call: PresentationGroupCall
|
let call: PresentationGroupCall
|
||||||
let storyPeerId: EnginePeer.Id
|
let storyPeerId: EnginePeer.Id
|
||||||
|
let canManageMessagesFromPeers: Set<EnginePeer.Id>
|
||||||
let insets: UIEdgeInsets
|
let insets: UIEdgeInsets
|
||||||
let isEmbeddedInCamera: Bool
|
let isEmbeddedInCamera: Bool
|
||||||
let minPaidStars: Int?
|
let minPaidStars: Int?
|
||||||
@ -46,6 +47,7 @@ final class StoryContentLiveChatComponent: Component {
|
|||||||
theme: PresentationTheme,
|
theme: PresentationTheme,
|
||||||
call: PresentationGroupCall,
|
call: PresentationGroupCall,
|
||||||
storyPeerId: EnginePeer.Id,
|
storyPeerId: EnginePeer.Id,
|
||||||
|
canManageMessagesFromPeers: Set<EnginePeer.Id>,
|
||||||
insets: UIEdgeInsets,
|
insets: UIEdgeInsets,
|
||||||
isEmbeddedInCamera: Bool,
|
isEmbeddedInCamera: Bool,
|
||||||
minPaidStars: Int?,
|
minPaidStars: Int?,
|
||||||
@ -57,6 +59,7 @@ final class StoryContentLiveChatComponent: Component {
|
|||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.call = call
|
self.call = call
|
||||||
self.storyPeerId = storyPeerId
|
self.storyPeerId = storyPeerId
|
||||||
|
self.canManageMessagesFromPeers = canManageMessagesFromPeers
|
||||||
self.insets = insets
|
self.insets = insets
|
||||||
self.isEmbeddedInCamera = isEmbeddedInCamera
|
self.isEmbeddedInCamera = isEmbeddedInCamera
|
||||||
self.minPaidStars = minPaidStars
|
self.minPaidStars = minPaidStars
|
||||||
@ -82,6 +85,9 @@ final class StoryContentLiveChatComponent: Component {
|
|||||||
if lhs.storyPeerId != rhs.storyPeerId {
|
if lhs.storyPeerId != rhs.storyPeerId {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.canManageMessagesFromPeers != rhs.canManageMessagesFromPeers {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.insets != rhs.insets {
|
if lhs.insets != rhs.insets {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -452,6 +458,10 @@ final class StoryContentLiveChatComponent: Component {
|
|||||||
isMyMessage = true
|
isMyMessage = true
|
||||||
canDelete = true
|
canDelete = true
|
||||||
}
|
}
|
||||||
|
if let author = message.author, component.canManageMessagesFromPeers.contains(author.id) {
|
||||||
|
isMyMessage = true
|
||||||
|
canDelete = true
|
||||||
|
}
|
||||||
var isMessageFromAdmin = false
|
var isMessageFromAdmin = false
|
||||||
if message.isFromAdmin {
|
if message.isFromAdmin {
|
||||||
isMessageFromAdmin = true
|
isMessageFromAdmin = true
|
||||||
|
|||||||
@ -40,10 +40,11 @@ final class StoryItemContentComponent: Component {
|
|||||||
let isUIHidden: Bool
|
let isUIHidden: Bool
|
||||||
let preferHighQuality: Bool
|
let preferHighQuality: Bool
|
||||||
let isEmbeddedInCamera: Bool
|
let isEmbeddedInCamera: Bool
|
||||||
|
let canManageLiveChatMessagesFromPeers: Set<EnginePeer.Id>
|
||||||
let activateReaction: (UIView, MessageReaction.Reaction) -> Void
|
let activateReaction: (UIView, MessageReaction.Reaction) -> Void
|
||||||
let controller: () -> ViewController?
|
let controller: () -> ViewController?
|
||||||
|
|
||||||
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?) {
|
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?) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
self.peer = peer
|
self.peer = peer
|
||||||
@ -57,6 +58,7 @@ final class StoryItemContentComponent: Component {
|
|||||||
self.isUIHidden = isUIHidden
|
self.isUIHidden = isUIHidden
|
||||||
self.preferHighQuality = preferHighQuality
|
self.preferHighQuality = preferHighQuality
|
||||||
self.isEmbeddedInCamera = isEmbeddedInCamera
|
self.isEmbeddedInCamera = isEmbeddedInCamera
|
||||||
|
self.canManageLiveChatMessagesFromPeers = canManageLiveChatMessagesFromPeers
|
||||||
self.activateReaction = activateReaction
|
self.activateReaction = activateReaction
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
}
|
}
|
||||||
@ -95,6 +97,9 @@ final class StoryItemContentComponent: Component {
|
|||||||
if lhs.isEmbeddedInCamera != rhs.isEmbeddedInCamera {
|
if lhs.isEmbeddedInCamera != rhs.isEmbeddedInCamera {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.canManageLiveChatMessagesFromPeers != rhs.canManageLiveChatMessagesFromPeers {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.preferHighQuality != rhs.preferHighQuality {
|
if lhs.preferHighQuality != rhs.preferHighQuality {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -1013,6 +1018,7 @@ final class StoryItemContentComponent: Component {
|
|||||||
theme: environment.theme,
|
theme: environment.theme,
|
||||||
call: mediaStreamCall,
|
call: mediaStreamCall,
|
||||||
storyPeerId: component.peer.id,
|
storyPeerId: component.peer.id,
|
||||||
|
canManageMessagesFromPeers: component.canManageLiveChatMessagesFromPeers,
|
||||||
insets: environment.containerInsets,
|
insets: environment.containerInsets,
|
||||||
isEmbeddedInCamera: component.isEmbeddedInCamera,
|
isEmbeddedInCamera: component.isEmbeddedInCamera,
|
||||||
minPaidStars: minPaidStars,
|
minPaidStars: minPaidStars,
|
||||||
|
|||||||
@ -1629,6 +1629,12 @@ public final class StoryItemSetContainerComponent: Component {
|
|||||||
component.markAsSeen(id)
|
component.markAsSeen(id)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var canManageLiveChatMessagesFromPeers = Set<EnginePeer.Id>()
|
||||||
|
if let sendAsData = self.sendMessageContext.sendAsData {
|
||||||
|
canManageLiveChatMessagesFromPeers.formUnion(sendAsData.availablePeers.map(\.peer.id))
|
||||||
|
}
|
||||||
|
|
||||||
let _ = visibleItem.view.update(
|
let _ = visibleItem.view.update(
|
||||||
transition: itemTransition.withUserData(StoryItemContentComponent.Hint(
|
transition: itemTransition.withUserData(StoryItemContentComponent.Hint(
|
||||||
synchronousLoad: index == centralIndex && itemLayout.contentScaleFraction <= 0.0001 && hintAllowSynchronousLoads
|
synchronousLoad: index == centralIndex && itemLayout.contentScaleFraction <= 0.0001 && hintAllowSynchronousLoads
|
||||||
@ -1647,6 +1653,7 @@ public final class StoryItemSetContainerComponent: Component {
|
|||||||
isUIHidden: component.hideUI,
|
isUIHidden: component.hideUI,
|
||||||
preferHighQuality: component.slice.additionalPeerData.preferHighQualityStories,
|
preferHighQuality: component.slice.additionalPeerData.preferHighQualityStories,
|
||||||
isEmbeddedInCamera: component.isEmbeddedInCamera,
|
isEmbeddedInCamera: component.isEmbeddedInCamera,
|
||||||
|
canManageLiveChatMessagesFromPeers: canManageLiveChatMessagesFromPeers,
|
||||||
activateReaction: { [weak self] reactionView, reaction in
|
activateReaction: { [weak self] reactionView, reaction in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
|
|||||||
@ -696,7 +696,6 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) {
|
|||||||
sendPaidMessageStars = StarsAmount(value: minMessagePrice, nanos: 0)
|
sendPaidMessageStars = StarsAmount(value: minMessagePrice, nanos: 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isAdmin = liveChatStateValue.isAdmin
|
|
||||||
|
|
||||||
if let currentSendAsPeer = self.currentSendAsPeer {
|
if let currentSendAsPeer = self.currentSendAsPeer {
|
||||||
sendAsPeer = currentSendAsPeer
|
sendAsPeer = currentSendAsPeer
|
||||||
@ -705,6 +704,14 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) {
|
|||||||
return self.sendAsData?.availablePeers.first(where: { $0.peer.id == defaultSendAs })
|
return self.sendAsData?.availablePeers.first(where: { $0.peer.id == defaultSendAs })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if liveChatStateValue.isAdmin {
|
||||||
|
if let sendAsPeer {
|
||||||
|
isAdmin = sendAsPeer.peer.id == component.context.account.peerId
|
||||||
|
} else {
|
||||||
|
isAdmin = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4291,8 +4298,6 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) {
|
|||||||
}
|
}
|
||||||
var sendAsPeer: SendAsPeer?
|
var sendAsPeer: SendAsPeer?
|
||||||
if let liveChatStateValue = itemView.liveChatState {
|
if let liveChatStateValue = itemView.liveChatState {
|
||||||
isAdmin = liveChatStateValue.isAdmin
|
|
||||||
|
|
||||||
if let currentSendAsPeer = self.currentSendAsPeer {
|
if let currentSendAsPeer = self.currentSendAsPeer {
|
||||||
sendAsPeer = currentSendAsPeer
|
sendAsPeer = currentSendAsPeer
|
||||||
} else {
|
} else {
|
||||||
@ -4300,6 +4305,14 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) {
|
|||||||
return self.sendAsData?.availablePeers.first(where: { $0.peer.id == defaultSendAs })
|
return self.sendAsData?.availablePeers.first(where: { $0.peer.id == defaultSendAs })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if liveChatStateValue.isAdmin {
|
||||||
|
if let sendAsPeer {
|
||||||
|
isAdmin = sendAsPeer.peer.id == component.context.account.peerId
|
||||||
|
} else {
|
||||||
|
isAdmin = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
call.sendStars(fromId: sendAsPeer?.peer.id, isAdmin: isAdmin, amount: Int64(count), delay: delay)
|
call.sendStars(fromId: sendAsPeer?.peer.id, isAdmin: isAdmin, amount: Int64(count), delay: delay)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user