Skip to content

Commit

Permalink
Merge commit '6d03d548d79a2f73f1c734cfc334af6b2e9867fa' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
laktyushin committed Sep 19, 2023
2 parents d1a8a37 + 6d03d54 commit 7c1d315
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 63 deletions.
8 changes: 8 additions & 0 deletions Telegram/Telegram-iOS/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -10048,6 +10048,8 @@ Sorry for the inconvenience.";

"Story.SendReactionAsMessage" = "Send reaction as a private message";

"StoryList.TooltipStoriesSavedToChannel_1" = "Story saved to channel's profile";
"StoryList.TooltipStoriesSavedToChannel_any" = "%d stories saved to channel's profile.";
"Story.ToastRemovedFromChannelText" = "Story removed from the channel's profile";
"Story.ToastSavedToChannelTitle" = "Story saved to the channel's profile";
"Story.ToastSavedToChannelText" = "Saved stories can be viewed by others on the channel's profile until an admin removes them.";
Expand Down Expand Up @@ -10078,3 +10080,9 @@ Sorry for the inconvenience.";
"Stats.Boosts.BoostsToLevelUp" = "Boosts to Level Up";

"MediaEditor.RemoveAudio" = "Remove Audio";

"ChannelBoost.BoostLinkCopied" = "Boost link copied to clipboard";
"ChannelBoost.BoostLinkForwardTooltip.Chat.One" = "Boost link forwarded to **%@**";
"ChannelBoost.BoostLinkForwardTooltip.TwoChats.One" = "Boost link forwarded to **%@** and **%@**";
"ChannelBoost.BoostLinkForwardTooltip.ManyChats.One" = "Boost link forwarded to **%@** and %@ others";
"ChannelBoost.BoostLinkForwardTooltip.SavedMessages.One" = "Boost link forwarded to **Saved Messages**";
13 changes: 11 additions & 2 deletions submodules/AvatarNode/Sources/AvatarNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -867,15 +867,18 @@ public final class AvatarNode: ASDisplayNode {
public var totalCount: Int
public var unseenCount: Int
public var hasUnseenCloseFriendsItems: Bool
public var progress: Float?

public init(
totalCount: Int,
unseenCount: Int,
hasUnseenCloseFriendsItems: Bool
hasUnseenCloseFriendsItems: Bool,
progress: Float? = nil
) {
self.totalCount = totalCount
self.unseenCount = unseenCount
self.hasUnseenCloseFriendsItems = hasUnseenCloseFriendsItems
self.progress = progress
}
}

Expand Down Expand Up @@ -1135,6 +1138,12 @@ public final class AvatarNode: ASDisplayNode {
storyIndicator = ComponentView()
self.storyIndicator = storyIndicator
}
var mappedProgress: AvatarStoryIndicatorComponent.Progress?
if let value = storyStats.progress {
mappedProgress = .definite(value)
} else if !self.loadingStatuses.isEmpty {
mappedProgress = .indefinite
}
let _ = storyIndicator.update(
transition: indicatorTransition,
component: AnyComponent(AvatarStoryIndicatorComponent(
Expand All @@ -1151,7 +1160,7 @@ public final class AvatarNode: ASDisplayNode {
totalCount: storyStats.totalCount,
unseenCount: storyStats.unseenCount
),
displayProgress: !self.loadingStatuses.isEmpty
progress: mappedProgress
)),
environment: {},
containerSize: indicatorSize
Expand Down
4 changes: 2 additions & 2 deletions submodules/PremiumUI/Sources/PremiumLimitScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private func generateBadgePath(rectSize: CGSize, tailPosition: CGFloat? = 0.5) -
withCenter: CGPoint(x: rect.minX + cornerRadius, y: rect.minY + cornerRadius),
radius: cornerRadius,
startAngle: .pi,
endAngle: .pi + leftArcEndAngle,
endAngle: .pi + max(0.0001, leftArcEndAngle),
clockwise: true
)

Expand Down Expand Up @@ -136,7 +136,7 @@ private func generateBadgePath(rectSize: CGSize, tailPosition: CGFloat? = 0.5) -
path.addArc(
withCenter: CGPoint(x: rect.minX + rectSize.width - cornerRadius, y: rect.minY + cornerRadius),
radius: cornerRadius,
startAngle: rightArcStartAngle,
startAngle: min(-0.0001, rightArcStartAngle),
endAngle: 0.0,
clockwise: true
)
Expand Down
11 changes: 9 additions & 2 deletions submodules/SSignalKit/SwiftSignalKit/Source/Signal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public func |> <T, U>(value: T, function: ((T) -> U)) -> U {
}

private final class SubscriberDisposable<T, E>: Disposable, CustomStringConvertible {
private let subscriber: Subscriber<T, E>
#if DEBUG
private weak var subscriber: Subscriber<T, E>?
#else
private var subscriber: Subscriber<T, E>?
#endif

private var lock = pthread_mutex_t()
private var disposable: Disposable?
Expand All @@ -41,15 +45,18 @@ private final class SubscriberDisposable<T, E>: Disposable, CustomStringConverti
}

func dispose() {
self.subscriber.markTerminatedWithoutDisposal()
var subscriber: Subscriber<T, E>?

var disposeItem: Disposable?
pthread_mutex_lock(&self.lock)
disposeItem = self.disposable
subscriber = self.subscriber
self.subscriber = nil
self.disposable = nil
pthread_mutex_unlock(&self.lock)

disposeItem?.dispose()
subscriber?.markTerminatedWithoutDisposal()
}

public var description: String {
Expand Down
27 changes: 18 additions & 9 deletions submodules/SSignalKit/SwiftSignalKit/Source/Signal_Timing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import Foundation
public func delay<T, E>(_ timeout: Double, queue: Queue) -> (_ signal: Signal<T, E>) -> Signal<T, E> {
return { signal in
return Signal<T, E> { subscriber in
let disposable = MetaDisposable()
let timerDisposable = MetaDisposable()
let runDisposable = MetaDisposable()
queue.async {
let timer = Timer(timeout: timeout, repeat: false, completion: {
disposable.set(signal.start(next: { next in
runDisposable.set(signal.start(next: { next in
subscriber.putNext(next)
}, error: { error in
subscriber.putError(error)
Expand All @@ -15,38 +16,43 @@ public func delay<T, E>(_ timeout: Double, queue: Queue) -> (_ signal: Signal<T,
}))
}, queue: queue)

disposable.set(ActionDisposable {
timerDisposable.set(ActionDisposable {
queue.async {
timer.invalidate()
}
})

timer.start()
}
return disposable
return ActionDisposable {
timerDisposable.dispose()
runDisposable.dispose()
}
}
}
}

public func suspendAwareDelay<T, E>(_ timeout: Double, granularity: Double = 4.0, queue: Queue) -> (_ signal: Signal<T, E>) -> Signal<T, E> {
return { signal in
return Signal<T, E> { subscriber in
let disposable = MetaDisposable()
let timerDisposable = MetaDisposable()
let runDisposable = MetaDisposable()

queue.async {
let beginTimestamp = CFAbsoluteTimeGetCurrent()

let startFinalTimer: () -> Void = {
let finalTimeout = beginTimestamp + timeout - CFAbsoluteTimeGetCurrent()
let timer = Timer(timeout: max(0.0, finalTimeout), repeat: false, completion: {
disposable.set(signal.start(next: { next in
runDisposable.set(signal.start(next: { next in
subscriber.putNext(next)
}, error: { error in
subscriber.putError(error)
}, completed: {
subscriber.putCompletion()
}))
}, queue: queue)
disposable.set(ActionDisposable {
timerDisposable.set(ActionDisposable {
queue.async {
timer.invalidate()
}
Expand All @@ -72,14 +78,17 @@ public func suspendAwareDelay<T, E>(_ timeout: Double, granularity: Double = 4.0
}
}

disposable.set(ActionDisposable {
timerDisposable.set(ActionDisposable {
invalidateImpl?()
})

timer.start()
}
}
return disposable
return ActionDisposable {
timerDisposable.dispose()
runDisposable.dispose()
}
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions submodules/StatisticsUI/Sources/ChannelStatsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ public func channelStatsController(context: AccountContext, updatedPresentationD
UIPasteboard.general.string = "https://\(link)"

let presentationData = context.sharedContext.currentPresentationData.with { $0 }
presentImpl?(UndoOverlayController(presentationData: presentationData, content: .linkCopied(text: presentationData.strings.InviteLink_InviteLinkCopiedText), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }))
presentImpl?(UndoOverlayController(presentationData: presentationData, content: .linkCopied(text: presentationData.strings.ChannelBoost_BoostLinkCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }))
}, shareBoostLink: { link in
let link = "https://\(link)"

Expand All @@ -756,19 +756,19 @@ public func channelStatsController(context: AccountContext, updatedPresentationD
let text: String
var savedMessages = false
if peerIds.count == 1, let peerId = peerIds.first, peerId == context.account.peerId {
text = presentationData.strings.InviteLink_InviteLinkForwardTooltip_SavedMessages_One
text = presentationData.strings.ChannelBoost_BoostLinkForwardTooltip_SavedMessages_One
savedMessages = true
} else {
if peers.count == 1, let peer = peers.first {
let peerName = peer.id == context.account.peerId ? presentationData.strings.DialogList_SavedMessages : peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
text = presentationData.strings.InviteLink_InviteLinkForwardTooltip_Chat_One(peerName).string
text = presentationData.strings.ChannelBoost_BoostLinkForwardTooltip_Chat_One(peerName).string
} else if peers.count == 2, let firstPeer = peers.first, let secondPeer = peers.last {
let firstPeerName = firstPeer.id == context.account.peerId ? presentationData.strings.DialogList_SavedMessages : firstPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
let secondPeerName = secondPeer.id == context.account.peerId ? presentationData.strings.DialogList_SavedMessages : secondPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
text = presentationData.strings.InviteLink_InviteLinkForwardTooltip_TwoChats_One(firstPeerName, secondPeerName).string
text = presentationData.strings.ChannelBoost_BoostLinkForwardTooltip_TwoChats_One(firstPeerName, secondPeerName).string
} else if let peer = peers.first {
let peerName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
text = presentationData.strings.InviteLink_InviteLinkForwardTooltip_ManyChats_One(peerName, "\(peers.count - 1)").string
text = presentationData.strings.ChannelBoost_BoostLinkForwardTooltip_ManyChats_One(peerName, "\(peers.count - 1)").string
} else {
text = ""
}
Expand All @@ -779,7 +779,7 @@ public func channelStatsController(context: AccountContext, updatedPresentationD
}
shareController.actionCompleted = {
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
presentImpl?(UndoOverlayController(presentationData: presentationData, content: .linkCopied(text: presentationData.strings.Conversation_LinkCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }))
presentImpl?(UndoOverlayController(presentationData: presentationData, content: .linkCopied(text: presentationData.strings.ChannelBoost_BoostLinkCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }))
}
presentImpl?(shareController)
},
Expand Down
9 changes: 8 additions & 1 deletion submodules/StatisticsUI/Sources/StatsOverviewItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,14 @@ class StatsOverviewItemNode: ListViewItemNode {

bottomLeftValueLabelLayoutAndApply = makeBottomLeftValueLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: "\(stats.boosts)", font: valueFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))

bottomRightValueLabelLayoutAndApply = makeBottomRightValueLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: "\(stats.nextLevelBoosts ?? 0)", font: valueFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
let boostsLeft: Int32
if let nextLevelBoosts = stats.nextLevelBoosts {
boostsLeft = Int32(nextLevelBoosts - stats.boosts)
} else {
boostsLeft = 0
}

bottomRightValueLabelLayoutAndApply = makeBottomRightValueLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: "\(boostsLeft)", font: valueFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))

topLeftTitleLabelLayoutAndApply = makeTopLeftTitleLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.presentationData.strings.Stats_Boosts_Level, font: titleFont, textColor: item.presentationData.theme.list.sectionHeaderTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2724,6 +2724,34 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
}
destinationView.isHidden = true

if let destinationTransitionView {
destinationTransitionView.layer.anchorPoint = CGPoint(x: 0.0, y: 0.5)
let snapshotScale = self.previewContainerView.bounds.width / destinationTransitionView.frame.width
destinationTransitionView.center = CGPoint(x: 0.0, y: self.previewContainerView.bounds.height / 2.0)
destinationTransitionView.layer.transform = CATransform3DMakeScale(snapshotScale, snapshotScale, 1.0)

destinationTransitionView.alpha = 0.0
Queue.mainQueue().after(0.15) {
destinationTransitionView.alpha = 1.0
destinationTransitionView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25)
}

self.previewContainerView.addSubview(destinationTransitionView)
destinationSnapshotView = destinationTransitionView
}
} else if let destinationNode = destinationView.asyncdisplaykit_node as? AvatarNode.ContentNode {
let destinationTransitionView: UIView?
if let image = destinationNode.unroundedImage {
destinationTransitionView = UIImageView(image: image)
destinationTransitionView?.bounds = destinationNode.bounds
destinationTransitionView?.layer.cornerRadius = destinationNode.bounds.width / 2.0
} else if let snapshotView = destinationView.snapshotView(afterScreenUpdates: false) {
destinationTransitionView = snapshotView
} else {
destinationTransitionView = nil
}
destinationView.isHidden = true

if let destinationTransitionView {
destinationTransitionView.layer.anchorPoint = CGPoint(x: 0.0, y: 0.5)
let snapshotScale = self.previewContainerView.bounds.width / destinationTransitionView.frame.width
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,20 @@ final class PeerInfoStoryGridScreenComponent: Component {

let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: environment.theme)

let title: String = presentationData.strings.StoryList_TooltipStoriesSavedToProfile(Int32(paneNode.selectedIds.count))
let title: String
let text: String

if component.peerId == component.context.account.peerId {
title = presentationData.strings.StoryList_TooltipStoriesSavedToProfile(Int32(paneNode.selectedIds.count))
text = presentationData.strings.StoryList_TooltipStoriesSavedToProfileText
} else {
title = presentationData.strings.StoryList_TooltipStoriesSavedToChannel(Int32(paneNode.selectedIds.count))
text = presentationData.strings.Story_ToastSavedToChannelText
}

environment.controller()?.present(UndoOverlayController(
presentationData: presentationData,
content: .info(title: title, text: presentationData.strings.StoryList_TooltipStoriesSavedToProfileText, timeout: nil),
content: .info(title: title, text: text, timeout: nil),
elevatedLayout: false,
animateInAsReplacement: false,
action: { _ in return false }
Expand Down
Loading

0 comments on commit 7c1d315

Please sign in to comment.