mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Various fixes
This commit is contained in:
@@ -35,7 +35,7 @@ extension DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
formatter.calendar = Calendar.utc
|
||||
formatter.dateFormat = format
|
||||
formatter.timeZone = TimeZone.utc
|
||||
formatter.timeZone = .current
|
||||
return formatter
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func messageContentToUpload(accountPeerId: PeerId, network: Network, postbox: Po
|
||||
return messageContentToUpload(accountPeerId: accountPeerId, network: network, postbox: postbox, auxiliaryMethods: auxiliaryMethods, transformOutgoingMessageMedia: transformOutgoingMessageMedia, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: revalidationContext, forceReupload: forceReupload, isGrouped: isGrouped, passFetchProgress: passFetchProgress, forceNoBigParts: false, peerId: message.id.peerId, messageId: message.id, attributes: message.attributes, text: message.text, media: message.media)
|
||||
}
|
||||
|
||||
func messageContentToUpload(accountPeerId: PeerId, network: Network, postbox: Postbox, auxiliaryMethods: AccountAuxiliaryMethods, transformOutgoingMessageMedia: TransformOutgoingMessageMedia?, messageMediaPreuploadManager: MessageMediaPreuploadManager, revalidationContext: MediaReferenceRevalidationContext, forceReupload: Bool, isGrouped: Bool, passFetchProgress: Bool, forceNoBigParts: Bool, peerId: PeerId, messageId: MessageId?, attributes: [MessageAttribute], text: String, media: [Media]) -> MessageContentToUpload {
|
||||
func messageContentToUpload(accountPeerId: PeerId, network: Network, postbox: Postbox, auxiliaryMethods: AccountAuxiliaryMethods, transformOutgoingMessageMedia: TransformOutgoingMessageMedia?, messageMediaPreuploadManager: MessageMediaPreuploadManager, revalidationContext: MediaReferenceRevalidationContext, forceReupload: Bool, isGrouped: Bool, passFetchProgress: Bool, forceNoBigParts: Bool, peerId: PeerId, messageId: MessageId?, attributes: [MessageAttribute], text: String, media: [Media], mediaReference: AnyMediaReference? = nil) -> MessageContentToUpload {
|
||||
var contextResult: OutgoingChatContextResultMessageAttribute?
|
||||
var autoremoveMessageAttribute: AutoremoveTimeoutMessageAttribute?
|
||||
var autoclearMessageAttribute: AutoclearTimeoutMessageAttribute?
|
||||
@@ -110,14 +110,14 @@ func messageContentToUpload(accountPeerId: PeerId, network: Network, postbox: Po
|
||||
return .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaWebPage(flags: flags, url: content.url), text), reuploadInfo: nil, cacheReferenceKey: nil))
|
||||
}
|
||||
|> castError(PendingMessageUploadError.self), .text)
|
||||
} else if let media = media.first, let mediaResult = mediaContentToUpload(accountPeerId: accountPeerId, network: network, postbox: postbox, auxiliaryMethods: auxiliaryMethods, transformOutgoingMessageMedia: transformOutgoingMessageMedia, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: revalidationContext, forceReupload: forceReupload, isGrouped: isGrouped, passFetchProgress: passFetchProgress, forceNoBigParts: forceNoBigParts, peerId: peerId, media: media, text: text, autoremoveMessageAttribute: autoremoveMessageAttribute, autoclearMessageAttribute: autoclearMessageAttribute, messageId: messageId, attributes: attributes) {
|
||||
} else if let media = media.first, let mediaResult = mediaContentToUpload(accountPeerId: accountPeerId, network: network, postbox: postbox, auxiliaryMethods: auxiliaryMethods, transformOutgoingMessageMedia: transformOutgoingMessageMedia, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: revalidationContext, forceReupload: forceReupload, isGrouped: isGrouped, passFetchProgress: passFetchProgress, forceNoBigParts: forceNoBigParts, peerId: peerId, media: media, text: text, autoremoveMessageAttribute: autoremoveMessageAttribute, autoclearMessageAttribute: autoclearMessageAttribute, messageId: messageId, attributes: attributes, mediaReference: mediaReference) {
|
||||
return .signal(mediaResult, .media)
|
||||
} else {
|
||||
return .signal(.single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .text(text), reuploadInfo: nil, cacheReferenceKey: nil))), .text)
|
||||
}
|
||||
}
|
||||
|
||||
func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Postbox, auxiliaryMethods: AccountAuxiliaryMethods, transformOutgoingMessageMedia: TransformOutgoingMessageMedia?, messageMediaPreuploadManager: MessageMediaPreuploadManager, revalidationContext: MediaReferenceRevalidationContext, forceReupload: Bool, isGrouped: Bool, passFetchProgress: Bool, forceNoBigParts: Bool, peerId: PeerId, media: Media, text: String, autoremoveMessageAttribute: AutoremoveTimeoutMessageAttribute?, autoclearMessageAttribute: AutoclearTimeoutMessageAttribute?, messageId: MessageId?, attributes: [MessageAttribute]) -> Signal<PendingMessageUploadedContentResult, PendingMessageUploadError>? {
|
||||
func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Postbox, auxiliaryMethods: AccountAuxiliaryMethods, transformOutgoingMessageMedia: TransformOutgoingMessageMedia?, messageMediaPreuploadManager: MessageMediaPreuploadManager, revalidationContext: MediaReferenceRevalidationContext, forceReupload: Bool, isGrouped: Bool, passFetchProgress: Bool, forceNoBigParts: Bool, peerId: PeerId, media: Media, text: String, autoremoveMessageAttribute: AutoremoveTimeoutMessageAttribute?, autoclearMessageAttribute: AutoclearTimeoutMessageAttribute?, messageId: MessageId?, attributes: [MessageAttribute], mediaReference: AnyMediaReference?) -> Signal<PendingMessageUploadedContentResult, PendingMessageUploadError>? {
|
||||
if let image = media as? TelegramMediaImage, let largest = largestImageRepresentation(image.representations) {
|
||||
if peerId.namespace == Namespaces.Peer.SecretChat, let resource = largest.resource as? SecretFileMediaResource {
|
||||
return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .secretMedia(.inputEncryptedFile(id: resource.fileId, accessHash: resource.accessHash), resource.decryptedSize, resource.key), reuploadInfo: nil, cacheReferenceKey: nil)))
|
||||
@@ -140,13 +140,15 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post
|
||||
return uploadedMediaFileContent(network: network, postbox: postbox, auxiliaryMethods: auxiliaryMethods, transformOutgoingMessageMedia: transformOutgoingMessageMedia, messageMediaPreuploadManager: messageMediaPreuploadManager, forceReupload: true, isGrouped: isGrouped, passFetchProgress: false, forceNoBigParts: false, peerId: peerId, messageId: messageId, text: text, attributes: attributes, autoremoveMessageAttribute: autoremoveMessageAttribute, autoclearMessageAttribute: autoclearMessageAttribute, file: file)
|
||||
} else {
|
||||
if forceReupload {
|
||||
let mediaReference: AnyMediaReference
|
||||
if file.isSticker {
|
||||
mediaReference = .standalone(media: file)
|
||||
let finalMediaReference: AnyMediaReference
|
||||
if let mediaReference = mediaReference {
|
||||
finalMediaReference = mediaReference
|
||||
} else if file.isSticker {
|
||||
finalMediaReference = .standalone(media: file)
|
||||
} else {
|
||||
mediaReference = .savedGif(media: file)
|
||||
finalMediaReference = .savedGif(media: file)
|
||||
}
|
||||
return revalidateMediaResourceReference(accountPeerId: accountPeerId, postbox: postbox, network: network, revalidationContext: revalidationContext, info: TelegramCloudMediaResourceFetchInfo(reference: mediaReference.resourceReference(file.resource), preferBackgroundReferenceRevalidation: false, continueInBackground: false), resource: resource)
|
||||
return revalidateMediaResourceReference(accountPeerId: accountPeerId, postbox: postbox, network: network, revalidationContext: revalidationContext, info: TelegramCloudMediaResourceFetchInfo(reference: finalMediaReference.resourceReference(file.resource), preferBackgroundReferenceRevalidation: false, continueInBackground: false), resource: resource)
|
||||
|> mapError { _ -> PendingMessageUploadError in
|
||||
return .generic
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ private func requestEditMessageInternal(accountPeerId: PeerId, postbox: Postbox,
|
||||
if let webpagePreviewAttribute = webpagePreviewAttribute {
|
||||
attributes.append(webpagePreviewAttribute)
|
||||
}
|
||||
return mediaContentToUpload(accountPeerId: accountPeerId, network: network, postbox: postbox, auxiliaryMethods: stateManager.auxiliaryMethods, transformOutgoingMessageMedia: transformOutgoingMessageMedia, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: mediaReferenceRevalidationContext, forceReupload: forceReupload, isGrouped: false, passFetchProgress: false, forceNoBigParts: false, peerId: messageId.peerId, media: augmentedMedia, text: "", autoremoveMessageAttribute: nil, autoclearMessageAttribute: nil, messageId: nil, attributes: attributes)
|
||||
return mediaContentToUpload(accountPeerId: accountPeerId, network: network, postbox: postbox, auxiliaryMethods: stateManager.auxiliaryMethods, transformOutgoingMessageMedia: transformOutgoingMessageMedia, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: mediaReferenceRevalidationContext, forceReupload: forceReupload, isGrouped: false, passFetchProgress: false, forceNoBigParts: false, peerId: messageId.peerId, media: augmentedMedia, text: "", autoremoveMessageAttribute: nil, autoclearMessageAttribute: nil, messageId: nil, attributes: attributes, mediaReference: nil)
|
||||
}
|
||||
if let uploadSignal = generateUploadSignal(forceReupload) {
|
||||
uploadedMedia = .single(.progress(0.027))
|
||||
|
||||
@@ -43,17 +43,14 @@ public extension Stories {
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case peerId = "peerId"
|
||||
case storyId = "storyId"
|
||||
case isForwardingDisabled = "isForwardingDisabled"
|
||||
}
|
||||
|
||||
public let peerId: EnginePeer.Id
|
||||
public let storyId: Int32
|
||||
public let isForwardingDisabled: Bool
|
||||
|
||||
public init(peerId: EnginePeer.Id, storyId: Int32, isForwardingDisabled: Bool) {
|
||||
public init(peerId: EnginePeer.Id, storyId: Int32) {
|
||||
self.peerId = peerId
|
||||
self.storyId = storyId
|
||||
self.isForwardingDisabled = isForwardingDisabled
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
@@ -61,7 +58,6 @@ public extension Stories {
|
||||
|
||||
self.peerId = EnginePeer.Id(try container.decode(Int64.self, forKey: .peerId))
|
||||
self.storyId = try container.decode(Int32.self, forKey: .storyId)
|
||||
self.isForwardingDisabled = try container.decode(Bool.self, forKey: .isForwardingDisabled)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@@ -69,7 +65,6 @@ public extension Stories {
|
||||
|
||||
try container.encode(self.peerId.toInt64(), forKey: .peerId)
|
||||
try container.encode(self.storyId, forKey: .storyId)
|
||||
try container.encode(self.isForwardingDisabled, forKey: .isForwardingDisabled)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -839,7 +839,7 @@ private func prepareUploadStoryContent(account: Account, media: EngineStoryInput
|
||||
}
|
||||
}
|
||||
|
||||
private func uploadedStoryContent(postbox: Postbox, network: Network, media: Media, embeddedStickers: [TelegramMediaFile], accountPeerId: PeerId, messageMediaPreuploadManager: MessageMediaPreuploadManager, revalidationContext: MediaReferenceRevalidationContext, auxiliaryMethods: AccountAuxiliaryMethods, passFetchProgress: Bool) -> (signal: Signal<PendingMessageUploadedContentResult?, NoError>, media: Media) {
|
||||
private func uploadedStoryContent(postbox: Postbox, network: Network, media: Media, mediaReference: AnyMediaReference?, embeddedStickers: [TelegramMediaFile], accountPeerId: PeerId, messageMediaPreuploadManager: MessageMediaPreuploadManager, revalidationContext: MediaReferenceRevalidationContext, auxiliaryMethods: AccountAuxiliaryMethods, passFetchProgress: Bool) -> (signal: Signal<PendingMessageUploadedContentResult?, NoError>, media: Media) {
|
||||
let originalMedia: Media = media
|
||||
let contentToUpload: MessageContentToUpload
|
||||
|
||||
@@ -864,7 +864,8 @@ private func uploadedStoryContent(postbox: Postbox, network: Network, media: Med
|
||||
messageId: nil,
|
||||
attributes: attributes,
|
||||
text: "",
|
||||
media: [media]
|
||||
media: [media],
|
||||
mediaReference: mediaReference
|
||||
)
|
||||
|
||||
let contentSignal: Signal<PendingMessageUploadedContentResult, PendingMessageUploadError>
|
||||
@@ -1024,16 +1025,28 @@ func _internal_uploadStoryImpl(
|
||||
randomId: Int64,
|
||||
forwardInfo: Stories.PendingForwardInfo?
|
||||
) -> Signal<StoryUploadResult, NoError> {
|
||||
return postbox.transaction { transaction -> Api.InputPeer? in
|
||||
return transaction.getPeer(toPeerId).flatMap(apiInputPeer)
|
||||
return postbox.transaction { transaction -> (Peer, Peer?)? in
|
||||
if let peer = transaction.getPeer(toPeerId) {
|
||||
if let forwardInfo = forwardInfo {
|
||||
return (peer, transaction.getPeer(forwardInfo.peerId))
|
||||
} else {
|
||||
return (peer, nil)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|> mapToSignal { inputPeer -> Signal<StoryUploadResult, NoError> in
|
||||
guard let inputPeer = inputPeer else {
|
||||
|> mapToSignal { inputPeerAndForwardInfoPeer -> Signal<StoryUploadResult, NoError> in
|
||||
guard let (inputPeer, forwardInfoPeer) = inputPeerAndForwardInfoPeer, let inputPeer = apiInputPeer(inputPeer) else {
|
||||
return .single(.completed(nil))
|
||||
}
|
||||
|
||||
var mediaReference: AnyMediaReference?
|
||||
if let forwardInfo = forwardInfo, let forwardInfoPeer = forwardInfoPeer.flatMap(PeerReference.init) {
|
||||
mediaReference = .story(peer: forwardInfoPeer, id: forwardInfo.storyId, media: media)
|
||||
}
|
||||
|
||||
let passFetchProgress = media is TelegramMediaFile
|
||||
let (contentSignal, originalMedia) = uploadedStoryContent(postbox: postbox, network: network, media: media, embeddedStickers: embeddedStickers, accountPeerId: accountPeerId, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: revalidationContext, auxiliaryMethods: auxiliaryMethods, passFetchProgress: passFetchProgress)
|
||||
let (contentSignal, originalMedia) = uploadedStoryContent(postbox: postbox, network: network, media: media, mediaReference: mediaReference, embeddedStickers: embeddedStickers, accountPeerId: accountPeerId, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: revalidationContext, auxiliaryMethods: auxiliaryMethods, passFetchProgress: passFetchProgress)
|
||||
return contentSignal
|
||||
|> mapToSignal { result -> Signal<StoryUploadResult, NoError> in
|
||||
switch result {
|
||||
@@ -1209,7 +1222,7 @@ func _internal_editStory(account: Account, peerId: PeerId, id: Int32, media: Eng
|
||||
if case .video = media {
|
||||
passFetchProgress = true
|
||||
}
|
||||
(contentSignal, originalMedia) = uploadedStoryContent(postbox: account.postbox, network: account.network, media: prepareUploadStoryContent(account: account, media: media), embeddedStickers: media.embeddedStickers, accountPeerId: account.peerId, messageMediaPreuploadManager: account.messageMediaPreuploadManager, revalidationContext: account.mediaReferenceRevalidationContext, auxiliaryMethods: account.auxiliaryMethods, passFetchProgress: passFetchProgress)
|
||||
(contentSignal, originalMedia) = uploadedStoryContent(postbox: account.postbox, network: account.network, media: prepareUploadStoryContent(account: account, media: media), mediaReference: nil, embeddedStickers: media.embeddedStickers, accountPeerId: account.peerId, messageMediaPreuploadManager: account.messageMediaPreuploadManager, revalidationContext: account.mediaReferenceRevalidationContext, auxiliaryMethods: account.auxiliaryMethods, passFetchProgress: passFetchProgress)
|
||||
} else {
|
||||
contentSignal = .single(nil)
|
||||
originalMedia = nil
|
||||
|
||||
@@ -454,9 +454,9 @@ public func stringForStoryActivityTimestamp(strings: PresentationStrings, dateTi
|
||||
let dayDifference = timeinfo.tm_yday - timeinfoNow.tm_yday
|
||||
if dayDifference == 0 || dayDifference == -1 {
|
||||
let day: RelativeTimestampFormatDay
|
||||
if dayDifference == 0 {
|
||||
let minutes = difference / (60 * 60)
|
||||
return short ? strings.ShortTime_HoursAgo(minutes) : strings.Time_HoursAgo(minutes)
|
||||
if dayDifference == 0 || short {
|
||||
let hours = difference / (60 * 60)
|
||||
return short ? strings.ShortTime_HoursAgo(hours) : strings.Time_HoursAgo(hours)
|
||||
} else {
|
||||
day = .yesterday
|
||||
}
|
||||
|
||||
@@ -1034,7 +1034,8 @@ final class MediaEditorScreenComponent: Component {
|
||||
authorName: authorName,
|
||||
text: forwardStory.text,
|
||||
isChannel: forwardAuthor.id.isGroupOrChannel,
|
||||
isVibrant: true
|
||||
isVibrant: true,
|
||||
fillsWidth: true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -340,6 +340,9 @@ public final class MessageInputPanelComponent: Component {
|
||||
if (lhs.moreAction == nil) != (rhs.moreAction == nil) {
|
||||
return false
|
||||
}
|
||||
if (lhs.setMediaRecordingActive == nil) != (rhs.setMediaRecordingActive == nil) {
|
||||
return false
|
||||
}
|
||||
if lhs.hideKeyboard != rhs.hideKeyboard {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -10,17 +10,20 @@ public final class ForwardInfoPanelComponent: Component {
|
||||
public let text: String
|
||||
public let isChannel: Bool
|
||||
public let isVibrant: Bool
|
||||
public let fillsWidth: Bool
|
||||
|
||||
public init(
|
||||
authorName: String,
|
||||
text: String,
|
||||
isChannel: Bool,
|
||||
isVibrant: Bool
|
||||
isVibrant: Bool,
|
||||
fillsWidth: Bool
|
||||
) {
|
||||
self.authorName = authorName
|
||||
self.text = text
|
||||
self.isChannel = isChannel
|
||||
self.isVibrant = isVibrant
|
||||
self.fillsWidth = fillsWidth
|
||||
}
|
||||
|
||||
public static func ==(lhs: ForwardInfoPanelComponent, rhs: ForwardInfoPanelComponent) -> Bool {
|
||||
@@ -36,6 +39,9 @@ public final class ForwardInfoPanelComponent: Component {
|
||||
if lhs.isVibrant != rhs.isVibrant {
|
||||
return false
|
||||
}
|
||||
if lhs.fillsWidth != rhs.fillsWidth {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -80,24 +86,6 @@ public final class ForwardInfoPanelComponent: Component {
|
||||
self.component = component
|
||||
self.state = state
|
||||
|
||||
let size = CGSize(width: availableSize.width, height: 40.0)
|
||||
|
||||
let lineColor: UIColor
|
||||
if !component.isVibrant {
|
||||
// self.blurBackgroundView.update(size: size, cornerRadius: 4.0, transition: .immediate)
|
||||
self.blurBackgroundView.frame = CGRect(origin: .zero, size: size)
|
||||
self.insertSubview(self.blurBackgroundView, at: 0)
|
||||
|
||||
lineColor = UIColor.white
|
||||
} else {
|
||||
lineColor = UIColor(white: 1.0, alpha: 0.5)
|
||||
}
|
||||
|
||||
self.blockView.update(size: size, isTransparent: true, primaryColor: lineColor, secondaryColor: nil, thirdColor: nil, backgroundColor: nil, pattern: nil, animation: .None)
|
||||
self.blockView.frame = CGRect(origin: .zero, size: size)
|
||||
|
||||
|
||||
|
||||
var titleOffset: CGFloat = 0.0
|
||||
if component.isChannel {
|
||||
let iconView: UIImageView
|
||||
@@ -118,6 +106,7 @@ public final class ForwardInfoPanelComponent: Component {
|
||||
iconView.removeFromSuperview()
|
||||
}
|
||||
|
||||
let sideInset: CGFloat = 9.0
|
||||
let titleSize = self.title.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(MultilineTextComponent(
|
||||
@@ -131,7 +120,7 @@ public final class ForwardInfoPanelComponent: Component {
|
||||
environment: {},
|
||||
containerSize: CGSize(width: availableSize.width - titleOffset - 20.0, height: availableSize.height)
|
||||
)
|
||||
let titleFrame = CGRect(origin: CGPoint(x: 9.0 + titleOffset, y: 3.0), size: titleSize)
|
||||
let titleFrame = CGRect(origin: CGPoint(x: sideInset + titleOffset, y: 3.0), size: titleSize)
|
||||
if let view = self.title.view {
|
||||
if view.superview == nil {
|
||||
self.addSubview(view)
|
||||
@@ -152,7 +141,7 @@ public final class ForwardInfoPanelComponent: Component {
|
||||
environment: {},
|
||||
containerSize: CGSize(width: availableSize.width - 20.0, height: availableSize.height)
|
||||
)
|
||||
let textFrame = CGRect(origin: CGPoint(x: 9.0, y: 20.0), size: textSize)
|
||||
let textFrame = CGRect(origin: CGPoint(x: sideInset, y: 20.0), size: textSize)
|
||||
if let view = self.text.view {
|
||||
if view.superview == nil {
|
||||
self.addSubview(view)
|
||||
@@ -160,6 +149,27 @@ public final class ForwardInfoPanelComponent: Component {
|
||||
view.frame = textFrame
|
||||
}
|
||||
|
||||
let size: CGSize
|
||||
if component.fillsWidth {
|
||||
size = CGSize(width: availableSize.width, height: 40.0)
|
||||
} else {
|
||||
size = CGSize(width: max(titleFrame.maxX, textFrame.maxX) + sideInset, height: 40.0)
|
||||
}
|
||||
|
||||
let lineColor: UIColor
|
||||
if !component.isVibrant {
|
||||
// self.blurBackgroundView.update(size: size, cornerRadius: 4.0, transition: .immediate)
|
||||
self.blurBackgroundView.frame = CGRect(origin: .zero, size: size)
|
||||
self.insertSubview(self.blurBackgroundView, at: 0)
|
||||
|
||||
lineColor = UIColor.white
|
||||
} else {
|
||||
lineColor = UIColor(white: 1.0, alpha: 0.5)
|
||||
}
|
||||
|
||||
self.blockView.update(size: size, isTransparent: true, primaryColor: lineColor, secondaryColor: nil, thirdColor: nil, backgroundColor: nil, pattern: nil, animation: .None)
|
||||
self.blockView.frame = CGRect(origin: .zero, size: size)
|
||||
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ final class StoryAuthorInfoComponent: Component {
|
||||
let titleColor = UIColor.white
|
||||
let subtitleColor = UIColor(white: 1.0, alpha: 0.8)
|
||||
let subtitle: NSAttributedString
|
||||
let subtitleTruncationType: CTLineTruncationType
|
||||
if let forwardInfo = component.forwardInfo {
|
||||
let authorName: String
|
||||
switch forwardInfo {
|
||||
@@ -117,6 +118,7 @@ final class StoryAuthorInfoComponent: Component {
|
||||
combinedString.append(NSAttributedString(string: authorName, font: Font.medium(11.0), textColor: titleColor))
|
||||
combinedString.append(NSAttributedString(string: " • \(timeString)", font: Font.regular(11.0), textColor: subtitleColor))
|
||||
subtitle = combinedString
|
||||
subtitleTruncationType = .middle
|
||||
} else {
|
||||
var subtitleString = stringForStoryActivityTimestamp(strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, preciseTime: true, relativeTimestamp: component.timestamp, relativeTo: timestamp)
|
||||
if component.isEdited {
|
||||
@@ -124,6 +126,7 @@ final class StoryAuthorInfoComponent: Component {
|
||||
subtitleString.append(component.strings.Story_HeaderEdited)
|
||||
}
|
||||
subtitle = NSAttributedString(string: subtitleString, font: Font.regular(11.0), textColor: subtitleColor)
|
||||
subtitleTruncationType = .end
|
||||
}
|
||||
|
||||
let titleSize = self.title.update(
|
||||
@@ -140,7 +143,7 @@ final class StoryAuthorInfoComponent: Component {
|
||||
transition: .immediate,
|
||||
component: AnyComponent(MultilineTextComponent(
|
||||
text: .plain(subtitle),
|
||||
truncationType: .end,
|
||||
truncationType: subtitleTruncationType,
|
||||
maximumNumberOfLines: 1
|
||||
)),
|
||||
environment: {},
|
||||
|
||||
@@ -113,12 +113,7 @@ public final class StoryContentContextImpl: StoryContentContext {
|
||||
if let stateView = views.views[PostboxViewKey.storiesState(key: .local)] as? StoryStatesView, let localState = stateView.value?.get(Stories.LocalState.self) {
|
||||
for item in localState.items {
|
||||
if let forwardInfo = item.forwardInfo, let peer = transaction.getPeer(forwardInfo.peerId) {
|
||||
let peer = EnginePeer(peer)
|
||||
if forwardInfo.isForwardingDisabled {
|
||||
pendingForwardsInfo[item.randomId] = .unknown(name: peer.compactDisplayTitle)
|
||||
} else {
|
||||
pendingForwardsInfo[item.randomId] = .known(peer: peer, storyId: forwardInfo.storyId)
|
||||
}
|
||||
pendingForwardsInfo[item.randomId] = .known(peer: EnginePeer(peer), storyId: forwardInfo.storyId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,7 +678,8 @@ final class StoryContentCaptionComponent: Component {
|
||||
authorName: authorName,
|
||||
text: "Story",
|
||||
isChannel: isChannel,
|
||||
isVibrant: false
|
||||
isVibrant: false,
|
||||
fillsWidth: false
|
||||
)
|
||||
),
|
||||
environment: {},
|
||||
|
||||
@@ -5222,11 +5222,12 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
|
||||
if case let .user(user) = peer {
|
||||
externalState.isPeerArchived = user.storiesHidden ?? false
|
||||
|
||||
} else if case let .channel(channel) = peer {
|
||||
externalState.isPeerArchived = channel.storiesHidden ?? false
|
||||
}
|
||||
|
||||
let forwardInfo = Stories.PendingForwardInfo(peerId: component.slice.peer.id, storyId: item.id, isForwardingDisabled: item.isForwardingDisabled)
|
||||
let forwardInfo = Stories.PendingForwardInfo(peerId: component.slice.peer.id, storyId: item.id)
|
||||
|
||||
if let rootController = context.sharedContext.mainWindow?.viewController as? TelegramRootControllerInterface {
|
||||
var existingMedia: EngineMedia?
|
||||
|
||||
@@ -1041,11 +1041,13 @@ final class StoryItemSetContainerSendMessage {
|
||||
immediateExternalShare: false,
|
||||
forceTheme: defaultDarkColorPresentationTheme
|
||||
)
|
||||
shareController.shareStory = { [weak view] in
|
||||
guard let view else {
|
||||
return
|
||||
if !component.slice.peer.isService {
|
||||
shareController.shareStory = { [weak view] in
|
||||
guard let view else {
|
||||
return
|
||||
}
|
||||
view.openStoryEditing(repost: true)
|
||||
}
|
||||
view.openStoryEditing(repost: true)
|
||||
}
|
||||
shareController.completed = { [weak view] peerIds in
|
||||
guard let view, let component = view.component else {
|
||||
|
||||
Reference in New Issue
Block a user