mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-06-20 18:24:43 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
@@ -505,6 +505,7 @@
|
||||
"Notification.JoinedChat" = "%@ joined the group";
|
||||
"Notification.JoinedChannel" = "%@ joined the channel";
|
||||
"Notification.Invited" = "%@ invited %@";
|
||||
"Notification.InvitedMultiple" = "%@ invited %@";
|
||||
"Notification.LeftChat" = "%@ left the group";
|
||||
"Notification.LeftChannel" = "%@ left the channel";
|
||||
"Notification.Kicked" = "%@ removed %@";
|
||||
@@ -2561,6 +2562,7 @@ Unused sets are archived when you add more.";
|
||||
"Channel.AdminLog.InfoPanelTitle" = "What Is This?";
|
||||
"Channel.AdminLog.InfoPanelAlertTitle" = "What is the event log?";
|
||||
"Channel.AdminLog.InfoPanelAlertText" = "This is a list of all service actions taken by the group's members and admins in the last 48 hours.";
|
||||
"Channel.AdminLog.InfoPanelChannelAlertText" = "This is a list of all service actions taken by the channel's admins in the last 48 hours.";
|
||||
|
||||
"Channel.AdminLog.BanReadMessages" = "Read Messages";
|
||||
"Channel.AdminLog.BanSendMessages" = "Send Messages";
|
||||
@@ -5158,6 +5160,8 @@ Any member of this group will be able to see messages in the channel.";
|
||||
"AuthSessions.AddDeviceIntro.Text2" = "Run Telegram on your computer to get the QR code";
|
||||
"AuthSessions.AddDeviceIntro.Text3" = "Scan the QR code to connect your account";
|
||||
"AuthSessions.AddDeviceIntro.Action" = "Scan QR Code";
|
||||
"AuthSessions.AddedDeviceTitle" = "Loggin Successful";
|
||||
"AuthSessions.AddedDeviceTerminate" = "Terminate";
|
||||
|
||||
"Map.SendThisPlace" = "Send This Place";
|
||||
"Map.SetThisPlace" = "Set This Place";
|
||||
@@ -5230,3 +5234,8 @@ Any member of this group will be able to see messages in the channel.";
|
||||
|
||||
"Theme.ThemeChanged" = "Color Theme Changed";
|
||||
"Theme.ThemeChangedText" = "You can change it back in\n[Settings > Appearance]().";
|
||||
|
||||
"StickerPackActionInfo.AddedTitle" = "Stickers Added";
|
||||
"StickerPackActionInfo.AddedText" = "%@ has been added to your stickers.";
|
||||
"StickerPackActionInfo.RemovedTitle" = "Stickers Removed";
|
||||
"StickerPackActionInfo.RemovedText" = "%@ is no longer in your stickers.";
|
||||
|
||||
@@ -71,13 +71,24 @@ private protocol AnimatedStickerFrameSource: class {
|
||||
var frameRate: Int { get }
|
||||
var frameCount: Int { get }
|
||||
|
||||
func takeFrame() -> AnimatedStickerFrame
|
||||
func takeFrame() -> AnimatedStickerFrame?
|
||||
}
|
||||
|
||||
private final class AnimatedStickerFrameSourceWrapper {
|
||||
let value: AnimatedStickerFrameSource
|
||||
|
||||
init(_ value: AnimatedStickerFrameSource) {
|
||||
self.value = value
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 9.0, *)
|
||||
private final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource {
|
||||
private let queue: Queue
|
||||
private let data: Data
|
||||
private var data: Data
|
||||
private var dataComplete: Bool
|
||||
private let notifyUpdated: () -> Void
|
||||
|
||||
private var scratchBuffer: Data
|
||||
let width: Int
|
||||
let bytesPerRow: Int
|
||||
@@ -90,9 +101,11 @@ private final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource
|
||||
var decodeBuffer: Data
|
||||
var frameBuffer: Data
|
||||
|
||||
init?(queue: Queue, data: Data) {
|
||||
init?(queue: Queue, data: Data, complete: Bool, notifyUpdated: @escaping () -> Void) {
|
||||
self.queue = queue
|
||||
self.data = data
|
||||
self.dataComplete = complete
|
||||
self.notifyUpdated = notifyUpdated
|
||||
self.scratchBuffer = Data(count: compression_decode_scratch_buffer_size(COMPRESSION_LZFSE))
|
||||
|
||||
var offset = 0
|
||||
@@ -152,7 +165,7 @@ private final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource
|
||||
assert(self.queue.isCurrent())
|
||||
}
|
||||
|
||||
func takeFrame() -> AnimatedStickerFrame {
|
||||
func takeFrame() -> AnimatedStickerFrame? {
|
||||
var frameData: Data?
|
||||
var isLastFrame = false
|
||||
|
||||
@@ -163,8 +176,24 @@ private final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource
|
||||
let frameIndex = self.frameIndex
|
||||
|
||||
self.data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Void in
|
||||
if self.offset + 4 > dataLength {
|
||||
if self.dataComplete {
|
||||
self.frameIndex = 0
|
||||
self.offset = self.initialOffset
|
||||
self.frameBuffer.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
memset(bytes, 0, frameBufferLength)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var frameLength: Int32 = 0
|
||||
memcpy(&frameLength, bytes.advanced(by: self.offset), 4)
|
||||
|
||||
if self.offset + 4 + Int(frameLength) > dataLength {
|
||||
return
|
||||
}
|
||||
|
||||
self.offset += 4
|
||||
|
||||
self.scratchBuffer.withUnsafeMutableBytes { (scratchBytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
@@ -194,7 +223,7 @@ private final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource
|
||||
|
||||
self.frameIndex += 1
|
||||
self.offset += Int(frameLength)
|
||||
if self.offset == dataLength {
|
||||
if self.offset == dataLength && self.dataComplete {
|
||||
isLastFrame = true
|
||||
self.frameIndex = 0
|
||||
self.offset = self.initialOffset
|
||||
@@ -204,7 +233,16 @@ private final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource
|
||||
}
|
||||
}
|
||||
|
||||
return AnimatedStickerFrame(data: frameData!, type: .yuva, width: self.width, height: self.height, bytesPerRow: self.bytesPerRow, index: frameIndex, isLastFrame: isLastFrame)
|
||||
if let frameData = frameData {
|
||||
return AnimatedStickerFrame(data: frameData, type: .yuva, width: self.width, height: self.height, bytesPerRow: self.bytesPerRow, index: frameIndex, isLastFrame: isLastFrame)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func updateData(data: Data, complete: Bool) {
|
||||
self.data = data
|
||||
self.dataComplete = complete
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +279,7 @@ private final class AnimatedStickerDirectFrameSource: AnimatedStickerFrameSource
|
||||
assert(self.queue.isCurrent())
|
||||
}
|
||||
|
||||
func takeFrame() -> AnimatedStickerFrame {
|
||||
func takeFrame() -> AnimatedStickerFrame? {
|
||||
let frameIndex = self.currentFrame % self.frameCount
|
||||
self.currentFrame += 1
|
||||
var frameData = Data(count: self.bytesPerRow * self.height)
|
||||
@@ -271,15 +309,23 @@ private final class AnimatedStickerFrameQueue {
|
||||
|
||||
func take() -> AnimatedStickerFrame? {
|
||||
if self.frames.isEmpty {
|
||||
self.frames.append(self.source.takeFrame())
|
||||
if let frame = self.source.takeFrame() {
|
||||
self.frames.append(frame)
|
||||
}
|
||||
}
|
||||
if !self.frames.isEmpty {
|
||||
let frame = self.frames.removeFirst()
|
||||
return frame
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
let frame = self.frames.removeFirst()
|
||||
return frame
|
||||
}
|
||||
|
||||
func generateFramesIfNeeded() {
|
||||
if self.frames.isEmpty {
|
||||
self.frames.append(self.source.takeFrame())
|
||||
if let frame = self.source.takeFrame() {
|
||||
self.frames.append(frame)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,7 +343,7 @@ public struct AnimatedStickerStatus: Equatable {
|
||||
}
|
||||
|
||||
public protocol AnimatedStickerNodeSource {
|
||||
func cachedDataPath(width: Int, height: Int) -> Signal<String, NoError>
|
||||
func cachedDataPath(width: Int, height: Int) -> Signal<(String, Bool), NoError>
|
||||
func directDataPath() -> Signal<String, NoError>
|
||||
}
|
||||
|
||||
@@ -312,7 +358,7 @@ public final class AnimatedStickerNodeLocalFileSource: AnimatedStickerNodeSource
|
||||
return .single(self.path)
|
||||
}
|
||||
|
||||
public func cachedDataPath(width: Int, height: Int) -> Signal<String, NoError> {
|
||||
public func cachedDataPath(width: Int, height: Int) -> Signal<(String, Bool), NoError> {
|
||||
return .never()
|
||||
}
|
||||
}
|
||||
@@ -330,9 +376,10 @@ public final class AnimatedStickerNode: ASDisplayNode {
|
||||
private var reportedStarted = false
|
||||
|
||||
private let timer = Atomic<SwiftSignalKit.Timer?>(value: nil)
|
||||
private let frameSource = Atomic<QueueLocalObject<AnimatedStickerFrameSourceWrapper>?>(value: nil)
|
||||
|
||||
private var directData: (Data, String, Int, Int)?
|
||||
private var cachedData: Data?
|
||||
private var cachedData: (Data, Bool)?
|
||||
|
||||
private var renderer: (AnimationRenderer & ASDisplayNode)?
|
||||
|
||||
@@ -421,15 +468,30 @@ public final class AnimatedStickerNode: ASDisplayNode {
|
||||
}))
|
||||
case .cached:
|
||||
self.disposable.set((source.cachedDataPath(width: width, height: height)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] path in
|
||||
|> deliverOnMainQueue).start(next: { [weak self] path, complete in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.cachedData = try? Data(contentsOf: URL(fileURLWithPath: path), options: [.mappedRead])
|
||||
if strongSelf.isPlaying {
|
||||
strongSelf.play()
|
||||
} else if strongSelf.canDisplayFirstFrame {
|
||||
strongSelf.play(firstFrame: true)
|
||||
if let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: [.mappedRead]) {
|
||||
if let (_, currentComplete) = strongSelf.cachedData {
|
||||
if !currentComplete {
|
||||
strongSelf.cachedData = (data, complete)
|
||||
strongSelf.frameSource.with { frameSource in
|
||||
frameSource?.with { frameSource in
|
||||
if let frameSource = frameSource.value as? AnimatedStickerCachedFrameSource {
|
||||
frameSource.updateData(data: data, complete: complete)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
strongSelf.cachedData = (data, complete)
|
||||
if strongSelf.isPlaying {
|
||||
strongSelf.play()
|
||||
} else if strongSelf.canDisplayFirstFrame {
|
||||
strongSelf.play(firstFrame: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
@@ -464,15 +526,24 @@ public final class AnimatedStickerNode: ASDisplayNode {
|
||||
let cachedData = self.cachedData
|
||||
let queue = self.queue
|
||||
let timerHolder = self.timer
|
||||
let frameSourceHolder = self.frameSource
|
||||
self.queue.async { [weak self] in
|
||||
var maybeFrameSource: AnimatedStickerFrameSource?
|
||||
var notifyUpdated: (() -> Void)?
|
||||
if let directData = directData {
|
||||
maybeFrameSource = AnimatedStickerDirectFrameSource(queue: queue, data: directData.0, width: directData.2, height: directData.3)
|
||||
} else if let cachedData = cachedData {
|
||||
} else if let (cachedData, cachedDataComplete) = cachedData {
|
||||
if #available(iOS 9.0, *) {
|
||||
maybeFrameSource = AnimatedStickerCachedFrameSource(queue: queue, data: cachedData)
|
||||
maybeFrameSource = AnimatedStickerCachedFrameSource(queue: queue, data: cachedData, complete: cachedDataComplete, notifyUpdated: {
|
||||
notifyUpdated?()
|
||||
})
|
||||
}
|
||||
}
|
||||
let _ = frameSourceHolder.swap(maybeFrameSource.flatMap { maybeFrameSource in
|
||||
return QueueLocalObject(queue: queue, generate: {
|
||||
return AnimatedStickerFrameSourceWrapper(maybeFrameSource)
|
||||
})
|
||||
})
|
||||
guard let frameSource = maybeFrameSource else {
|
||||
return
|
||||
}
|
||||
@@ -541,9 +612,9 @@ public final class AnimatedStickerNode: ASDisplayNode {
|
||||
var maybeFrameSource: AnimatedStickerFrameSource?
|
||||
if let directData = directData {
|
||||
maybeFrameSource = AnimatedStickerDirectFrameSource(queue: queue, data: directData.0, width: directData.2, height: directData.3)
|
||||
} else if let cachedData = cachedData {
|
||||
} else if let (cachedData, cachedDataComplete) = cachedData {
|
||||
if #available(iOS 9.0, *) {
|
||||
maybeFrameSource = AnimatedStickerCachedFrameSource(queue: queue, data: cachedData)
|
||||
maybeFrameSource = AnimatedStickerCachedFrameSource(queue: queue, data: cachedData, complete: cachedDataComplete, notifyUpdated: {})
|
||||
}
|
||||
}
|
||||
guard let frameSource = maybeFrameSource else {
|
||||
|
||||
@@ -132,7 +132,8 @@ public final class AuthTransferScanScreen: ViewController {
|
||||
private func dismissWithSuccess(session: RecentAccountSession?) {
|
||||
if let navigationController = navigationController as? NavigationController {
|
||||
let activeSessionsContext = self.activeSessionsContext
|
||||
self.present(UndoOverlayController(presentationData: self.presentationData, content: .actionSucceeded(title: "Loggin Successful", text: "Telegram for macOS", cancel: "Terminate"), elevatedLayout: false, animateInAsReplacement: false, action: { value in
|
||||
|
||||
self.present(UndoOverlayController(presentationData: self.presentationData, content: .actionSucceeded(title: self.presentationData.strings.AuthSessions_AddedDeviceTitle, text: session?.appName ?? "Telegram for macOS", cancel: self.presentationData.strings.AuthSessions_AddedDeviceTerminate), elevatedLayout: false, animateInAsReplacement: false, action: { value in
|
||||
if value == .undo, let session = session {
|
||||
let _ = activeSessionsContext.remove(hash: session.hash).start()
|
||||
return true
|
||||
|
||||
@@ -254,7 +254,7 @@ final class CallListControllerNode: ASDisplayNode {
|
||||
self?.openInfo(peerId, messages)
|
||||
}, delete: { [weak self] messageIds in
|
||||
if let strongSelf = self {
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: messageIds, type: .forLocalPeer).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: messageIds, type: .forLocalPeer).start()
|
||||
}
|
||||
}, updateShowCallsTab: { [weak self] value in
|
||||
if let strongSelf = self {
|
||||
|
||||
@@ -128,8 +128,6 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
private let mode: NavigationControllerMode
|
||||
private var theme: NavigationControllerTheme
|
||||
|
||||
public private(set) weak var overlayPresentingController: ViewController?
|
||||
|
||||
var inCallNavigate: (() -> Void)?
|
||||
private var inCallStatusBar: StatusBar?
|
||||
private var globalScrollToTopNode: ScrollToTopNode?
|
||||
@@ -137,8 +135,11 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
private var rootModalFrame: NavigationModalFrame?
|
||||
private var modalContainers: [NavigationModalContainer] = []
|
||||
private var overlayContainers: [NavigationOverlayContainer] = []
|
||||
|
||||
private var globalOverlayContainers: [NavigationOverlayContainer] = []
|
||||
private var globalOverlayContainerParent: GlobalOverlayContainerParent?
|
||||
public var globalOverlayControllersUpdated: (() -> Void)?
|
||||
|
||||
private var validLayout: ContainerViewLayout?
|
||||
private var validStatusBarStyle: NavigationStatusBarStyle?
|
||||
private var validStatusBarHidden: Bool = false
|
||||
@@ -451,6 +452,8 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
|
||||
var topVisibleOverlayContainerWithStatusBar: NavigationOverlayContainer?
|
||||
|
||||
var notifyGlobalOverlayControllersUpdated = false
|
||||
|
||||
var modalStyleOverlayTransitionFactor: CGFloat = 0.0
|
||||
var previousGlobalOverlayContainer: NavigationOverlayContainer?
|
||||
for i in (0 ..< self.globalOverlayContainers.count).reversed() {
|
||||
@@ -475,6 +478,7 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
self.globalOverlayContainerParent?.addSubnode(overlayContainer)
|
||||
}
|
||||
overlayContainer.transitionIn()
|
||||
notifyGlobalOverlayControllersUpdated = true
|
||||
}
|
||||
|
||||
if overlayContainer.supernode != nil {
|
||||
@@ -920,6 +924,10 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
}
|
||||
|
||||
self.isUpdatingContainers = false
|
||||
|
||||
if notifyGlobalOverlayControllersUpdated {
|
||||
self.globalOverlayControllersUpdated?()
|
||||
}
|
||||
}
|
||||
|
||||
private func controllerRemoved(_ controller: ViewController) {
|
||||
@@ -1131,6 +1139,7 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
if overlayContainer.controller === controller {
|
||||
overlayContainer.removeFromSupernode()
|
||||
strongSelf.globalOverlayContainers.remove(at: i)
|
||||
strongSelf.globalOverlayControllersUpdated?()
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -1292,4 +1301,24 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var overlayControllers: [ViewController] {
|
||||
return self.overlayContainers.compactMap { container in
|
||||
if container.isReady {
|
||||
return container.controller
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var globalOverlayControllers: [ViewController] {
|
||||
return self.globalOverlayContainers.compactMap { container in
|
||||
if container.isReady {
|
||||
return container.controller
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,18 @@ private final class TextNodeStrikethrough {
|
||||
}
|
||||
}
|
||||
|
||||
public struct TextRangeRectEdge: Equatable {
|
||||
public var x: CGFloat
|
||||
public var y: CGFloat
|
||||
public var height: CGFloat
|
||||
|
||||
public init(x: CGFloat, y: CGFloat, height: CGFloat) {
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.height = height
|
||||
}
|
||||
}
|
||||
|
||||
private final class TextNodeLine {
|
||||
let line: CTLine
|
||||
let frame: CGRect
|
||||
@@ -589,11 +601,13 @@ public final class TextNodeLayout: NSObject {
|
||||
return nil
|
||||
}
|
||||
|
||||
public func rangeRects(in range: NSRange) -> [CGRect]? {
|
||||
public func rangeRects(in range: NSRange) -> (rects: [CGRect], start: TextRangeRectEdge, end: TextRangeRectEdge)? {
|
||||
guard let _ = self.attributedString, range.length != 0 else {
|
||||
return nil
|
||||
}
|
||||
var rects: [(CGRect, CGRect)] = []
|
||||
var startEdge: TextRangeRectEdge?
|
||||
var endEdge: TextRangeRectEdge?
|
||||
for line in self.lines {
|
||||
let lineRange = NSIntersectionRange(range, line.range)
|
||||
if lineRange.length != 0 {
|
||||
@@ -616,11 +630,34 @@ public final class TextNodeLayout: NSObject {
|
||||
|
||||
let width = max(0.0, abs(rightOffset - leftOffset))
|
||||
|
||||
if line.range.contains(range.lowerBound) {
|
||||
let offsetX = floor(CTLineGetOffsetForStringIndex(line.line, range.lowerBound, nil))
|
||||
startEdge = TextRangeRectEdge(x: lineFrame.minX + offsetX, y: lineFrame.minY, height: lineFrame.height)
|
||||
}
|
||||
if line.range.contains(range.upperBound - 1) {
|
||||
let offsetX: CGFloat
|
||||
if line.range.upperBound == range.upperBound {
|
||||
offsetX = lineFrame.maxX
|
||||
} else {
|
||||
var secondaryOffset: CGFloat = 0.0
|
||||
let primaryOffset = floor(CTLineGetOffsetForStringIndex(line.line, range.upperBound - 1, &secondaryOffset))
|
||||
secondaryOffset = floor(secondaryOffset)
|
||||
let nextOffet = floor(CTLineGetOffsetForStringIndex(line.line, range.upperBound, &secondaryOffset))
|
||||
|
||||
if primaryOffset != secondaryOffset {
|
||||
offsetX = secondaryOffset
|
||||
} else {
|
||||
offsetX = nextOffet
|
||||
}
|
||||
}
|
||||
endEdge = TextRangeRectEdge(x: lineFrame.minX + offsetX, y: lineFrame.minY, height: lineFrame.height)
|
||||
}
|
||||
|
||||
rects.append((lineFrame, CGRect(origin: CGPoint(x: lineFrame.minX + min(leftOffset, rightOffset) + self.insets.left, y: lineFrame.minY + self.insets.top), size: CGSize(width: width, height: lineFrame.size.height))))
|
||||
}
|
||||
}
|
||||
if !rects.isEmpty {
|
||||
return rects.map { $1 }
|
||||
if !rects.isEmpty, let startEdge = startEdge, let endEdge = endEdge {
|
||||
return (rects.map { $1 }, startEdge, endEdge)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -768,7 +805,7 @@ public class TextNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
public func rangeRects(in range: NSRange) -> [CGRect]? {
|
||||
public func rangeRects(in range: NSRange) -> (rects: [CGRect], start: TextRangeRectEdge, end: TextRangeRectEdge)? {
|
||||
if let cachedLayout = self.cachedLayout {
|
||||
return cachedLayout.rangeRects(in: range)
|
||||
} else {
|
||||
|
||||
@@ -812,7 +812,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
||||
items.append(ActionSheetButtonItem(title: globalTitle, color: .destructive, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: messages.map { $0.id }, type: .forEveryone).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: messages.map { $0.id }, type: .forEveryone).start()
|
||||
strongSelf.controllerInteraction?.dismissController()
|
||||
}
|
||||
}))
|
||||
@@ -827,13 +827,13 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
||||
items.append(ActionSheetButtonItem(title: localOptionText, color: .destructive, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: messages.map { $0.id }, type: .forLocalPeer).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: messages.map { $0.id }, type: .forLocalPeer).start()
|
||||
strongSelf.controllerInteraction?.dismissController()
|
||||
}
|
||||
}))
|
||||
}
|
||||
if !ask && items.count == 1 {
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: messages.map { $0.id }, type: .forEveryone).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: messages.map { $0.id }, type: .forEveryone).start()
|
||||
strongSelf.controllerInteraction?.dismissController()
|
||||
} else if !items.isEmpty {
|
||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#import <LegacyComponents/TGMediaAsset.h>
|
||||
|
||||
#import <LegacyComponents/TGMediaAssetsUtils.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGMediaSelectionContext;
|
||||
@class TGMediaEditingContext;
|
||||
@@ -53,7 +52,6 @@
|
||||
@property (nonatomic, assign) bool collapsed;
|
||||
|
||||
@property (nonatomic, strong) NSString *recipientName;
|
||||
@property (nonatomic, assign) TGMediaVideoConversionPreset defaultVideoPreset;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context camera:(bool)hasCamera selfPortrait:(bool)selfPortrait forProfilePhoto:(bool)forProfilePhoto assetType:(TGMediaAssetType)assetType saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping;
|
||||
|
||||
|
||||
@@ -801,7 +801,7 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
||||
if ([cell isKindOfClass:[TGAttachmentAssetCell class]])
|
||||
thumbnailImage = cell.imageView.image;
|
||||
|
||||
TGMediaPickerModernGalleryMixin *mixin = [[TGMediaPickerModernGalleryMixin alloc] initWithContext:_context item:asset fetchResult:_fetchResult parentController:self.parentController thumbnailImage:thumbnailImage selectionContext:_selectionContext editingContext:_editingContext suggestionContext:self.suggestionContext hasCaptions:(_allowCaptions && !_forProfilePhoto) allowCaptionEntities:self.allowCaptionEntities hasTimer:self.hasTimer onlyCrop:self.onlyCrop inhibitDocumentCaptions:_inhibitDocumentCaptions inhibitMute:self.inhibitMute asFile:self.asFile itemsLimit:TGAttachmentDisplayedAssetLimit recipientName:self.recipientName defaultVideoPreset:self.defaultVideoPreset hasSilentPosting:self.hasSilentPosting hasSchedule:self.hasSchedule reminder:self.reminder];
|
||||
TGMediaPickerModernGalleryMixin *mixin = [[TGMediaPickerModernGalleryMixin alloc] initWithContext:_context item:asset fetchResult:_fetchResult parentController:self.parentController thumbnailImage:thumbnailImage selectionContext:_selectionContext editingContext:_editingContext suggestionContext:self.suggestionContext hasCaptions:(_allowCaptions && !_forProfilePhoto) allowCaptionEntities:self.allowCaptionEntities hasTimer:self.hasTimer onlyCrop:self.onlyCrop inhibitDocumentCaptions:_inhibitDocumentCaptions inhibitMute:self.inhibitMute asFile:self.asFile itemsLimit:TGAttachmentDisplayedAssetLimit recipientName:self.recipientName hasSilentPosting:self.hasSilentPosting hasSchedule:self.hasSchedule reminder:self.reminder];
|
||||
mixin.presentScheduleController = self.presentScheduleController;
|
||||
__weak TGAttachmentCarouselItemView *weakSelf = self;
|
||||
mixin.thumbnailSignalForItem = ^SSignal *(id item)
|
||||
@@ -864,7 +864,7 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
||||
{
|
||||
id<LegacyComponentsOverlayWindowManager> windowManager = [_context makeOverlayWindowManager];
|
||||
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:asset intent:_disableStickers ? TGPhotoEditorControllerSignupAvatarIntent : TGPhotoEditorControllerAvatarIntent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab defaultVideoPreset:_defaultVideoPreset];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:asset intent:_disableStickers ? TGPhotoEditorControllerSignupAvatarIntent : TGPhotoEditorControllerAvatarIntent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab];
|
||||
controller.editingContext = _editingContext;
|
||||
controller.dontHideStatusBar = true;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#import <LegacyComponents/TGOverlayController.h>
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGMediaSelectionContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class PGCamera;
|
||||
@class TGCameraPreviewView;
|
||||
@@ -46,7 +45,6 @@ typedef enum {
|
||||
@property (nonatomic, strong) NSArray *forcedEntities;
|
||||
|
||||
@property (nonatomic, strong) NSString *recipientName;
|
||||
@property (nonatomic, assign) TGMediaVideoConversionPreset defaultVideoPreset;
|
||||
|
||||
@property (nonatomic, copy) void(^finishedWithResults)(TGOverlayController *controller, TGMediaSelectionContext *selectionContext, TGMediaEditingContext *editingContext, id<TGMediaSelectableItem> currentItem, bool silentPosting, int32_t scheduleTime);
|
||||
@property (nonatomic, copy) void(^finishedWithPhoto)(TGOverlayController *controller, UIImage *resultImage, NSString *caption, NSArray *entities, NSArray *stickers, NSNumber *timer);
|
||||
|
||||
@@ -1247,7 +1247,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
||||
}];
|
||||
|
||||
bool hasCamera = !self.inhibitMultipleCapture && ((_intent == TGCameraControllerGenericIntent && !_shortcut) || (_intent == TGCameraControllerPassportMultipleIntent));
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:windowContext items:galleryItems focusItem:focusItem selectionContext:_items.count > 1 ? selectionContext : nil editingContext:editingContext hasCaptions:self.allowCaptions allowCaptionEntities:self.allowCaptionEntities hasTimer:self.hasTimer onlyCrop:_intent == TGCameraControllerPassportIntent || _intent == TGCameraControllerPassportIdIntent || _intent == TGCameraControllerPassportMultipleIntent inhibitDocumentCaptions:self.inhibitDocumentCaptions hasSelectionPanel:true hasCamera:hasCamera recipientName:self.recipientName defaultVideoPreset:self.defaultVideoPreset];
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:windowContext items:galleryItems focusItem:focusItem selectionContext:_items.count > 1 ? selectionContext : nil editingContext:editingContext hasCaptions:self.allowCaptions allowCaptionEntities:self.allowCaptionEntities hasTimer:self.hasTimer onlyCrop:_intent == TGCameraControllerPassportIntent || _intent == TGCameraControllerPassportIdIntent || _intent == TGCameraControllerPassportMultipleIntent inhibitDocumentCaptions:self.inhibitDocumentCaptions hasSelectionPanel:true hasCamera:hasCamera recipientName:self.recipientName];
|
||||
model.inhibitMute = self.inhibitMute;
|
||||
model.controller = galleryController;
|
||||
model.suggestionContext = self.suggestionContext;
|
||||
@@ -1651,7 +1651,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
||||
if (_intent == TGCameraControllerSignupAvatarIntent) {
|
||||
intent = TGPhotoEditorControllerSignupAvatarIntent;
|
||||
}
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:windowContext item:image intent:(TGPhotoEditorControllerFromCameraIntent | intent) adjustments:nil caption:nil screenImage:image availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab defaultVideoPreset:_defaultVideoPreset];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:windowContext item:image intent:(TGPhotoEditorControllerFromCameraIntent | intent) adjustments:nil caption:nil screenImage:image availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab];
|
||||
__weak TGPhotoEditorController *weakController = controller;
|
||||
controller.beginTransitionIn = ^UIView *(CGRect *referenceFrame, __unused UIView **parentView)
|
||||
{
|
||||
@@ -1735,7 +1735,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
||||
|
||||
default:
|
||||
{
|
||||
TGCameraPhotoPreviewController *controller = _shortcut ? [[TGCameraPhotoPreviewController alloc] initWithContext:windowContext image:image metadata:metadata recipientName:self.recipientName backButtonTitle:TGLocalized(@"Camera.Retake") doneButtonTitle:TGLocalized(@"Common.Next") saveCapturedMedia:_saveCapturedMedia saveEditedPhotos:_saveEditedPhotos defaultVideoPreset:_defaultVideoPreset] : [[TGCameraPhotoPreviewController alloc] initWithContext:windowContext image:image metadata:metadata recipientName:self.recipientName saveCapturedMedia:_saveCapturedMedia saveEditedPhotos:_saveEditedPhotos defaultVideoPreset:_defaultVideoPreset];
|
||||
TGCameraPhotoPreviewController *controller = _shortcut ? [[TGCameraPhotoPreviewController alloc] initWithContext:windowContext image:image metadata:metadata recipientName:self.recipientName backButtonTitle:TGLocalized(@"Camera.Retake") doneButtonTitle:TGLocalized(@"Common.Next") saveCapturedMedia:_saveCapturedMedia saveEditedPhotos:_saveEditedPhotos] : [[TGCameraPhotoPreviewController alloc] initWithContext:windowContext image:image metadata:metadata recipientName:self.recipientName saveCapturedMedia:_saveCapturedMedia saveEditedPhotos:_saveEditedPhotos];
|
||||
controller.allowCaptions = self.allowCaptions;
|
||||
controller.shouldStoreAssets = self.shouldStoreCapturedAssets;
|
||||
controller.suggestionContext = self.suggestionContext;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#import <LegacyComponents/TGOverlayController.h>
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class PGCameraShotMetadata;
|
||||
@class PGPhotoEditorValues;
|
||||
@@ -27,8 +26,8 @@
|
||||
@property (nonatomic, assign) bool hasSilentPosting;
|
||||
@property (nonatomic, assign) bool hasSchedule;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName backButtonTitle:(NSString *)backButtonTitle doneButtonTitle:(NSString *)doneButtonTitle saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName backButtonTitle:(NSString *)backButtonTitle doneButtonTitle:(NSString *)doneButtonTitle saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -80,8 +80,6 @@
|
||||
bool _saveEditedPhotos;
|
||||
|
||||
id<LegacyComponentsContext> _context;
|
||||
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@property (nonatomic, weak) TGPhotoEditorController *editorController;
|
||||
@@ -90,12 +88,12 @@
|
||||
|
||||
@implementation TGCameraPhotoPreviewController
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos
|
||||
{
|
||||
return [self initWithContext:context image:image metadata:metadata recipientName:recipientName backButtonTitle:TGLocalized(@"Camera.Retake") doneButtonTitle:TGLocalized(@"MediaPicker.Send") saveCapturedMedia:saveCapturedMedia saveEditedPhotos:saveEditedPhotos defaultVideoPreset:defaultVideoPreset];
|
||||
return [self initWithContext:context image:image metadata:metadata recipientName:recipientName backButtonTitle:TGLocalized(@"Camera.Retake") doneButtonTitle:TGLocalized(@"MediaPicker.Send") saveCapturedMedia:saveCapturedMedia saveEditedPhotos:saveEditedPhotos];
|
||||
}
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName backButtonTitle:(NSString *)backButtonTitle doneButtonTitle:(NSString *)doneButtonTitle saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image metadata:(PGCameraShotMetadata *)metadata recipientName:(NSString *)recipientName backButtonTitle:(NSString *)backButtonTitle doneButtonTitle:(NSString *)doneButtonTitle saveCapturedMedia:(bool)saveCapturedMedia saveEditedPhotos:(bool)saveEditedPhotos
|
||||
{
|
||||
self = [super initWithContext:context];
|
||||
if (self != nil)
|
||||
@@ -105,7 +103,6 @@
|
||||
_metadata = metadata;
|
||||
_imageSize = image.size;
|
||||
_recipientName = recipientName;
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
|
||||
_editingContext = [[TGMediaEditingContext alloc] init];
|
||||
|
||||
@@ -887,7 +884,7 @@
|
||||
PGPhotoEditorValues *editorValues = (PGPhotoEditorValues *)[_editingContext adjustmentsForItem:_image];
|
||||
NSString *caption = [_editingContext captionForItem:_image];
|
||||
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:editableMediaItem intent:TGPhotoEditorControllerFromCameraIntent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_portraitToolbarView.currentTabs selectedTab:tab defaultVideoPreset:_defaultVideoPreset];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:editableMediaItem intent:TGPhotoEditorControllerFromCameraIntent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_portraitToolbarView.currentTabs selectedTab:tab];
|
||||
controller.editingContext = _editingContext;
|
||||
self.editorController = controller;
|
||||
controller.metadata = _metadata;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#import <LegacyComponents/TGModernGalleryController.h>
|
||||
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGClipboardGalleryPhotoItem;
|
||||
|
||||
@@ -20,7 +19,7 @@
|
||||
@property (nonatomic, copy) void (^editorOpened)(void);
|
||||
@property (nonatomic, copy) void (^editorClosed)(void);
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image images:(NSArray *)images parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image images:(NSArray *)images parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName;
|
||||
|
||||
- (void)present;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
@implementation TGClipboardGalleryMixin
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image images:(NSArray *)images parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context image:(UIImage *)image images:(NSArray *)images parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
@@ -61,7 +61,7 @@
|
||||
}
|
||||
}];
|
||||
|
||||
TGClipboardGalleryModel *model = [[TGClipboardGalleryModel alloc] initWithContext:_context images:images focusIndex:focusIndex selectionContext:selectionContext editingContext:editingContext hasCaptions:hasCaptions hasTimer:hasTimer hasSelectionPanel:false recipientName:recipientName defaultVideoPreset:defaultVideoPreset];
|
||||
TGClipboardGalleryModel *model = [[TGClipboardGalleryModel alloc] initWithContext:_context images:images focusIndex:focusIndex selectionContext:selectionContext editingContext:editingContext hasCaptions:hasCaptions hasTimer:hasTimer hasSelectionPanel:false recipientName:recipientName];
|
||||
_galleryModel = model;
|
||||
model.controller = modernGallery;
|
||||
model.suggestionContext = suggestionContext;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#import <LegacyComponents/TGPhotoEditorController.h>
|
||||
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@interface TGClipboardGalleryModel : TGModernGalleryModel
|
||||
|
||||
@@ -27,6 +26,6 @@
|
||||
@property (nonatomic, readonly) TGMediaSelectionContext *selectionContext;
|
||||
@property (nonatomic, strong) TGSuggestionContext *suggestionContext;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context images:(NSArray *)images focusIndex:(NSUInteger)focusIndex selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer hasSelectionPanel:(bool)hasSelectionPanel recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context images:(NSArray *)images focusIndex:(NSUInteger)focusIndex selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer hasSelectionPanel:(bool)hasSelectionPanel recipientName:(NSString *)recipientName;
|
||||
|
||||
@end
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
TGMediaEditingContext *_editingContext;
|
||||
|
||||
id<LegacyComponentsContext> _context;
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@property (nonatomic, weak) TGPhotoEditorController *editorController;
|
||||
@@ -35,13 +34,12 @@
|
||||
|
||||
@implementation TGClipboardGalleryModel
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context images:(NSArray *)images focusIndex:(NSUInteger)focusIndex selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer hasSelectionPanel:(bool)hasSelectionPanel recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context images:(NSArray *)images focusIndex:(NSUInteger)focusIndex selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions hasTimer:(bool)hasTimer hasSelectionPanel:(bool)hasSelectionPanel recipientName:(NSString *)recipientName
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_context = context;
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
|
||||
NSMutableArray *items = [[NSMutableArray alloc] init];
|
||||
TGClipboardGalleryPhotoItem *focusItem = nil;
|
||||
@@ -79,7 +77,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
_interfaceView = [[TGMediaPickerGalleryInterfaceView alloc] initWithContext:_context focusItem:focusItem selectionContext:selectionContext editingContext:editingContext hasSelectionPanel:hasSelectionPanel hasCameraButton:false recipientName:recipientName defaultVideoPreset:defaultVideoPreset];
|
||||
_interfaceView = [[TGMediaPickerGalleryInterfaceView alloc] initWithContext:_context focusItem:focusItem selectionContext:selectionContext editingContext:editingContext hasSelectionPanel:hasSelectionPanel hasCameraButton:false recipientName:recipientName];
|
||||
_interfaceView.hasCaptions = hasCaptions;
|
||||
_interfaceView.hasTimer = hasTimer;
|
||||
[_interfaceView setEditorTabPressed:^(TGPhotoEditorTab tab)
|
||||
@@ -322,7 +320,7 @@
|
||||
}
|
||||
|
||||
TGPhotoEditorControllerIntent intent = isVideo ? TGPhotoEditorControllerVideoIntent : TGPhotoEditorControllerGenericIntent;
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:item.editableMediaItem intent:intent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_interfaceView.currentTabs selectedTab:tab defaultVideoPreset:_defaultVideoPreset];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:item.editableMediaItem intent:intent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_interfaceView.currentTabs selectedTab:tab];
|
||||
controller.editingContext = _editingContext;
|
||||
self.editorController = controller;
|
||||
controller.suggestionContext = self.suggestionContext;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGViewController;
|
||||
@class TGMenuSheetController;
|
||||
@@ -13,7 +12,7 @@
|
||||
|
||||
@interface TGClipboardMenu : NSObject
|
||||
|
||||
+ (TGMenuSheetController *)presentInParentController:(TGViewController *)parentController context:(id<LegacyComponentsContext>)context images:(NSArray *)images hasCaption:(bool)hasCaption hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset completed:(void (^)(TGMediaSelectionContext *selectionContext, TGMediaEditingContext *editingContext, id<TGMediaSelectableItem> currentItem))completed dismissed:(void (^)(void))dismissed sourceView:(UIView *)sourceView sourceRect:(CGRect (^)(void))sourceRect;
|
||||
+ (TGMenuSheetController *)presentInParentController:(TGViewController *)parentController context:(id<LegacyComponentsContext>)context images:(NSArray *)images hasCaption:(bool)hasCaption hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName completed:(void (^)(TGMediaSelectionContext *selectionContext, TGMediaEditingContext *editingContext, id<TGMediaSelectableItem> currentItem))completed dismissed:(void (^)(void))dismissed sourceView:(UIView *)sourceView sourceRect:(CGRect (^)(void))sourceRect;
|
||||
|
||||
+ (NSArray *)resultSignalsForSelectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext currentItem:(id<TGMediaSelectableItem>)currentItem descriptionGenerator:(id (^)(id, NSString *, NSArray *, NSString *))descriptionGenerator;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
@implementation TGClipboardMenu
|
||||
|
||||
+ (TGMenuSheetController *)presentInParentController:(TGViewController *)parentController context:(id<LegacyComponentsContext>)context images:(NSArray *)images hasCaption:(bool)hasCaption hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset completed:(void (^)(TGMediaSelectionContext *selectionContext, TGMediaEditingContext *editingContext, id<TGMediaSelectableItem> currentItem))completed dismissed:(void (^)(void))dismissed sourceView:(UIView *)sourceView sourceRect:(CGRect (^)(void))sourceRect
|
||||
+ (TGMenuSheetController *)presentInParentController:(TGViewController *)parentController context:(id<LegacyComponentsContext>)context images:(NSArray *)images hasCaption:(bool)hasCaption hasTimer:(bool)hasTimer recipientName:(NSString *)recipientName completed:(void (^)(TGMediaSelectionContext *selectionContext, TGMediaEditingContext *editingContext, id<TGMediaSelectableItem> currentItem))completed dismissed:(void (^)(void))dismissed sourceView:(UIView *)sourceView sourceRect:(CGRect (^)(void))sourceRect
|
||||
{
|
||||
bool centered = false;
|
||||
if (sourceRect == nil)
|
||||
@@ -46,7 +46,6 @@
|
||||
previewItem.allowCaptions = hasCaption;
|
||||
previewItem.hasTimer = hasTimer;
|
||||
previewItem.recipientName = recipientName;
|
||||
previewItem.defaultVideoPreset = defaultVideoPreset;
|
||||
previewItem.sendPressed = ^(UIImage *currentItem)
|
||||
{
|
||||
__strong TGClipboardPreviewItemView *strongPreviewItem = weakPreviewItem;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
@property (nonatomic, assign) bool allowCaptions;
|
||||
@property (nonatomic, assign) bool hasTimer;
|
||||
@property (nonatomic, strong) NSString *recipientName;
|
||||
@property (nonatomic, assign) TGMediaVideoConversionPreset defaultVideoPreset;
|
||||
|
||||
@property (nonatomic, readonly) TGMediaSelectionContext *selectionContext;
|
||||
@property (nonatomic, readonly) TGMediaEditingContext *editingContext;
|
||||
|
||||
@@ -266,7 +266,7 @@ const CGFloat TGClipboardPreviewEdgeInset = 8.0f;
|
||||
if ([cell isKindOfClass:[TGClipboardPreviewCell class]])
|
||||
thumbnailImage = cell.imageView.image;
|
||||
|
||||
TGClipboardGalleryMixin *mixin = [[TGClipboardGalleryMixin alloc] initWithContext:_context image:image images:_images parentController:self.parentController thumbnailImage:thumbnailImage selectionContext:_selectionContext editingContext:_editingContext suggestionContext:self.suggestionContext hasCaptions:self.allowCaptions hasTimer:self.hasTimer recipientName:self.recipientName defaultVideoPreset:self.defaultVideoPreset];
|
||||
TGClipboardGalleryMixin *mixin = [[TGClipboardGalleryMixin alloc] initWithContext:_context image:image images:_images parentController:self.parentController thumbnailImage:thumbnailImage selectionContext:_selectionContext editingContext:_editingContext suggestionContext:self.suggestionContext hasCaptions:self.allowCaptions hasTimer:self.hasTimer recipientName:self.recipientName];
|
||||
|
||||
[self _setupGalleryMixin:mixin];
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#import <LegacyComponents/TGMediaAssetsUtils.h>
|
||||
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGMediaAssetsPickerController;
|
||||
@class TGViewController;
|
||||
|
||||
@@ -93,8 +91,8 @@ typedef enum
|
||||
|
||||
- (void)dismiss;
|
||||
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping selectionLimit:(int)selectionLimit;
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping inhibitSelection:(bool)inhibitSelection selectionLimit:(int)selectionLimit;
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping selectionLimit:(int)selectionLimit;
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping inhibitSelection:(bool)inhibitSelection selectionLimit:(int)selectionLimit;
|
||||
|
||||
+ (TGMediaAssetType)assetTypeForIntent:(TGMediaAssetsControllerIntent)intent;
|
||||
|
||||
|
||||
@@ -58,12 +58,12 @@
|
||||
|
||||
@implementation TGMediaAssetsController
|
||||
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping selectionLimit:(int)selectionLimit
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping selectionLimit:(int)selectionLimit
|
||||
{
|
||||
return [self controllerWithContext:context assetGroup:assetGroup intent:intent recipientName:recipientName defaultVideoPreset:defaultVideoPreset saveEditedPhotos:saveEditedPhotos allowGrouping:allowGrouping inhibitSelection:false selectionLimit:selectionLimit];
|
||||
return [self controllerWithContext:context assetGroup:assetGroup intent:intent recipientName:recipientName saveEditedPhotos:saveEditedPhotos allowGrouping:allowGrouping inhibitSelection:false selectionLimit:selectionLimit];
|
||||
}
|
||||
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping inhibitSelection:(bool)inhibitSelection selectionLimit:(int)selectionLimit
|
||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping inhibitSelection:(bool)inhibitSelection selectionLimit:(int)selectionLimit
|
||||
{
|
||||
if (intent != TGMediaAssetsControllerSendMediaIntent)
|
||||
allowGrouping = false;
|
||||
@@ -106,7 +106,7 @@
|
||||
|
||||
if ([group isKindOfClass:[TGMediaAssetGroup class]])
|
||||
{
|
||||
pickerController = [[TGMediaAssetsPickerController alloc] initWithContext:strongController->_context assetsLibrary:strongController.assetsLibrary assetGroup:group intent:intent selectionContext:inhibitSelection ? nil : strongController->_selectionContext editingContext:strongController->_editingContext saveEditedPhotos:strongController->_saveEditedPhotos defaultVideoPreset:defaultVideoPreset];
|
||||
pickerController = [[TGMediaAssetsPickerController alloc] initWithContext:strongController->_context assetsLibrary:strongController.assetsLibrary assetGroup:group intent:intent selectionContext:inhibitSelection ? nil : strongController->_selectionContext editingContext:strongController->_editingContext saveEditedPhotos:strongController->_saveEditedPhotos];
|
||||
pickerController.pallete = strongController.pallete;
|
||||
}
|
||||
pickerController.suggestionContext = strongController.suggestionContext;
|
||||
@@ -118,7 +118,6 @@
|
||||
pickerController.liveVideoUploadEnabled = strongController.liveVideoUploadEnabled;
|
||||
pickerController.catchToolbarView = catchToolbarView;
|
||||
pickerController.recipientName = recipientName;
|
||||
pickerController.defaultVideoPreset = defaultVideoPreset;
|
||||
pickerController.hasTimer = strongController.hasTimer;
|
||||
pickerController.onlyCrop = strongController.onlyCrop;
|
||||
pickerController.hasSilentPosting = strongController.hasSilentPosting;
|
||||
@@ -129,7 +128,7 @@
|
||||
};
|
||||
[groupsController loadViewIfNeeded];
|
||||
|
||||
TGMediaAssetsPickerController *pickerController = [[TGMediaAssetsPickerController alloc] initWithContext:context assetsLibrary:assetsController.assetsLibrary assetGroup:assetGroup intent:intent selectionContext:inhibitSelection ? nil : assetsController->_selectionContext editingContext:assetsController->_editingContext saveEditedPhotos:saveEditedPhotos defaultVideoPreset:defaultVideoPreset];
|
||||
TGMediaAssetsPickerController *pickerController = [[TGMediaAssetsPickerController alloc] initWithContext:context assetsLibrary:assetsController.assetsLibrary assetGroup:assetGroup intent:intent selectionContext:inhibitSelection ? nil : assetsController->_selectionContext editingContext:assetsController->_editingContext saveEditedPhotos:saveEditedPhotos];
|
||||
pickerController.pallete = assetsController.pallete;
|
||||
pickerController.catchToolbarView = catchToolbarView;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#import <LegacyComponents/TGMediaPickerController.h>
|
||||
#import <LegacyComponents/TGMediaAssetsController.h>
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGMediaAssetsPreheatMixin;
|
||||
@class TGMediaPickerModernGalleryMixin;
|
||||
@@ -15,6 +14,6 @@
|
||||
@property (nonatomic, assign) bool liveVideoUploadEnabled;
|
||||
@property (nonatomic, readonly) TGMediaAssetGroup *assetGroup;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context assetsLibrary:(TGMediaAssetsLibrary *)assetsLibrary assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context assetsLibrary:(TGMediaAssetsLibrary *)assetsLibrary assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext saveEditedPhotos:(bool)saveEditedPhotos;
|
||||
|
||||
@end
|
||||
|
||||
@@ -46,15 +46,13 @@
|
||||
|
||||
id<LegacyComponentsContext> _context;
|
||||
bool _saveEditedPhotos;
|
||||
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation TGMediaAssetsPickerController
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context assetsLibrary:(TGMediaAssetsLibrary *)assetsLibrary assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext saveEditedPhotos:(bool)saveEditedPhotos defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context assetsLibrary:(TGMediaAssetsLibrary *)assetsLibrary assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext saveEditedPhotos:(bool)saveEditedPhotos
|
||||
{
|
||||
bool hasSelection = false;
|
||||
bool hasEditing = false;
|
||||
@@ -90,7 +88,6 @@
|
||||
_assetsLibrary = assetsLibrary;
|
||||
_assetGroup = assetGroup;
|
||||
_intent = intent;
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
|
||||
[self setTitle:_assetGroup.title];
|
||||
|
||||
@@ -326,7 +323,7 @@
|
||||
|
||||
- (TGMediaPickerModernGalleryMixin *)_galleryMixinForContext:(id<LegacyComponentsContext>)context item:(id)item thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities inhibitDocumentCaptions:(bool)inhibitDocumentCaptions asFile:(bool)asFile
|
||||
{
|
||||
return [[TGMediaPickerModernGalleryMixin alloc] initWithContext:context item:item fetchResult:_fetchResult parentController:self thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:self.hasTimer onlyCrop:self.onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:self.inhibitMute asFile:asFile itemsLimit:0 recipientName:self.recipientName defaultVideoPreset:self.defaultVideoPreset hasSilentPosting:self.hasSilentPosting hasSchedule:self.hasSchedule reminder:self.reminder];
|
||||
return [[TGMediaPickerModernGalleryMixin alloc] initWithContext:context item:item fetchResult:_fetchResult parentController:self thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:self.hasTimer onlyCrop:self.onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:self.inhibitMute asFile:asFile itemsLimit:0 recipientName:self.recipientName hasSilentPosting:self.hasSilentPosting hasSchedule:self.hasSchedule reminder:self.reminder];
|
||||
}
|
||||
|
||||
- (TGMediaPickerModernGalleryMixin *)galleryMixinForIndexPath:(NSIndexPath *)indexPath previewMode:(bool)previewMode outAsset:(TGMediaAsset **)outAsset
|
||||
@@ -398,7 +395,7 @@
|
||||
if (_intent == TGMediaAssetsControllerSetSignupProfilePhotoIntent) {
|
||||
intent = TGPhotoEditorControllerSignupAvatarIntent;
|
||||
}
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:asset intent:intent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab defaultVideoPreset:_defaultVideoPreset];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:asset intent:intent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab];
|
||||
controller.editingContext = self.editingContext;
|
||||
controller.didFinishRenderingFullSizeImage = ^(UIImage *resultImage)
|
||||
{
|
||||
|
||||
@@ -445,7 +445,7 @@
|
||||
if (strongSelf == nil)
|
||||
return nil;
|
||||
|
||||
TGMediaAssetsController *controller = [TGMediaAssetsController controllerWithContext:context assetGroup:group intent:strongSelf->_signup ? TGMediaAssetsControllerSetSignupProfilePhotoIntent : TGMediaAssetsControllerSetProfilePhotoIntent recipientName:nil defaultVideoPreset:TGMediaVideoConversionPresetCompressedDefault saveEditedPhotos:strongSelf->_saveEditedPhotos allowGrouping:false selectionLimit:10];
|
||||
TGMediaAssetsController *controller = [TGMediaAssetsController controllerWithContext:context assetGroup:group intent:strongSelf->_signup ? TGMediaAssetsControllerSetSignupProfilePhotoIntent : TGMediaAssetsControllerSetProfilePhotoIntent recipientName:nil saveEditedPhotos:strongSelf->_saveEditedPhotos allowGrouping:false selectionLimit:10];
|
||||
__weak TGMediaAssetsController *weakController = controller;
|
||||
controller.avatarCompletionBlock = ^(UIImage *resultImage)
|
||||
{
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#import <LegacyComponents/TGSuggestionContext.h>
|
||||
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGMediaPickerLayoutMetrics;
|
||||
@class TGMediaSelectionContext;
|
||||
@class TGMediaEditingContext;
|
||||
@@ -29,7 +27,6 @@
|
||||
@property (nonatomic, assign) bool onlyCrop;
|
||||
@property (nonatomic, assign) bool inhibitMute;
|
||||
@property (nonatomic, strong) NSString *recipientName;
|
||||
@property (nonatomic, assign) TGMediaVideoConversionPreset defaultVideoPreset;
|
||||
@property (nonatomic, assign) bool hasSilentPosting;
|
||||
@property (nonatomic, assign) bool hasSchedule;
|
||||
@property (nonatomic, assign) bool reminder;
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
{
|
||||
_selectionContext = selectionContext;
|
||||
_editingContext = editingContext;
|
||||
_defaultVideoPreset = TGMediaVideoConversionPresetCompressedDefault;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#import <LegacyComponents/TGPhotoToolbarView.h>
|
||||
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGMediaSelectionContext;
|
||||
@class TGMediaEditingContext;
|
||||
@@ -38,7 +37,7 @@
|
||||
|
||||
@property (nonatomic, readonly) UIView *timerButton;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasSelectionPanel:(bool)hasSelectionPanel hasCameraButton:(bool)hasCameraButton recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasSelectionPanel:(bool)hasSelectionPanel hasCameraButton:(bool)hasCameraButton recipientName:(NSString *)recipientName;
|
||||
|
||||
- (void)setSelectedItemsModel:(TGMediaPickerGallerySelectedItemsModel *)selectedItemsModel;
|
||||
- (void)setEditorTabPressed:(void (^)(TGPhotoEditorTab tab))editorTabPressed;
|
||||
|
||||
@@ -92,8 +92,6 @@
|
||||
id<LegacyComponentsContext> _context;
|
||||
|
||||
bool _ignoreSelectionUpdates;
|
||||
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) ASHandle *actionHandle;
|
||||
@@ -105,7 +103,7 @@
|
||||
|
||||
@synthesize safeAreaInset = _safeAreaInset;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasSelectionPanel:(bool)hasSelectionPanel hasCameraButton:(bool)hasCameraButton recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasSelectionPanel:(bool)hasSelectionPanel hasCameraButton:(bool)hasCameraButton recipientName:(NSString *)recipientName
|
||||
{
|
||||
self = [super initWithFrame:CGRectZero];
|
||||
if (self != nil)
|
||||
@@ -118,8 +116,6 @@
|
||||
|
||||
_hasSwipeGesture = true;
|
||||
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
|
||||
_itemHeaderViews = [[NSMutableArray alloc] init];
|
||||
_itemFooterViews = [[NSMutableArray alloc] init];
|
||||
|
||||
@@ -854,7 +850,11 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
preset = _defaultVideoPreset;
|
||||
NSNumber *presetValue = [[NSUserDefaults standardUserDefaults] objectForKey:@"TG_preferredVideoPreset_v0"];
|
||||
if (presetValue != nil)
|
||||
preset = (TGMediaVideoConversionPreset)[presetValue integerValue];
|
||||
else
|
||||
preset = TGMediaVideoConversionPresetCompressedMedium;
|
||||
}
|
||||
|
||||
TGMediaVideoConversionPreset bestPreset = [TGMediaVideoConverter bestAvailablePresetForDimensions:dimensions];
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#import <LegacyComponents/TGMediaAssetsUtils.h>
|
||||
#import <LegacyComponents/LegacyComponentsContext.h>
|
||||
#import <LegacyComponents/TGVideoEditAdjustments.h>
|
||||
|
||||
@class TGModernGalleryController;
|
||||
@class TGMediaPickerGallerySelectedItemsModel;
|
||||
@@ -46,6 +45,6 @@
|
||||
@property (nonatomic, readonly) TGMediaSelectionContext *selectionContext;
|
||||
@property (nonatomic, strong) TGSuggestionContext *suggestionContext;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context items:(NSArray *)items focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions hasSelectionPanel:(bool)hasSelectionPanel hasCamera:(bool)hasCamera recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context items:(NSArray *)items focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions hasSelectionPanel:(bool)hasSelectionPanel hasCamera:(bool)hasCamera recipientName:(NSString *)recipientName;
|
||||
|
||||
@end
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
bool _inhibitDocumentCaptions;
|
||||
NSString *_recipientName;
|
||||
bool _hasCamera;
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@property (nonatomic, weak) TGPhotoEditorController *editorController;
|
||||
@@ -47,7 +46,7 @@
|
||||
|
||||
@implementation TGMediaPickerGalleryModel
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context items:(NSArray *)items focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions hasSelectionPanel:(bool)hasSelectionPanel hasCamera:(bool)hasCamera recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context items:(NSArray *)items focusItem:(id<TGModernGalleryItem>)focusItem selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions hasSelectionPanel:(bool)hasSelectionPanel hasCamera:(bool)hasCamera recipientName:(NSString *)recipientName
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
@@ -67,7 +66,6 @@
|
||||
_hasSelectionPanel = hasSelectionPanel;
|
||||
_inhibitDocumentCaptions = inhibitDocumentCaptions;
|
||||
_recipientName = recipientName;
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
_hasCamera = hasCamera;
|
||||
|
||||
__weak TGMediaPickerGalleryModel *weakSelf = self;
|
||||
@@ -184,7 +182,7 @@
|
||||
if (_interfaceView == nil)
|
||||
{
|
||||
__weak TGMediaPickerGalleryModel *weakSelf = self;
|
||||
_interfaceView = [[TGMediaPickerGalleryInterfaceView alloc] initWithContext:_context focusItem:_initialFocusItem selectionContext:_selectionContext editingContext:_editingContext hasSelectionPanel:_hasSelectionPanel hasCameraButton:_hasCamera recipientName:_recipientName defaultVideoPreset:_defaultVideoPreset];
|
||||
_interfaceView = [[TGMediaPickerGalleryInterfaceView alloc] initWithContext:_context focusItem:_initialFocusItem selectionContext:_selectionContext editingContext:_editingContext hasSelectionPanel:_hasSelectionPanel hasCameraButton:_hasCamera recipientName:_recipientName];
|
||||
[_interfaceView setSuggestionContext:_suggestionContext];
|
||||
_interfaceView.hasCaptions = _hasCaptions;
|
||||
_interfaceView.allowCaptionEntities = _allowCaptionEntities;
|
||||
@@ -387,7 +385,7 @@
|
||||
self.storeOriginalImageForItem(item.editableMediaItem, screenImage);
|
||||
|
||||
TGPhotoEditorControllerIntent intent = isVideo ? TGPhotoEditorControllerVideoIntent : TGPhotoEditorControllerGenericIntent;
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:item.editableMediaItem intent:intent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_interfaceView.currentTabs selectedTab:tab defaultVideoPreset:_defaultVideoPreset];
|
||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:item.editableMediaItem intent:intent adjustments:editorValues caption:caption screenImage:screenImage availableTabs:_interfaceView.currentTabs selectedTab:tab];
|
||||
controller.editingContext = _editingContext;
|
||||
self.editorController = controller;
|
||||
controller.suggestionContext = self.suggestionContext;
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
|
||||
@property (nonatomic, copy) void (^presentScheduleController)(void (^)(int32_t));
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder;
|
||||
|
||||
- (void)present;
|
||||
- (void)updateWithFetchResult:(TGMediaAssetFetchResult *)fetchResult;
|
||||
|
||||
@@ -41,17 +41,17 @@
|
||||
|
||||
@implementation TGMediaPickerModernGalleryMixin
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
{
|
||||
return [self initWithContext:context item:item fetchResult:fetchResult momentList:nil parentController:parentController thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:inhibitMute asFile:asFile itemsLimit:itemsLimit recipientName:recipientName defaultVideoPreset:defaultVideoPreset hasSilentPosting:hasSilentPosting hasSchedule:hasSchedule reminder:reminder];
|
||||
return [self initWithContext:context item:item fetchResult:fetchResult momentList:nil parentController:parentController thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:inhibitMute asFile:asFile itemsLimit:itemsLimit recipientName:recipientName hasSilentPosting:hasSilentPosting hasSchedule:hasSchedule reminder:reminder];
|
||||
}
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
{
|
||||
return [self initWithContext:context item:item fetchResult:nil momentList:momentList parentController:parentController thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:inhibitMute asFile:asFile itemsLimit:itemsLimit recipientName:nil defaultVideoPreset:defaultVideoPreset hasSilentPosting:hasSilentPosting hasSchedule:hasSchedule reminder:reminder];
|
||||
return [self initWithContext:context item:item fetchResult:nil momentList:momentList parentController:parentController thumbnailImage:thumbnailImage selectionContext:selectionContext editingContext:editingContext suggestionContext:suggestionContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions inhibitMute:inhibitMute asFile:asFile itemsLimit:itemsLimit recipientName:nil hasSilentPosting:hasSilentPosting hasSchedule:hasSchedule reminder:reminder];
|
||||
}
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id)item fetchResult:(TGMediaAssetFetchResult *)fetchResult momentList:(TGMediaAssetMomentList *)momentList parentController:(TGViewController *)parentController thumbnailImage:(UIImage *)thumbnailImage selectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext suggestionContext:(TGSuggestionContext *)suggestionContext hasCaptions:(bool)hasCaptions allowCaptionEntities:(bool)allowCaptionEntities hasTimer:(bool)hasTimer onlyCrop:(bool)onlyCrop inhibitDocumentCaptions:(bool)inhibitDocumentCaptions inhibitMute:(bool)inhibitMute asFile:(bool)asFile itemsLimit:(NSUInteger)itemsLimit recipientName:(NSString *)recipientName hasSilentPosting:(bool)hasSilentPosting hasSchedule:(bool)hasSchedule reminder:(bool)reminder
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
@@ -83,7 +83,7 @@
|
||||
|
||||
NSArray *galleryItems = fetchResult != nil ? [self prepareGalleryItemsForFetchResult:fetchResult selectionContext:selectionContext editingContext:editingContext asFile:asFile enumerationBlock:enumerationBlock] : [self prepareGalleryItemsForMomentList:momentList selectionContext:selectionContext editingContext:editingContext asFile:asFile enumerationBlock:enumerationBlock];
|
||||
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:[_windowManager context] items:galleryItems focusItem:focusItem selectionContext:selectionContext editingContext:editingContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions hasSelectionPanel:true hasCamera:false recipientName:recipientName defaultVideoPreset:defaultVideoPreset];
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:[_windowManager context] items:galleryItems focusItem:focusItem selectionContext:selectionContext editingContext:editingContext hasCaptions:hasCaptions allowCaptionEntities:allowCaptionEntities hasTimer:hasTimer onlyCrop:onlyCrop inhibitDocumentCaptions:inhibitDocumentCaptions hasSelectionPanel:true hasCamera:false recipientName:recipientName];
|
||||
_galleryModel = model;
|
||||
model.inhibitMute = inhibitMute;
|
||||
model.controller = modernGallery;
|
||||
|
||||
@@ -227,7 +227,7 @@
|
||||
TGMediaAssetsControllerIntent assetsIntent = (intent == TGPassportAttachIntentMultiple) ? TGMediaAssetsControllerPassportMultipleIntent : TGMediaAssetsControllerPassportIntent;
|
||||
|
||||
[strongParentController presentWithContext:^UIViewController *(id<LegacyComponentsContext> context) {
|
||||
TGMediaAssetsController *controller = [TGMediaAssetsController controllerWithContext:context assetGroup:group intent:assetsIntent recipientName:nil defaultVideoPreset:TGMediaVideoConversionPresetCompressedDefault saveEditedPhotos:false allowGrouping:false selectionLimit:10];
|
||||
TGMediaAssetsController *controller = [TGMediaAssetsController controllerWithContext:context assetGroup:group intent:assetsIntent recipientName:nil saveEditedPhotos:false allowGrouping:false selectionLimit:10];
|
||||
controller.onlyCrop = true;
|
||||
__weak TGMediaAssetsController *weakController = controller;
|
||||
controller.singleCompletionBlock = ^(id<TGMediaEditableItem> currentItem, TGMediaEditingContext *editingContext) {
|
||||
|
||||
@@ -51,7 +51,7 @@ typedef enum {
|
||||
@property (nonatomic, assign) bool dontHideStatusBar;
|
||||
@property (nonatomic, strong) PGCameraShotMetadata *metadata;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id<TGMediaEditableItem>)item intent:(TGPhotoEditorControllerIntent)intent adjustments:(id<TGMediaEditAdjustments>)adjustments caption:(NSString *)caption screenImage:(UIImage *)screenImage availableTabs:(TGPhotoEditorTab)availableTabs selectedTab:(TGPhotoEditorTab)selectedTab defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id<TGMediaEditableItem>)item intent:(TGPhotoEditorControllerIntent)intent adjustments:(id<TGMediaEditAdjustments>)adjustments caption:(NSString *)caption screenImage:(UIImage *)screenImage availableTabs:(TGPhotoEditorTab)availableTabs selectedTab:(TGPhotoEditorTab)selectedTab;
|
||||
|
||||
- (void)dismissEditor;
|
||||
- (void)applyEditor;
|
||||
|
||||
@@ -88,8 +88,6 @@
|
||||
TGMessageImageViewOverlayView *_progressView;
|
||||
|
||||
id<LegacyComponentsContext> _context;
|
||||
|
||||
TGMediaVideoConversionPreset _defaultVideoPreset;
|
||||
}
|
||||
|
||||
@property (nonatomic, weak) UIImage *fullSizeImage;
|
||||
@@ -100,7 +98,7 @@
|
||||
|
||||
@synthesize actionHandle = _actionHandle;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id<TGMediaEditableItem>)item intent:(TGPhotoEditorControllerIntent)intent adjustments:(id<TGMediaEditAdjustments>)adjustments caption:(NSString *)caption screenImage:(UIImage *)screenImage availableTabs:(TGPhotoEditorTab)availableTabs selectedTab:(TGPhotoEditorTab)selectedTab defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context item:(id<TGMediaEditableItem>)item intent:(TGPhotoEditorControllerIntent)intent adjustments:(id<TGMediaEditAdjustments>)adjustments caption:(NSString *)caption screenImage:(UIImage *)screenImage availableTabs:(TGPhotoEditorTab)availableTabs selectedTab:(TGPhotoEditorTab)selectedTab
|
||||
{
|
||||
self = [super initWithContext:context];
|
||||
if (self != nil)
|
||||
@@ -122,8 +120,6 @@
|
||||
_initialAdjustments = adjustments;
|
||||
_screenImage = screenImage;
|
||||
|
||||
_defaultVideoPreset = defaultVideoPreset;
|
||||
|
||||
_queue = [[SQueue alloc] init];
|
||||
_photoEditor = [[PGPhotoEditor alloc] initWithOriginalSize:_item.originalSize adjustments:adjustments forVideo:(intent == TGPhotoEditorControllerVideoIntent) enableStickers:(intent & TGPhotoEditorControllerSignupAvatarIntent) == 0];
|
||||
if ([self presentedForAvatarCreation])
|
||||
@@ -1118,7 +1114,7 @@
|
||||
{
|
||||
_ignoreDefaultPreviewViewTransitionIn = true;
|
||||
|
||||
TGPhotoQualityController *qualityController = [[TGPhotoQualityController alloc] initWithContext:_context photoEditor:_photoEditor previewView:_previewView defaultPreset:_defaultVideoPreset];
|
||||
TGPhotoQualityController *qualityController = [[TGPhotoQualityController alloc] initWithContext:_context photoEditor:_photoEditor previewView:_previewView];
|
||||
qualityController.item = _item;
|
||||
qualityController.toolbarLandscapeSize = TGPhotoEditorToolbarSize;
|
||||
qualityController.beginTransitionIn = ^UIView *(CGRect *referenceFrame, UIView **parentView, bool *noTransitionView)
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
|
||||
@property (nonatomic, readonly) TGMediaVideoConversionPreset preset;
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context photoEditor:(PGPhotoEditor *)photoEditor previewView:(TGPhotoEditorPreviewView *)previewView defaultPreset:(TGMediaVideoConversionPreset)defaultPreset;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context photoEditor:(PGPhotoEditor *)photoEditor previewView:(TGPhotoEditorPreviewView *)previewView;
|
||||
|
||||
@end
|
||||
|
||||
@@ -69,7 +69,7 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f;
|
||||
|
||||
@implementation TGPhotoQualityController
|
||||
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context photoEditor:(PGPhotoEditor *)photoEditor previewView:(TGPhotoEditorPreviewView *)previewView defaultPreset:(TGMediaVideoConversionPreset)defaultPreset
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context photoEditor:(PGPhotoEditor *)photoEditor previewView:(TGPhotoEditorPreviewView *)previewView
|
||||
{
|
||||
self = [super initWithContext:context];
|
||||
if (self != nil)
|
||||
@@ -89,7 +89,11 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = defaultPreset;
|
||||
NSNumber *presetValue = [[NSUserDefaults standardUserDefaults] objectForKey:@"TG_preferredVideoPreset_v0"];
|
||||
if (presetValue != nil)
|
||||
value = [presetValue integerValue];
|
||||
else
|
||||
value = TGMediaVideoConversionPresetCompressedMedium;
|
||||
}
|
||||
|
||||
_disposable = [[SMetaDisposable alloc] init];
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
@interface TGPhotoVideoEditor : NSObject
|
||||
|
||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller caption:(NSString *)caption entities:(NSArray *)entities withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset completion:(void (^)(id<TGMediaEditableItem>, TGMediaEditingContext *))completion;
|
||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller caption:(NSString *)caption entities:(NSArray *)entities withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName completion:(void (^)(id<TGMediaEditableItem>, TGMediaEditingContext *))completion;
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
@implementation TGPhotoVideoEditor
|
||||
|
||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller caption:(NSString *)caption entities:(NSArray *)entities withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName defaultVideoPreset:(TGMediaVideoConversionPreset)defaultVideoPreset completion:(void (^)(id<TGMediaEditableItem>, TGMediaEditingContext *))completion
|
||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller caption:(NSString *)caption entities:(NSArray *)entities withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName completion:(void (^)(id<TGMediaEditableItem>, TGMediaEditingContext *))completion
|
||||
{
|
||||
id<LegacyComponentsOverlayWindowManager> windowManager = [context makeOverlayWindowManager];
|
||||
id<LegacyComponentsContext> windowContext = [windowManager context];
|
||||
@@ -29,7 +29,7 @@
|
||||
galleryItem = [[TGMediaPickerGalleryPhotoItem alloc] initWithAsset:item];
|
||||
galleryItem.editingContext = editingContext;
|
||||
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:windowContext items:@[galleryItem] focusItem:galleryItem selectionContext:nil editingContext:editingContext hasCaptions:true allowCaptionEntities:true hasTimer:false onlyCrop:false inhibitDocumentCaptions:false hasSelectionPanel:false hasCamera:false recipientName:recipientName defaultVideoPreset:defaultVideoPreset];
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:windowContext items:@[galleryItem] focusItem:galleryItem selectionContext:nil editingContext:editingContext hasCaptions:true allowCaptionEntities:true hasTimer:false onlyCrop:false inhibitDocumentCaptions:false hasSelectionPanel:false hasCamera:false recipientName:recipientName];
|
||||
model.controller = galleryController;
|
||||
//model.suggestionContext = self.suggestionContext;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public func defaultVideoPresetForContext(_ context: AccountContext) -> TGMediaVi
|
||||
case 4:
|
||||
return TGMediaVideoConversionPresetCompressedHigh
|
||||
case 5:
|
||||
return TGMediaVideoConversionPresetCompressedVeryLow
|
||||
return TGMediaVideoConversionPresetCompressedVeryHigh
|
||||
default:
|
||||
return TGMediaVideoConversionPresetCompressedMedium
|
||||
}
|
||||
@@ -63,6 +63,9 @@ public struct LegacyAttachmentMenuMediaEditing: OptionSet {
|
||||
}
|
||||
|
||||
public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaOptions: LegacyAttachmentMenuMediaEditing?, saveEditedPhotos: Bool, allowGrouping: Bool, hasSchedule: Bool, canSendPolls: Bool, presentationData: PresentationData, parentController: LegacyController, recentlyUsedInlineBots: [Peer], initialCaption: String, openGallery: @escaping () -> Void, openCamera: @escaping (TGAttachmentCameraView?, TGMenuSheetController?) -> Void, openFileGallery: @escaping () -> Void, openWebSearch: @escaping () -> Void, openMap: @escaping () -> Void, openContacts: @escaping () -> Void, openPoll: @escaping () -> Void, presentSelectionLimitExceeded: @escaping () -> Void, presentCantSendMultipleFiles: @escaping () -> Void, presentSchedulePicker: @escaping (@escaping (Int32) -> Void) -> Void, sendMessagesWithSignals: @escaping ([Any]?, Bool, Int32) -> Void, selectRecentlyUsedInlineBot: @escaping (Peer) -> Void) -> TGMenuSheetController {
|
||||
let defaultVideoPreset = defaultVideoPresetForContext(context)
|
||||
UserDefaults.standard.set(defaultVideoPreset.rawValue as NSNumber, forKey: "TG_preferredVideoPreset_v0")
|
||||
|
||||
let actionSheetTheme = ActionSheetControllerTheme(presentationData: presentationData)
|
||||
let fontSize = floor(actionSheetTheme.baseFontSize * 20.0 / 17.0)
|
||||
|
||||
@@ -103,7 +106,6 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaO
|
||||
carouselItemView = carouselItem
|
||||
carouselItem.suggestionContext = legacySuggestionContext(context: context, peerId: peer.id)
|
||||
carouselItem.recipientName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
carouselItem.defaultVideoPreset = defaultVideoPresetForContext(context)
|
||||
carouselItem.cameraPressed = { [weak controller] cameraView in
|
||||
if let controller = controller {
|
||||
DeviceAccess.authorizeAccess(to: .camera, presentationData: context.sharedContext.currentPresentationData.with { $0 }, present: context.sharedContext.presentGlobalController, openSettings: context.sharedContext.applicationBindings.openSettings, { value in
|
||||
@@ -237,6 +239,9 @@ public func legacyMenuPaletteFromTheme(_ theme: PresentationTheme) -> TGMenuShee
|
||||
}
|
||||
|
||||
public func presentLegacyPasteMenu(context: AccountContext, peer: Peer, saveEditedPhotos: Bool, allowGrouping: Bool, presentationData: PresentationData, images: [UIImage], sendMessagesWithSignals: @escaping ([Any]?) -> Void, present: (ViewController, Any?) -> Void, initialLayout: ContainerViewLayout? = nil) -> ViewController {
|
||||
let defaultVideoPreset = defaultVideoPresetForContext(context)
|
||||
UserDefaults.standard.set(defaultVideoPreset.rawValue as NSNumber, forKey: "TG_preferredVideoPreset_v0")
|
||||
|
||||
let legacyController = LegacyController(presentation: .custom, theme: presentationData.theme, initialLayout: initialLayout)
|
||||
legacyController.statusBar.statusBarStyle = .Ignore
|
||||
legacyController.controllerLoaded = { [weak legacyController] in
|
||||
@@ -260,7 +265,7 @@ public func presentLegacyPasteMenu(context: AccountContext, peer: Peer, saveEdit
|
||||
|
||||
legacyController.enableSizeClassSignal = true
|
||||
|
||||
let controller = TGClipboardMenu.present(inParentController: emptyController, context: legacyController.context, images: images, hasCaption: true, hasTimer: hasTimer, recipientName: recipientName, defaultVideoPreset: defaultVideoPresetForContext(context), completed: { selectionContext, editingContext, currentItem in
|
||||
let controller = TGClipboardMenu.present(inParentController: emptyController, context: legacyController.context, images: images, hasCaption: true, hasTimer: hasTimer, recipientName: recipientName, completed: { selectionContext, editingContext, currentItem in
|
||||
let signals = TGClipboardMenu.resultSignals(for: selectionContext, editingContext: editingContext, currentItem: currentItem, descriptionGenerator: legacyAssetPickerItemGenerator())
|
||||
sendMessagesWithSignals(signals)
|
||||
}, dismissed: { [weak legacyController] in
|
||||
|
||||
@@ -57,6 +57,7 @@ public func legacyAssetPicker(context: AccountContext, presentationData: Present
|
||||
return Signal { subscriber in
|
||||
let intent = fileMode ? TGMediaAssetsControllerSendFileIntent : TGMediaAssetsControllerSendMediaIntent
|
||||
let defaultVideoPreset = defaultVideoPresetForContext(context)
|
||||
UserDefaults.standard.set(defaultVideoPreset.rawValue as NSNumber, forKey: "TG_preferredVideoPreset_v0")
|
||||
|
||||
DeviceAccess.authorizeAccess(to: .mediaLibrary(.send), presentationData: presentationData, present: context.sharedContext.presentGlobalController, openSettings: context.sharedContext.applicationBindings.openSettings, { value in
|
||||
if !value {
|
||||
@@ -71,7 +72,7 @@ public func legacyAssetPicker(context: AccountContext, presentationData: Present
|
||||
} else {
|
||||
Queue.mainQueue().async {
|
||||
subscriber.putNext({ context in
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: group, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), defaultVideoPreset: defaultVideoPreset, saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, inhibitSelection: editingMedia, selectionLimit: Int32(selectionLimit))
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: group, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, inhibitSelection: editingMedia, selectionLimit: Int32(selectionLimit))
|
||||
return controller!
|
||||
})
|
||||
subscriber.putCompletion()
|
||||
@@ -80,7 +81,7 @@ public func legacyAssetPicker(context: AccountContext, presentationData: Present
|
||||
})
|
||||
} else {
|
||||
subscriber.putNext({ context in
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), defaultVideoPreset: defaultVideoPreset, saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, selectionLimit: Int32(selectionLimit))
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, selectionLimit: Int32(selectionLimit))
|
||||
return controller!
|
||||
})
|
||||
subscriber.putCompletion()
|
||||
|
||||
@@ -24,7 +24,7 @@ public func legacyWallpaperPicker(context: AccountContext, presentationData: Pre
|
||||
} else {
|
||||
Queue.mainQueue().async {
|
||||
subscriber.putNext({ context in
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: group, intent: intent, recipientName: nil, defaultVideoPreset: TGMediaVideoConversionPresetCompressedDefault, saveEditedPhotos: false, allowGrouping: false, selectionLimit: 1)
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: group, intent: intent, recipientName: nil, saveEditedPhotos: false, allowGrouping: false, selectionLimit: 1)
|
||||
return controller!
|
||||
})
|
||||
subscriber.putCompletion()
|
||||
@@ -33,7 +33,7 @@ public func legacyWallpaperPicker(context: AccountContext, presentationData: Pre
|
||||
})
|
||||
} else {
|
||||
subscriber.putNext({ context in
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: nil, defaultVideoPreset: TGMediaVideoConversionPresetCompressedDefault, saveEditedPhotos: false, allowGrouping: false, selectionLimit: 1)
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: nil, saveEditedPhotos: false, allowGrouping: false, selectionLimit: 1)
|
||||
return controller!
|
||||
})
|
||||
subscriber.putCompletion()
|
||||
|
||||
@@ -453,7 +453,7 @@ public class AvatarGalleryController: ViewController, StandalonePresentableContr
|
||||
}
|
||||
} else {
|
||||
if let messageId = messageId {
|
||||
let _ = deleteMessagesInteractively(postbox: self.context.account.postbox, messageIds: [messageId], type: .forEveryone).start()
|
||||
let _ = deleteMessagesInteractively(account: self.context.account, messageIds: [messageId], type: .forEveryone).start()
|
||||
}
|
||||
|
||||
if entry == self.entries.first {
|
||||
|
||||
@@ -1180,7 +1180,7 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
|
||||
})
|
||||
}
|
||||
|
||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(presentationData.strings.Channel_Management_LabelEditor), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
|
||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(initialParticipant?.adminInfo == nil ? presentationData.strings.Channel_Management_AddModerator : presentationData.strings.Channel_Moderator_Title), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
|
||||
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: channelAdminControllerEntries(presentationData: presentationData, state: state, accountPeerId: context.account.peerId, channelView: channelView, adminView: adminView, initialParticipant: initialParticipant, canEdit: canEdit), style: .blocks, focusItemTag: focusItemTag, ensureVisibleItemTag: nil, emptyStateItem: nil, animateChanges: true)
|
||||
|
||||
|
||||
@@ -489,7 +489,7 @@ private func channelAdminsControllerEntries(presentationData: PresentationData,
|
||||
return entries
|
||||
}
|
||||
|
||||
public func channelAdminsController(context: AccountContext, peerId: PeerId, loadCompleted: @escaping () -> Void = {}) -> ViewController {
|
||||
public func channelAdminsController(context: AccountContext, peerId initialPeerId: PeerId, loadCompleted: @escaping () -> Void = {}) -> ViewController {
|
||||
let statePromise = ValuePromise(ChannelAdminsControllerState(), ignoreRepeated: true)
|
||||
let stateValue = Atomic(value: ChannelAdminsControllerState())
|
||||
let updateState: ((ChannelAdminsControllerState) -> ChannelAdminsControllerState) -> Void = { f in
|
||||
@@ -517,15 +517,23 @@ public func channelAdminsController(context: AccountContext, peerId: PeerId, loa
|
||||
|
||||
var upgradedToSupergroupImpl: ((PeerId, @escaping () -> Void) -> Void)?
|
||||
|
||||
let currentPeerId = ValuePromise<PeerId>(initialPeerId)
|
||||
|
||||
let upgradedToSupergroup: (PeerId, @escaping () -> Void) -> Void = { upgradedPeerId, f in
|
||||
currentPeerId.set(upgradedPeerId)
|
||||
upgradedToSupergroupImpl?(upgradedPeerId, f)
|
||||
}
|
||||
|
||||
let transferedOwnership: (PeerId) -> Void = { memberId in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let _ = (context.account.postbox.transaction { transaction -> (channel: Peer?, user: Peer?) in
|
||||
return (channel: transaction.getPeer(peerId), user: transaction.getPeer(memberId))
|
||||
} |> deliverOnMainQueue).start(next: { peer, user in
|
||||
let _ = (currentPeerId.get()
|
||||
|> take(1)
|
||||
|> mapToSignal { peerId in
|
||||
context.account.postbox.transaction { transaction -> (channel: Peer?, user: Peer?) in
|
||||
return (channel: transaction.getPeer(peerId), user: transaction.getPeer(memberId))
|
||||
}
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { peer, user in
|
||||
guard let peer = peer, let user = user else {
|
||||
return
|
||||
}
|
||||
@@ -534,15 +542,22 @@ public func channelAdminsController(context: AccountContext, peerId: PeerId, loa
|
||||
}
|
||||
|
||||
let peerView = Promise<PeerView>()
|
||||
peerView.set(context.account.viewTracker.peerView(peerId))
|
||||
peerView.set(currentPeerId.get()
|
||||
|> mapToSignal { peerId in
|
||||
return context.account.viewTracker.peerView(peerId)
|
||||
})
|
||||
|
||||
let arguments = ChannelAdminsControllerArguments(context: context, openRecentActions: {
|
||||
let _ = (context.account.postbox.loadedPeerWithId(peerId)
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
if peer is TelegramGroup {
|
||||
} else {
|
||||
pushControllerImpl?(context.sharedContext.makeChatRecentActionsController(context: context, peer: peer))
|
||||
}
|
||||
let _ = (currentPeerId.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { peerId in
|
||||
let _ = (context.account.postbox.loadedPeerWithId(peerId)
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
if peer is TelegramGroup {
|
||||
} else {
|
||||
pushControllerImpl?(context.sharedContext.makeChatRecentActionsController(context: context, peer: peer))
|
||||
}
|
||||
})
|
||||
})
|
||||
}, setPeerIdWithRevealedOptions: { peerId, fromPeerId in
|
||||
updateState { state in
|
||||
@@ -553,140 +568,162 @@ public func channelAdminsController(context: AccountContext, peerId: PeerId, loa
|
||||
}
|
||||
}
|
||||
}, removeAdmin: { adminId in
|
||||
updateState {
|
||||
return $0.withUpdatedRemovingPeerId(adminId)
|
||||
}
|
||||
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
removeAdminDisposable.set((removeGroupAdmin(account: context.account, peerId: peerId, adminId: adminId)
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
updateState {
|
||||
return $0.withUpdatedRemovingPeerId(nil)
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
removeAdminDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(account: context.account, peerId: peerId, memberId: adminId, adminRights: TelegramChatAdminRights(flags: []), rank: nil)
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
updateState {
|
||||
return $0.withUpdatedRemovingPeerId(nil)
|
||||
}
|
||||
}))
|
||||
}
|
||||
}, addAdmin: {
|
||||
let _ = (peerView.get()
|
||||
let _ = (currentPeerId.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { peerView in
|
||||
updateState { current in
|
||||
var dismissController: (() -> Void)?
|
||||
let controller = ChannelMembersSearchController(context: context, peerId: peerId, mode: .promote, filters: [], openPeer: { peer, participant in
|
||||
dismissController?()
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
if peer.id == context.account.peerId {
|
||||
return
|
||||
|> deliverOnMainQueue).start(next: { peerId in
|
||||
updateState {
|
||||
return $0.withUpdatedRemovingPeerId(adminId)
|
||||
}
|
||||
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
removeAdminDisposable.set((removeGroupAdmin(account: context.account, peerId: peerId, adminId: adminId)
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
updateState {
|
||||
return $0.withUpdatedRemovingPeerId(nil)
|
||||
}
|
||||
if let participant = participant {
|
||||
switch participant.participant {
|
||||
case .creator:
|
||||
}))
|
||||
} else {
|
||||
removeAdminDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberAdminRights(account: context.account, peerId: peerId, memberId: adminId, adminRights: TelegramChatAdminRights(flags: []), rank: nil)
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
updateState {
|
||||
return $0.withUpdatedRemovingPeerId(nil)
|
||||
}
|
||||
}))
|
||||
}
|
||||
})
|
||||
}, addAdmin: {
|
||||
let _ = (currentPeerId.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { peerId in
|
||||
let _ = (peerView.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { peerView in
|
||||
updateState { current in
|
||||
var dismissController: (() -> Void)?
|
||||
let controller = ChannelMembersSearchController(context: context, peerId: peerId, mode: .promote, filters: [], openPeer: { peer, participant in
|
||||
dismissController?()
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
if peer.id == context.account.peerId {
|
||||
return
|
||||
case let .member(_, _, _, banInfo, _):
|
||||
if let banInfo = banInfo {
|
||||
var canUnban = false
|
||||
if banInfo.restrictedBy != context.account.peerId {
|
||||
canUnban = true
|
||||
}
|
||||
if let channel = peerView.peers[peerId] as? TelegramChannel {
|
||||
if channel.hasPermission(.banMembers) {
|
||||
}
|
||||
if let participant = participant {
|
||||
switch participant.participant {
|
||||
case .creator:
|
||||
return
|
||||
case let .member(_, _, _, banInfo, _):
|
||||
if let banInfo = banInfo {
|
||||
var canUnban = false
|
||||
if banInfo.restrictedBy != context.account.peerId {
|
||||
canUnban = true
|
||||
}
|
||||
}
|
||||
if !canUnban {
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Channel_Members_AddAdminErrorBlacklisted, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
return
|
||||
if let channel = peerView.peers[peerId] as? TelegramChannel {
|
||||
if channel.hasPermission(.banMembers) {
|
||||
canUnban = true
|
||||
}
|
||||
}
|
||||
if !canUnban {
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Channel_Members_AddAdminErrorBlacklisted, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pushControllerImpl?(channelAdminController(context: context, peerId: peerId, adminId: peer.id, initialParticipant: participant?.participant, updated: { _ in
|
||||
}, upgradedToSupergroup: upgradedToSupergroup, transferedOwnership: transferedOwnership))
|
||||
})
|
||||
dismissController = { [weak controller] in
|
||||
controller?.dismiss()
|
||||
}
|
||||
pushControllerImpl?(channelAdminController(context: context, peerId: peerId, adminId: peer.id, initialParticipant: participant?.participant, updated: { _ in
|
||||
}, upgradedToSupergroup: upgradedToSupergroup, transferedOwnership: transferedOwnership))
|
||||
})
|
||||
dismissController = { [weak controller] in
|
||||
controller?.dismiss()
|
||||
pushControllerImpl?(controller)
|
||||
|
||||
return current
|
||||
}
|
||||
pushControllerImpl?(controller)
|
||||
|
||||
return current
|
||||
}
|
||||
})
|
||||
})
|
||||
}, openAdmin: { participant in
|
||||
pushControllerImpl?(channelAdminController(context: context, peerId: peerId, adminId: participant.peerId, initialParticipant: participant, updated: { _ in
|
||||
}, upgradedToSupergroup: upgradedToSupergroup, transferedOwnership: transferedOwnership))
|
||||
let _ = (currentPeerId.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { peerId in
|
||||
pushControllerImpl?(channelAdminController(context: context, peerId: peerId, adminId: participant.peerId, initialParticipant: participant, updated: { _ in
|
||||
}, upgradedToSupergroup: upgradedToSupergroup, transferedOwnership: transferedOwnership))
|
||||
})
|
||||
})
|
||||
|
||||
let membersAndLoadMoreControl: (Disposable, PeerChannelMemberCategoryControl?)
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
var didReportLoadCompleted = false
|
||||
membersAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.admins(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId) { membersState in
|
||||
if case .loading = membersState.loadingState, membersState.list.isEmpty {
|
||||
adminsPromise.set(.single(nil))
|
||||
} else {
|
||||
adminsPromise.set(.single(membersState.list))
|
||||
if !didReportLoadCompleted {
|
||||
didReportLoadCompleted = true
|
||||
loadCompleted()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
loadCompleted()
|
||||
let membersDisposable = (peerView.get()
|
||||
|> map { peerView -> [RenderedChannelParticipant]? in
|
||||
guard let cachedData = peerView.cachedData as? CachedGroupData, let participants = cachedData.participants else {
|
||||
return nil
|
||||
}
|
||||
var result: [RenderedChannelParticipant] = []
|
||||
var creatorPeer: Peer?
|
||||
for participant in participants.participants {
|
||||
if let peer = peerView.peers[participant.peerId] {
|
||||
switch participant {
|
||||
case .creator:
|
||||
creatorPeer = peer
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
guard let creator = creatorPeer else {
|
||||
return nil
|
||||
}
|
||||
for participant in participants.participants {
|
||||
if let peer = peerView.peers[participant.peerId] {
|
||||
switch participant {
|
||||
case .creator:
|
||||
result.append(RenderedChannelParticipant(participant: .creator(id: peer.id, rank: nil), peer: peer))
|
||||
case .admin:
|
||||
var peers: [PeerId: Peer] = [:]
|
||||
peers[creator.id] = creator
|
||||
peers[peer.id] = peer
|
||||
result.append(RenderedChannelParticipant(participant: .member(id: peer.id, invitedAt: 0, adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(flags: .groupSpecific), promotedBy: creator.id, canBeEditedByAccountPeer: creator.id == context.account.peerId), banInfo: nil, rank: nil), peer: peer, peers: peers))
|
||||
case .member:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}).start(next: { members in
|
||||
adminsPromise.set(.single(members))
|
||||
})
|
||||
membersAndLoadMoreControl = (membersDisposable, nil)
|
||||
}
|
||||
let membersAndLoadMoreControlValue = Atomic<(Disposable, PeerChannelMemberCategoryControl?)?>(value: nil)
|
||||
|
||||
let (membersDisposable, loadMoreControl) = membersAndLoadMoreControl
|
||||
actionsDisposable.add(membersDisposable)
|
||||
let membersDisposableValue = MetaDisposable()
|
||||
actionsDisposable.add(membersDisposableValue)
|
||||
|
||||
actionsDisposable.add((currentPeerId.get()
|
||||
|> deliverOnMainQueue).start(next: { peerId in
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
var didReportLoadCompleted = false
|
||||
let membersAndLoadMoreControl: (Disposable, PeerChannelMemberCategoryControl?) = context.peerChannelMemberCategoriesContextsManager.admins(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId) { membersState in
|
||||
if case .loading = membersState.loadingState, membersState.list.isEmpty {
|
||||
adminsPromise.set(.single(nil))
|
||||
} else {
|
||||
adminsPromise.set(.single(membersState.list))
|
||||
if !didReportLoadCompleted {
|
||||
didReportLoadCompleted = true
|
||||
loadCompleted()
|
||||
}
|
||||
}
|
||||
}
|
||||
let _ = membersAndLoadMoreControlValue.swap(membersAndLoadMoreControl)
|
||||
membersDisposableValue.set(membersAndLoadMoreControl.0)
|
||||
} else {
|
||||
loadCompleted()
|
||||
let membersDisposable = (peerView.get()
|
||||
|> map { peerView -> [RenderedChannelParticipant]? in
|
||||
guard let cachedData = peerView.cachedData as? CachedGroupData, let participants = cachedData.participants else {
|
||||
return nil
|
||||
}
|
||||
var result: [RenderedChannelParticipant] = []
|
||||
var creatorPeer: Peer?
|
||||
for participant in participants.participants {
|
||||
if let peer = peerView.peers[participant.peerId] {
|
||||
switch participant {
|
||||
case .creator:
|
||||
creatorPeer = peer
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
guard let creator = creatorPeer else {
|
||||
return nil
|
||||
}
|
||||
for participant in participants.participants {
|
||||
if let peer = peerView.peers[participant.peerId] {
|
||||
switch participant {
|
||||
case .creator:
|
||||
result.append(RenderedChannelParticipant(participant: .creator(id: peer.id, rank: nil), peer: peer))
|
||||
case .admin:
|
||||
var peers: [PeerId: Peer] = [:]
|
||||
peers[creator.id] = creator
|
||||
peers[peer.id] = peer
|
||||
result.append(RenderedChannelParticipant(participant: .member(id: peer.id, invitedAt: 0, adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(flags: .groupSpecific), promotedBy: creator.id, canBeEditedByAccountPeer: creator.id == context.account.peerId), banInfo: nil, rank: nil), peer: peer, peers: peers))
|
||||
case .member:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}).start(next: { members in
|
||||
adminsPromise.set(.single(members))
|
||||
})
|
||||
let membersAndLoadMoreControl: (Disposable, PeerChannelMemberCategoryControl?) = (membersDisposable, nil)
|
||||
let _ = membersAndLoadMoreControlValue.swap(membersAndLoadMoreControl)
|
||||
membersDisposableValue.set(membersAndLoadMoreControl.0)
|
||||
}
|
||||
}))
|
||||
|
||||
var previousPeers: [RenderedChannelParticipant]?
|
||||
|
||||
let signal = combineLatest(queue: .mainQueue(), presentationDataSignal, statePromise.get(), peerView.get(), adminsPromise.get() |> deliverOnMainQueue)
|
||||
|> deliverOnMainQueue
|
||||
|> map { presentationData, state, view, admins -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
let peerId = view.peerId
|
||||
|
||||
var rightNavigationButton: ItemListNavigationButton?
|
||||
var secondaryRightNavigationButton: ItemListNavigationButton?
|
||||
if let admins = admins, admins.count > 1 {
|
||||
@@ -783,17 +820,33 @@ public func channelAdminsController(context: AccountContext, peerId: PeerId, loa
|
||||
return
|
||||
}
|
||||
|
||||
rebuildControllerStackAfterSupergroupUpgrade(controller: controller, navigationController: navigationController)
|
||||
var replacedSelf = false
|
||||
rebuildControllerStackAfterSupergroupUpgrade(controller: controller, navigationController: navigationController, replace: { c in
|
||||
if c === controller {
|
||||
replacedSelf = true
|
||||
return channelAdminsController(context: context, peerId: upgradedPeerId, loadCompleted: {
|
||||
})
|
||||
} else {
|
||||
return c
|
||||
}
|
||||
})
|
||||
f()
|
||||
}
|
||||
controller.visibleBottomContentOffsetChanged = { offset in
|
||||
if case let .known(value) = offset, value < 40.0 {
|
||||
context.peerChannelMemberCategoriesContextsManager.loadMore(peerId: peerId, control: loadMoreControl)
|
||||
let _ = (currentPeerId.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { peerId in
|
||||
if let loadMoreControl = membersAndLoadMoreControlValue.with({ $0?.1 }) {
|
||||
context.peerChannelMemberCategoriesContextsManager.loadMore(peerId: peerId, control: loadMoreControl)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return controller
|
||||
}
|
||||
|
||||
func rebuildControllerStackAfterSupergroupUpgrade(controller: ViewController, navigationController: NavigationController) {
|
||||
func rebuildControllerStackAfterSupergroupUpgrade(controller: ViewController, navigationController: NavigationController, replace: ((UIViewController) -> UIViewController)? = nil) {
|
||||
var controllers = navigationController.viewControllers
|
||||
for i in 0 ..< controllers.count {
|
||||
if controllers[i] === controller {
|
||||
@@ -806,5 +859,10 @@ func rebuildControllerStackAfterSupergroupUpgrade(controller: ViewController, na
|
||||
break
|
||||
}
|
||||
}
|
||||
for i in 0 ..< controllers.count {
|
||||
if let replace = replace {
|
||||
controllers[i] = replace(controllers[i])
|
||||
}
|
||||
}
|
||||
navigationController.setViewControllers(controllers, animated: false)
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public func groupsInCommonController(context: AccountContext, peerId: PeerId) ->
|
||||
return context.account.postbox.transaction { transaction -> [Peer] in
|
||||
var result: [Peer] = []
|
||||
for id in peerIds {
|
||||
if let peer = transaction.getPeer(id) {
|
||||
if let peer = transaction.getPeer(id.id) {
|
||||
result.append(peer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public final class WriteBuffer: MemoryBuffer {
|
||||
self.offset = 0
|
||||
}
|
||||
|
||||
public func write(_ data: UnsafeRawPointer, offset: Int, length: Int) {
|
||||
public func write(_ data: UnsafeRawPointer, offset: Int = 0, length: Int) {
|
||||
if self.offset + length > self.capacity {
|
||||
self.capacity = self.offset + length + 256
|
||||
if self.length == 0 {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
final class MutableFailedMessageIdsView {
|
||||
let peerId: PeerId
|
||||
var ids: Set<MessageId>
|
||||
|
||||
init(peerId: PeerId, ids: [MessageId]) {
|
||||
self.peerId = peerId
|
||||
self.ids = Set(ids)
|
||||
}
|
||||
func replay(postbox: Postbox, transaction: PostboxTransaction) -> Bool {
|
||||
let ids = transaction.updatedFailedMessageIds.filter { $0.peerId == self.peerId }
|
||||
let updated = ids != self.ids
|
||||
self.ids = ids
|
||||
return updated
|
||||
}
|
||||
|
||||
func immutableView() -> FailedMessageIdsView {
|
||||
return FailedMessageIdsView(self.ids)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final class FailedMessageIdsView {
|
||||
public let ids: Set<MessageId>
|
||||
|
||||
fileprivate init(_ ids: Set<MessageId>) {
|
||||
self.ids = ids
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,9 @@ public enum MediaResourceDataFetchError {
|
||||
}
|
||||
|
||||
public enum CachedMediaResourceRepresentationResult {
|
||||
case reset
|
||||
case data(Data)
|
||||
case done
|
||||
case temporaryPath(String)
|
||||
case tempFile(TempBoxFile)
|
||||
}
|
||||
@@ -107,9 +110,19 @@ private struct CachedMediaResourceRepresentationKey: Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
private final class CachedMediaResourceRepresentationSubscriber {
|
||||
let update: (MediaResourceData) -> Void
|
||||
let onlyComplete: Bool
|
||||
|
||||
init(update: @escaping (MediaResourceData) -> Void, onlyComplete: Bool) {
|
||||
self.update = update
|
||||
self.onlyComplete = onlyComplete
|
||||
}
|
||||
}
|
||||
|
||||
private final class CachedMediaResourceRepresentationContext {
|
||||
var currentData: MediaResourceData?
|
||||
let dataSubscribers = Bag<(MediaResourceData) -> Void>()
|
||||
let dataSubscribers = Bag<CachedMediaResourceRepresentationSubscriber>()
|
||||
let disposable = MetaDisposable()
|
||||
var initialized = false
|
||||
}
|
||||
@@ -191,7 +204,7 @@ public final class MediaBox {
|
||||
return ResourceStorePaths(partial: "\(self.basePath)/\(fileNameForId(id))_partial", complete: "\(self.basePath)/\(fileNameForId(id))")
|
||||
}
|
||||
|
||||
private func cachedRepresentationPathForId(_ id: MediaResourceId, representation: CachedMediaResourceRepresentation) -> String {
|
||||
private func cachedRepresentationPathsForId(_ id: MediaResourceId, representation: CachedMediaResourceRepresentation) -> ResourceStorePaths {
|
||||
let cacheString: String
|
||||
switch representation.keepDuration {
|
||||
case .general:
|
||||
@@ -199,7 +212,7 @@ public final class MediaBox {
|
||||
case .shortLived:
|
||||
cacheString = "short-cache"
|
||||
}
|
||||
return "\(self.basePath)/\(cacheString)/\(fileNameForId(id)):\(representation.uniqueId)"
|
||||
return ResourceStorePaths(partial: "\(self.basePath)/\(cacheString)/\(fileNameForId(id))_partial:\(representation.uniqueId)", complete: "\(self.basePath)/\(cacheString)/\(fileNameForId(id)):\(representation.uniqueId)")
|
||||
}
|
||||
|
||||
public func storeResourceData(_ id: MediaResourceId, data: Data, synchronous: Bool = false) {
|
||||
@@ -662,7 +675,7 @@ public final class MediaBox {
|
||||
|
||||
public func storeCachedResourceRepresentation(_ resource: MediaResource, representation: CachedMediaResourceRepresentation, data: Data) {
|
||||
self.dataQueue.async {
|
||||
let path = self.cachedRepresentationPathForId(resource.id, representation: representation)
|
||||
let path = self.cachedRepresentationPathsForId(resource.id, representation: representation).complete
|
||||
let _ = try? data.write(to: URL(fileURLWithPath: path))
|
||||
}
|
||||
}
|
||||
@@ -672,26 +685,26 @@ public final class MediaBox {
|
||||
let disposable = MetaDisposable()
|
||||
|
||||
let begin: () -> Void = {
|
||||
let path = self.cachedRepresentationPathForId(resource.id, representation: representation)
|
||||
if let size = fileSize(path) {
|
||||
let paths = self.cachedRepresentationPathsForId(resource.id, representation: representation)
|
||||
if let size = fileSize(paths.complete) {
|
||||
self.timeBasedCleanup.touch(paths: [
|
||||
path
|
||||
paths.complete
|
||||
])
|
||||
|
||||
if let pathExtension = pathExtension {
|
||||
let symlinkPath = path + ".\(pathExtension)"
|
||||
let symlinkPath = paths.complete + ".\(pathExtension)"
|
||||
if fileSize(symlinkPath) == nil {
|
||||
let _ = try? FileManager.default.linkItem(atPath: path, toPath: symlinkPath)
|
||||
let _ = try? FileManager.default.linkItem(atPath: paths.complete, toPath: symlinkPath)
|
||||
}
|
||||
subscriber.putNext(MediaResourceData(path: symlinkPath, offset: 0, size: size, complete: true))
|
||||
subscriber.putCompletion()
|
||||
} else {
|
||||
subscriber.putNext(MediaResourceData(path: path, offset: 0, size: size, complete: true))
|
||||
subscriber.putNext(MediaResourceData(path: paths.complete, offset: 0, size: size, complete: true))
|
||||
subscriber.putCompletion()
|
||||
}
|
||||
} else if fetch {
|
||||
if attemptSynchronously && complete {
|
||||
subscriber.putNext(MediaResourceData(path: path, offset: 0, size: 0, complete: false))
|
||||
subscriber.putNext(MediaResourceData(path: paths.partial, offset: 0, size: 0, complete: false))
|
||||
}
|
||||
self.dataQueue.async {
|
||||
let key = CachedMediaResourceRepresentationKey(resourceId: resource.id, representation: representation)
|
||||
@@ -703,7 +716,7 @@ public final class MediaBox {
|
||||
self.cachedRepresentationContexts[key] = context
|
||||
}
|
||||
|
||||
let index = context.dataSubscribers.add(({ data in
|
||||
let index = context.dataSubscribers.add(CachedMediaResourceRepresentationSubscriber(update: { data in
|
||||
if !complete || data.complete {
|
||||
if let pathExtension = pathExtension, data.complete {
|
||||
let symlinkPath = data.path + ".\(pathExtension)"
|
||||
@@ -718,7 +731,7 @@ public final class MediaBox {
|
||||
if data.complete {
|
||||
subscriber.putCompletion()
|
||||
}
|
||||
}))
|
||||
}, onlyComplete: complete))
|
||||
if let currentData = context.currentData {
|
||||
if !complete || currentData.complete {
|
||||
subscriber.putNext(currentData)
|
||||
@@ -727,7 +740,7 @@ public final class MediaBox {
|
||||
subscriber.putCompletion()
|
||||
}
|
||||
} else if !complete {
|
||||
subscriber.putNext(MediaResourceData(path: path, offset: 0, size: 0, complete: false))
|
||||
subscriber.putNext(MediaResourceData(path: paths.partial, offset: 0, size: 0, complete: false))
|
||||
}
|
||||
|
||||
disposable.set(ActionDisposable { [weak context] in
|
||||
@@ -752,32 +765,65 @@ public final class MediaBox {
|
||||
}
|
||||
|> deliverOn(self.dataQueue)
|
||||
context.disposable.set(signal.start(next: { [weak self, weak context] next in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if let next = next {
|
||||
var isDone = false
|
||||
switch next {
|
||||
case let .temporaryPath(temporaryPath):
|
||||
rename(temporaryPath, path)
|
||||
case let .tempFile(tempFile):
|
||||
rename(tempFile.path, path)
|
||||
TempBox.shared.dispose(tempFile)
|
||||
case let .temporaryPath(temporaryPath):
|
||||
rename(temporaryPath, paths.complete)
|
||||
isDone = true
|
||||
case let .tempFile(tempFile):
|
||||
rename(tempFile.path, paths.complete)
|
||||
TempBox.shared.dispose(tempFile)
|
||||
isDone = true
|
||||
case .reset:
|
||||
let file = ManagedFile(queue: strongSelf.dataQueue, path: paths.partial, mode: .readwrite)
|
||||
file?.truncate(count: 0)
|
||||
unlink(paths.complete)
|
||||
case let .data(dataPart):
|
||||
let file = ManagedFile(queue: strongSelf.dataQueue, path: paths.partial, mode: .append)
|
||||
let dataCount = dataPart.count
|
||||
dataPart.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Void in
|
||||
file?.write(bytes, count: dataCount)
|
||||
}
|
||||
case .done:
|
||||
link(paths.partial, paths.complete)
|
||||
isDone = true
|
||||
}
|
||||
|
||||
if let strongSelf = self, let currentContext = strongSelf.cachedRepresentationContexts[key], currentContext === context {
|
||||
currentContext.disposable.dispose()
|
||||
strongSelf.cachedRepresentationContexts.removeValue(forKey: key)
|
||||
if let size = fileSize(path) {
|
||||
let data = MediaResourceData(path: path, offset: 0, size: size, complete: true)
|
||||
if isDone {
|
||||
currentContext.disposable.dispose()
|
||||
strongSelf.cachedRepresentationContexts.removeValue(forKey: key)
|
||||
}
|
||||
if let size = fileSize(paths.complete) {
|
||||
let data = MediaResourceData(path: paths.complete, offset: 0, size: size, complete: isDone)
|
||||
currentContext.currentData = data
|
||||
for subscriber in currentContext.dataSubscribers.copyItems() {
|
||||
subscriber(data)
|
||||
if !subscriber.onlyComplete || isDone {
|
||||
subscriber.update(data)
|
||||
}
|
||||
}
|
||||
} else if let size = fileSize(paths.partial) {
|
||||
let data = MediaResourceData(path: paths.partial, offset: 0, size: size, complete: isDone)
|
||||
currentContext.currentData = data
|
||||
for subscriber in currentContext.dataSubscribers.copyItems() {
|
||||
if !subscriber.onlyComplete || isDone {
|
||||
subscriber.update(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let strongSelf = self, let context = strongSelf.cachedRepresentationContexts[key] {
|
||||
let data = MediaResourceData(path: path, offset: 0, size: 0, complete: false)
|
||||
let data = MediaResourceData(path: paths.partial, offset: 0, size: 0, complete: false)
|
||||
context.currentData = data
|
||||
for subscriber in context.dataSubscribers.copyItems() {
|
||||
subscriber(data)
|
||||
if !subscriber.onlyComplete {
|
||||
subscriber.update(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -785,7 +831,7 @@ public final class MediaBox {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
subscriber.putNext(MediaResourceData(path: path, offset: 0, size: 0, complete: false))
|
||||
subscriber.putNext(MediaResourceData(path: paths.partial, offset: 0, size: 0, complete: false))
|
||||
subscriber.putCompletion()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ final class MessageHistoryFailedTable: Table {
|
||||
private let sharedKey = ValueBoxKey(length: 8 + 4 + 4)
|
||||
|
||||
private(set) var updatedPeerIds = Set<PeerId>()
|
||||
|
||||
private(set) var updatedMessageIds = Set<MessageId>()
|
||||
|
||||
private func key(_ id: MessageId) -> ValueBoxKey {
|
||||
self.sharedKey.setInt64(0, value: id.peerId.toInt64())
|
||||
self.sharedKey.setInt32(8, value: id.namespace)
|
||||
@@ -32,11 +33,30 @@ final class MessageHistoryFailedTable: Table {
|
||||
func add(_ id: MessageId) {
|
||||
self.valueBox.set(self.table, key: self.key(id), value: MemoryBuffer())
|
||||
self.updatedPeerIds.insert(id.peerId)
|
||||
self.updatedMessageIds.insert(id)
|
||||
}
|
||||
|
||||
func remove(_ id: MessageId) {
|
||||
self.valueBox.remove(self.table, key: self.key(id), secure: false)
|
||||
self.updatedPeerIds.insert(id.peerId)
|
||||
self.updatedMessageIds.remove(id)
|
||||
}
|
||||
|
||||
func get(peerId:PeerId) -> [MessageId] {
|
||||
var ids:[MessageId] = []
|
||||
self.valueBox.range(self.table, start: self.lowerBound(peerId: peerId), end: self.upperBound(peerId: peerId), keys: { key in
|
||||
|
||||
let peerId = PeerId(key.getInt64(0))
|
||||
let namespace = key.getInt32(8)
|
||||
let id = key.getInt32(8 + 4)
|
||||
ids.append(MessageId(peerId: peerId, namespace: namespace, id: id))
|
||||
|
||||
return false
|
||||
}, limit: 100)
|
||||
|
||||
self.updatedMessageIds = self.updatedMessageIds.union(ids)
|
||||
|
||||
return ids
|
||||
}
|
||||
|
||||
func contains(peerId: PeerId) -> Bool {
|
||||
|
||||
@@ -420,26 +420,29 @@ final class MutableMessageHistoryView {
|
||||
break
|
||||
}
|
||||
}
|
||||
if addCount == 2 && removeCount == 2 {
|
||||
assert(true)
|
||||
}
|
||||
for operation in operationSet {
|
||||
switch operation {
|
||||
case let .InsertMessage(message):
|
||||
if unwrappedTag.isEmpty || message.tags.contains(unwrappedTag) {
|
||||
if loadedState.add(entry: .IntermediateMessageEntry(message, nil, nil)) {
|
||||
hasChanges = true
|
||||
if self.namespaces.contains(message.id.namespace) {
|
||||
if loadedState.add(entry: .IntermediateMessageEntry(message, nil, nil)) {
|
||||
hasChanges = true
|
||||
}
|
||||
}
|
||||
}
|
||||
case let .Remove(indicesAndTags):
|
||||
for (index, _) in indicesAndTags {
|
||||
if loadedState.remove(index: index) {
|
||||
hasChanges = true
|
||||
if self.namespaces.contains(index.id.namespace) {
|
||||
if loadedState.remove(index: index) {
|
||||
hasChanges = true
|
||||
}
|
||||
}
|
||||
}
|
||||
case let .UpdateEmbeddedMedia(index, buffer):
|
||||
if loadedState.updateEmbeddedMedia(index: index, buffer: buffer) {
|
||||
hasChanges = true
|
||||
if self.namespaces.contains(index.id.namespace) {
|
||||
if loadedState.updateEmbeddedMedia(index: index, buffer: buffer) {
|
||||
hasChanges = true
|
||||
}
|
||||
}
|
||||
case let .UpdateGroupInfos(groupInfos):
|
||||
if loadedState.updateGroupInfo(mapping: groupInfos) {
|
||||
|
||||
@@ -107,6 +107,14 @@ public final class Transaction {
|
||||
return []
|
||||
}
|
||||
}
|
||||
public func failedMessageIds(for peerId: PeerId) -> [MessageId] {
|
||||
assert(!self.disposed)
|
||||
if let postbox = self.postbox {
|
||||
return postbox.failedMessageIds(for: peerId)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
public func deleteMessagesWithGlobalIds(_ ids: [Int32], forEachMedia: (Media) -> Void) {
|
||||
assert(!self.disposed)
|
||||
@@ -1703,7 +1711,7 @@ public final class Postbox {
|
||||
let transactionParticipationInTotalUnreadCountUpdates = self.peerNotificationSettingsTable.transactionParticipationInTotalUnreadCountUpdates(postbox: self)
|
||||
self.chatListIndexTable.commitWithTransaction(postbox: self, alteredInitialPeerCombinedReadStates: alteredInitialPeerCombinedReadStates, updatedPeers: updatedPeers, transactionParticipationInTotalUnreadCountUpdates: transactionParticipationInTotalUnreadCountUpdates, updatedRootUnreadState: &self.currentUpdatedTotalUnreadState, updatedGroupTotalUnreadSummaries: &self.currentUpdatedGroupTotalUnreadSummaries, currentUpdatedGroupSummarySynchronizeOperations: &self.currentUpdatedGroupSummarySynchronizeOperations)
|
||||
|
||||
let transaction = PostboxTransaction(currentUpdatedState: self.currentUpdatedState, currentPeerHoleOperations: self.currentPeerHoleOperations, currentOperationsByPeerId: self.currentOperationsByPeerId, chatListOperations: self.currentChatListOperations, currentUpdatedChatListInclusions: self.currentUpdatedChatListInclusions, currentUpdatedPeers: self.currentUpdatedPeers, currentUpdatedPeerNotificationSettings: self.currentUpdatedPeerNotificationSettings, currentUpdatedPeerNotificationBehaviorTimestamps: self.currentUpdatedPeerNotificationBehaviorTimestamps, currentUpdatedCachedPeerData: self.currentUpdatedCachedPeerData, currentUpdatedPeerPresences: currentUpdatedPeerPresences, currentUpdatedPeerChatListEmbeddedStates: self.currentUpdatedPeerChatListEmbeddedStates, currentUpdatedTotalUnreadState: self.currentUpdatedTotalUnreadState, currentUpdatedTotalUnreadSummaries: self.currentUpdatedGroupTotalUnreadSummaries, alteredInitialPeerCombinedReadStates: alteredInitialPeerCombinedReadStates, currentPeerMergedOperationLogOperations: self.currentPeerMergedOperationLogOperations, currentTimestampBasedMessageAttributesOperations: self.currentTimestampBasedMessageAttributesOperations, unsentMessageOperations: self.currentUnsentOperations, updatedSynchronizePeerReadStateOperations: self.currentUpdatedSynchronizeReadStateOperations, currentUpdatedGroupSummarySynchronizeOperations: self.currentUpdatedGroupSummarySynchronizeOperations, currentPreferencesOperations: self.currentPreferencesOperations, currentOrderedItemListOperations: self.currentOrderedItemListOperations, currentItemCollectionItemsOperations: self.currentItemCollectionItemsOperations, currentItemCollectionInfosOperations: self.currentItemCollectionInfosOperations, currentUpdatedPeerChatStates: self.currentUpdatedPeerChatStates, currentGlobalTagsOperations: self.currentGlobalTagsOperations, currentLocalTagsOperations: self.currentLocalTagsOperations, updatedMedia: self.currentUpdatedMedia, replaceRemoteContactCount: self.currentReplaceRemoteContactCount, replaceContactPeerIds: self.currentReplacedContactPeerIds, currentPendingMessageActionsOperations: self.currentPendingMessageActionsOperations, currentUpdatedMessageActionsSummaries: self.currentUpdatedMessageActionsSummaries, currentUpdatedMessageTagSummaries: self.currentUpdatedMessageTagSummaries, currentInvalidateMessageTagSummaries: self.currentInvalidateMessageTagSummaries, currentUpdatedPendingPeerNotificationSettings: self.currentUpdatedPendingPeerNotificationSettings, replacedAdditionalChatListItems: self.currentReplacedAdditionalChatListItems, updatedNoticeEntryKeys: self.currentUpdatedNoticeEntryKeys, updatedCacheEntryKeys: self.currentUpdatedCacheEntryKeys, currentUpdatedMasterClientId: currentUpdatedMasterClientId, updatedFailedMessagePeerIds: self.messageHistoryFailedTable.updatedPeerIds)
|
||||
let transaction = PostboxTransaction(currentUpdatedState: self.currentUpdatedState, currentPeerHoleOperations: self.currentPeerHoleOperations, currentOperationsByPeerId: self.currentOperationsByPeerId, chatListOperations: self.currentChatListOperations, currentUpdatedChatListInclusions: self.currentUpdatedChatListInclusions, currentUpdatedPeers: self.currentUpdatedPeers, currentUpdatedPeerNotificationSettings: self.currentUpdatedPeerNotificationSettings, currentUpdatedPeerNotificationBehaviorTimestamps: self.currentUpdatedPeerNotificationBehaviorTimestamps, currentUpdatedCachedPeerData: self.currentUpdatedCachedPeerData, currentUpdatedPeerPresences: currentUpdatedPeerPresences, currentUpdatedPeerChatListEmbeddedStates: self.currentUpdatedPeerChatListEmbeddedStates, currentUpdatedTotalUnreadState: self.currentUpdatedTotalUnreadState, currentUpdatedTotalUnreadSummaries: self.currentUpdatedGroupTotalUnreadSummaries, alteredInitialPeerCombinedReadStates: alteredInitialPeerCombinedReadStates, currentPeerMergedOperationLogOperations: self.currentPeerMergedOperationLogOperations, currentTimestampBasedMessageAttributesOperations: self.currentTimestampBasedMessageAttributesOperations, unsentMessageOperations: self.currentUnsentOperations, updatedSynchronizePeerReadStateOperations: self.currentUpdatedSynchronizeReadStateOperations, currentUpdatedGroupSummarySynchronizeOperations: self.currentUpdatedGroupSummarySynchronizeOperations, currentPreferencesOperations: self.currentPreferencesOperations, currentOrderedItemListOperations: self.currentOrderedItemListOperations, currentItemCollectionItemsOperations: self.currentItemCollectionItemsOperations, currentItemCollectionInfosOperations: self.currentItemCollectionInfosOperations, currentUpdatedPeerChatStates: self.currentUpdatedPeerChatStates, currentGlobalTagsOperations: self.currentGlobalTagsOperations, currentLocalTagsOperations: self.currentLocalTagsOperations, updatedMedia: self.currentUpdatedMedia, replaceRemoteContactCount: self.currentReplaceRemoteContactCount, replaceContactPeerIds: self.currentReplacedContactPeerIds, currentPendingMessageActionsOperations: self.currentPendingMessageActionsOperations, currentUpdatedMessageActionsSummaries: self.currentUpdatedMessageActionsSummaries, currentUpdatedMessageTagSummaries: self.currentUpdatedMessageTagSummaries, currentInvalidateMessageTagSummaries: self.currentInvalidateMessageTagSummaries, currentUpdatedPendingPeerNotificationSettings: self.currentUpdatedPendingPeerNotificationSettings, replacedAdditionalChatListItems: self.currentReplacedAdditionalChatListItems, updatedNoticeEntryKeys: self.currentUpdatedNoticeEntryKeys, updatedCacheEntryKeys: self.currentUpdatedCacheEntryKeys, currentUpdatedMasterClientId: currentUpdatedMasterClientId, updatedFailedMessagePeerIds: self.messageHistoryFailedTable.updatedPeerIds, updatedFailedMessageIds: self.messageHistoryFailedTable.updatedMessageIds)
|
||||
var updatedTransactionState: Int64?
|
||||
var updatedMasterClientId: Int64?
|
||||
if !transaction.isEmpty {
|
||||
@@ -1772,6 +1780,9 @@ public final class Postbox {
|
||||
}
|
||||
return result
|
||||
}
|
||||
fileprivate func failedMessageIds(for peerId: PeerId) -> [MessageId] {
|
||||
return self.messageHistoryFailedTable.get(peerId: peerId)
|
||||
}
|
||||
|
||||
fileprivate func messageIdForGloballyUniqueMessageId(peerId: PeerId, id: Int64) -> MessageId? {
|
||||
return self.globallyUniqueMessageIdsTable.get(peerId: peerId, globallyUniqueId: id)
|
||||
@@ -3185,4 +3196,25 @@ public final class Postbox {
|
||||
self.currentUpdatedGroupTotalUnreadSummaries[groupId] = summary
|
||||
}
|
||||
}
|
||||
|
||||
public func failedMessageIdsView(peerId: PeerId) -> Signal<FailedMessageIdsView, NoError> {
|
||||
return self.transactionSignal { subscriber, transaction in
|
||||
let view = MutableFailedMessageIdsView(peerId: peerId, ids: self.failedMessageIds(for: peerId))
|
||||
let (index, signal) = self.viewTracker.addFailedMessageIdsView(view)
|
||||
subscriber.putNext(view.immutableView())
|
||||
let disposable = signal.start(next: { next in
|
||||
subscriber.putNext(next)
|
||||
})
|
||||
|
||||
return ActionDisposable { [weak self] in
|
||||
disposable.dispose()
|
||||
if let strongSelf = self {
|
||||
strongSelf.queue.async {
|
||||
strongSelf.viewTracker.removeFailedMessageIdsView(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ final class PostboxTransaction {
|
||||
let updatedNoticeEntryKeys: Set<NoticeEntryKey>
|
||||
let updatedCacheEntryKeys: Set<ItemCacheEntryId>
|
||||
let updatedFailedMessagePeerIds: Set<PeerId>
|
||||
let updatedFailedMessageIds: Set<MessageId>
|
||||
|
||||
|
||||
|
||||
var isEmpty: Bool {
|
||||
if currentUpdatedState != nil {
|
||||
@@ -163,10 +166,13 @@ final class PostboxTransaction {
|
||||
if !updatedFailedMessagePeerIds.isEmpty {
|
||||
return false
|
||||
}
|
||||
if !updatedFailedMessageIds.isEmpty {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
init(currentUpdatedState: PostboxCoding?, currentPeerHoleOperations: [MessageHistoryIndexHoleOperationKey: [MessageHistoryIndexHoleOperation]] = [:], currentOperationsByPeerId: [PeerId: [MessageHistoryOperation]], chatListOperations: [PeerGroupId: [ChatListOperation]], currentUpdatedChatListInclusions: [PeerId: PeerChatListInclusion], currentUpdatedPeers: [PeerId: Peer], currentUpdatedPeerNotificationSettings: [PeerId: PeerNotificationSettings], currentUpdatedPeerNotificationBehaviorTimestamps: [PeerId: PeerNotificationSettingsBehaviorTimestamp], currentUpdatedCachedPeerData: [PeerId: CachedPeerData], currentUpdatedPeerPresences: [PeerId: PeerPresence], currentUpdatedPeerChatListEmbeddedStates: [PeerId: PeerChatListEmbeddedInterfaceState?], currentUpdatedTotalUnreadState: ChatListTotalUnreadState?, currentUpdatedTotalUnreadSummaries: [PeerGroupId: PeerGroupUnreadCountersCombinedSummary], alteredInitialPeerCombinedReadStates: [PeerId: CombinedPeerReadState], currentPeerMergedOperationLogOperations: [PeerMergedOperationLogOperation], currentTimestampBasedMessageAttributesOperations: [TimestampBasedMessageAttributesOperation], unsentMessageOperations: [IntermediateMessageHistoryUnsentOperation], updatedSynchronizePeerReadStateOperations: [PeerId: PeerReadStateSynchronizationOperation?], currentUpdatedGroupSummarySynchronizeOperations: [PeerGroupAndNamespace: Bool], currentPreferencesOperations: [PreferencesOperation], currentOrderedItemListOperations: [Int32: [OrderedItemListOperation]], currentItemCollectionItemsOperations: [ItemCollectionId: [ItemCollectionItemsOperation]], currentItemCollectionInfosOperations: [ItemCollectionInfosOperation], currentUpdatedPeerChatStates: Set<PeerId>, currentGlobalTagsOperations: [GlobalMessageHistoryTagsOperation], currentLocalTagsOperations: [IntermediateMessageHistoryLocalTagsOperation], updatedMedia: [MediaId: Media?], replaceRemoteContactCount: Int32?, replaceContactPeerIds: Set<PeerId>?, currentPendingMessageActionsOperations: [PendingMessageActionsOperation], currentUpdatedMessageActionsSummaries: [PendingMessageActionsSummaryKey: Int32], currentUpdatedMessageTagSummaries: [MessageHistoryTagsSummaryKey: MessageHistoryTagNamespaceSummary], currentInvalidateMessageTagSummaries: [InvalidatedMessageHistoryTagsSummaryEntryOperation], currentUpdatedPendingPeerNotificationSettings: Set<PeerId>, replacedAdditionalChatListItems: [PeerId]?, updatedNoticeEntryKeys: Set<NoticeEntryKey>, updatedCacheEntryKeys: Set<ItemCacheEntryId>, currentUpdatedMasterClientId: Int64?, updatedFailedMessagePeerIds: Set<PeerId>) {
|
||||
init(currentUpdatedState: PostboxCoding?, currentPeerHoleOperations: [MessageHistoryIndexHoleOperationKey: [MessageHistoryIndexHoleOperation]] = [:], currentOperationsByPeerId: [PeerId: [MessageHistoryOperation]], chatListOperations: [PeerGroupId: [ChatListOperation]], currentUpdatedChatListInclusions: [PeerId: PeerChatListInclusion], currentUpdatedPeers: [PeerId: Peer], currentUpdatedPeerNotificationSettings: [PeerId: PeerNotificationSettings], currentUpdatedPeerNotificationBehaviorTimestamps: [PeerId: PeerNotificationSettingsBehaviorTimestamp], currentUpdatedCachedPeerData: [PeerId: CachedPeerData], currentUpdatedPeerPresences: [PeerId: PeerPresence], currentUpdatedPeerChatListEmbeddedStates: [PeerId: PeerChatListEmbeddedInterfaceState?], currentUpdatedTotalUnreadState: ChatListTotalUnreadState?, currentUpdatedTotalUnreadSummaries: [PeerGroupId: PeerGroupUnreadCountersCombinedSummary], alteredInitialPeerCombinedReadStates: [PeerId: CombinedPeerReadState], currentPeerMergedOperationLogOperations: [PeerMergedOperationLogOperation], currentTimestampBasedMessageAttributesOperations: [TimestampBasedMessageAttributesOperation], unsentMessageOperations: [IntermediateMessageHistoryUnsentOperation], updatedSynchronizePeerReadStateOperations: [PeerId: PeerReadStateSynchronizationOperation?], currentUpdatedGroupSummarySynchronizeOperations: [PeerGroupAndNamespace: Bool], currentPreferencesOperations: [PreferencesOperation], currentOrderedItemListOperations: [Int32: [OrderedItemListOperation]], currentItemCollectionItemsOperations: [ItemCollectionId: [ItemCollectionItemsOperation]], currentItemCollectionInfosOperations: [ItemCollectionInfosOperation], currentUpdatedPeerChatStates: Set<PeerId>, currentGlobalTagsOperations: [GlobalMessageHistoryTagsOperation], currentLocalTagsOperations: [IntermediateMessageHistoryLocalTagsOperation], updatedMedia: [MediaId: Media?], replaceRemoteContactCount: Int32?, replaceContactPeerIds: Set<PeerId>?, currentPendingMessageActionsOperations: [PendingMessageActionsOperation], currentUpdatedMessageActionsSummaries: [PendingMessageActionsSummaryKey: Int32], currentUpdatedMessageTagSummaries: [MessageHistoryTagsSummaryKey: MessageHistoryTagNamespaceSummary], currentInvalidateMessageTagSummaries: [InvalidatedMessageHistoryTagsSummaryEntryOperation], currentUpdatedPendingPeerNotificationSettings: Set<PeerId>, replacedAdditionalChatListItems: [PeerId]?, updatedNoticeEntryKeys: Set<NoticeEntryKey>, updatedCacheEntryKeys: Set<ItemCacheEntryId>, currentUpdatedMasterClientId: Int64?, updatedFailedMessagePeerIds: Set<PeerId>, updatedFailedMessageIds: Set<MessageId>) {
|
||||
self.currentUpdatedState = currentUpdatedState
|
||||
self.currentPeerHoleOperations = currentPeerHoleOperations
|
||||
self.currentOperationsByPeerId = currentOperationsByPeerId
|
||||
@@ -206,5 +212,6 @@ final class PostboxTransaction {
|
||||
self.updatedNoticeEntryKeys = updatedNoticeEntryKeys
|
||||
self.updatedCacheEntryKeys = updatedCacheEntryKeys
|
||||
self.updatedFailedMessagePeerIds = updatedFailedMessagePeerIds
|
||||
self.updatedFailedMessageIds = updatedFailedMessageIds
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,10 @@ final class ViewTracker {
|
||||
private var multiplePeersViews = Bag<(MutableMultiplePeersView, ValuePipe<MultiplePeersView>)>()
|
||||
private var itemCollectionsViews = Bag<(MutableItemCollectionsView, ValuePipe<ItemCollectionsView>)>()
|
||||
|
||||
|
||||
private var failedMessageIdsViews = Bag<(MutableFailedMessageIdsView, ValuePipe<FailedMessageIdsView>)>()
|
||||
|
||||
|
||||
init(queue: Queue, renderMessage: @escaping (IntermediateMessage) -> Message, getPeer: @escaping (PeerId) -> Peer?, getPeerNotificationSettings: @escaping (PeerId) -> PeerNotificationSettings?, getCachedPeerData: @escaping (PeerId) -> CachedPeerData?, getPeerPresence: @escaping (PeerId) -> PeerPresence?, getTotalUnreadState: @escaping () -> ChatListTotalUnreadState, getPeerReadState: @escaping (PeerId) -> CombinedPeerReadState?, operationLogGetOperations: @escaping (PeerOperationLogTag, Int32, Int) -> [PeerMergedOperationLogEntry], operationLogGetTailIndex: @escaping (PeerOperationLogTag) -> Int32?, getTimestampBasedMessageAttributesHead: @escaping (UInt16) -> TimestampBasedMessageAttributesEntry?, getPreferencesEntry: @escaping (ValueBoxKey) -> PreferencesEntry?, unsentMessageIds: [MessageId], synchronizePeerReadStateOperations: [PeerId: PeerReadStateSynchronizationOperation]) {
|
||||
self.queue = queue
|
||||
self.renderMessage = renderMessage
|
||||
@@ -438,6 +442,12 @@ final class ViewTracker {
|
||||
pipe.putNext(mutableView.immutableView())
|
||||
}
|
||||
}
|
||||
|
||||
for (view, pipe) in self.failedMessageIdsViews.copyItems() {
|
||||
if view.replay(postbox: postbox, transaction: transaction) {
|
||||
pipe.putNext(view.immutableView())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func updateTrackedChatListHoles() {
|
||||
@@ -584,4 +594,17 @@ final class ViewTracker {
|
||||
return disposable
|
||||
}
|
||||
}
|
||||
|
||||
func addFailedMessageIdsView(_ view: MutableFailedMessageIdsView) -> (Bag<(MutableFailedMessageIdsView, ValuePipe<FailedMessageIdsView>)>.Index, Signal<FailedMessageIdsView, NoError>) {
|
||||
let record = (view, ValuePipe<FailedMessageIdsView>())
|
||||
let index = self.failedMessageIdsViews.add(record)
|
||||
|
||||
return (index, record.1.signal())
|
||||
}
|
||||
|
||||
func removeFailedMessageIdsView(_ index: Bag<(MutableFailedMessageIdsView, ValuePipe<PeerId?>)>.Index) {
|
||||
self.failedMessageIdsViews.remove(index)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import TextFormat
|
||||
import AccountContext
|
||||
import StickerPackPreviewUI
|
||||
import ItemListStickerPackItem
|
||||
import UndoUI
|
||||
|
||||
private final class InstalledStickerPacksControllerArguments {
|
||||
let account: Account
|
||||
@@ -494,6 +495,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
||||
let archivedPromise = Promise<[ArchivedStickerPackItem]?>()
|
||||
|
||||
var presentStickerPackController: ((StickerPackCollectionInfo) -> Void)?
|
||||
var navigationControllerImpl: (() -> NavigationController?)?
|
||||
|
||||
let arguments = InstalledStickerPacksControllerArguments(account: context.account, openStickerPack: { info in
|
||||
presentStickerPackController?(info)
|
||||
@@ -511,6 +513,31 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
||||
let dismissAction: () -> Void = { [weak controller] in
|
||||
controller?.dismissAnimated()
|
||||
}
|
||||
let removeAction: (RemoveStickerPackOption) -> Void = { action in
|
||||
let _ = (removeStickerPackInteractively(postbox: context.account.postbox, id: archivedItem.info.id, option: .archive)
|
||||
|> deliverOnMainQueue).start(next: { indexAndItems in
|
||||
guard let (positionInList, items) = indexAndItems else {
|
||||
return
|
||||
}
|
||||
|
||||
var animateInAsReplacement = false
|
||||
if let navigationController = navigationControllerImpl?() {
|
||||
for controller in navigationController.overlayControllers {
|
||||
if let controller = controller as? UndoOverlayController {
|
||||
controller.dismissWithCommitActionAndReplacementAnimation()
|
||||
animateInAsReplacement = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
navigationControllerImpl?()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_RemovedTitle, text: presentationData.strings.StickerPackActionInfo_RemovedText(archivedItem.info.title).0, undo: true, info: archivedItem.info, topItem: archivedItem.topItems.first, account: context.account), elevatedLayout: true, animateInAsReplacement: animateInAsReplacement, action: { action in
|
||||
if case .undo = action {
|
||||
let _ = addStickerPackInteractively(postbox: context.account.postbox, info: archivedItem.info, items: items, positionInList: positionInList).start()
|
||||
}
|
||||
return true
|
||||
}))
|
||||
})
|
||||
}
|
||||
controller.setItemGroups([
|
||||
ActionSheetItemGroup(items: [
|
||||
ActionSheetTextItem(title: presentationData.strings.StickerSettings_ContextInfo),
|
||||
@@ -524,12 +551,12 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
||||
archivedPromise.set(.single(packs))
|
||||
updatedPacks(packs)
|
||||
})
|
||||
|
||||
let _ = removeStickerPackInteractively(postbox: context.account.postbox, id: archivedItem.info.id, option: .archive).start()
|
||||
|
||||
removeAction(.archive)
|
||||
}),
|
||||
ActionSheetButtonItem(title: presentationData.strings.Common_Delete, color: .destructive, action: {
|
||||
dismissAction()
|
||||
let _ = removeStickerPackInteractively(postbox: context.account.postbox, id: archivedItem.info.id, option: .delete).start()
|
||||
removeAction(.delete)
|
||||
})
|
||||
]),
|
||||
ActionSheetItemGroup(items: [ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, action: { dismissAction() })])
|
||||
@@ -800,10 +827,37 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
||||
packs.insert(packReference, at: 0)
|
||||
}
|
||||
if let mainStickerPack = mainStickerPack {
|
||||
presentControllerImpl?(StickerPackScreen(context: context, mainStickerPack: mainStickerPack, stickerPacks: packs, parentNavigationController: controller?.navigationController as? NavigationController), nil)
|
||||
presentControllerImpl?(StickerPackScreen(context: context, mainStickerPack: mainStickerPack, stickerPacks: packs, parentNavigationController: controller?.navigationController as? NavigationController, actionPerformed: { info, items, action in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
var animateInAsReplacement = false
|
||||
if let navigationController = navigationControllerImpl?() {
|
||||
for controller in navigationController.overlayControllers {
|
||||
if let controller = controller as? UndoOverlayController {
|
||||
controller.dismissWithCommitActionAndReplacementAnimation()
|
||||
animateInAsReplacement = true
|
||||
}
|
||||
}
|
||||
}
|
||||
switch action {
|
||||
case .add:
|
||||
navigationControllerImpl?()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, account: context.account), elevatedLayout: true, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
return true
|
||||
}))
|
||||
case let .remove(positionInList):
|
||||
navigationControllerImpl?()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_RemovedTitle, text: presentationData.strings.StickerPackActionInfo_RemovedText(info.title).0, undo: true, info: info, topItem: items.first, account: context.account), elevatedLayout: true, animateInAsReplacement: animateInAsReplacement, action: { action in
|
||||
if case .undo = action {
|
||||
let _ = addStickerPackInteractively(postbox: context.account.postbox, info: info, items: items, positionInList: positionInList).start()
|
||||
}
|
||||
return true
|
||||
}))
|
||||
}
|
||||
}), nil)
|
||||
}
|
||||
})
|
||||
}
|
||||
navigationControllerImpl = { [weak controller] in
|
||||
return controller?.navigationController as? NavigationController
|
||||
}
|
||||
pushControllerImpl = { [weak controller] c in
|
||||
(controller?.navigationController as? NavigationController)?.pushViewController(c)
|
||||
}
|
||||
|
||||
@@ -63,10 +63,13 @@ public final class StickerPackPreviewController: ViewController, StandalonePrese
|
||||
}
|
||||
}
|
||||
|
||||
public init(context: AccountContext, stickerPack: StickerPackReference, mode: StickerPackPreviewControllerMode = .default, parentNavigationController: NavigationController?) {
|
||||
private let actionPerformed: ((StickerPackCollectionInfo, [ItemCollectionItem], StickerPackScreenPerformedAction) -> Void)?
|
||||
|
||||
public init(context: AccountContext, stickerPack: StickerPackReference, mode: StickerPackPreviewControllerMode = .default, parentNavigationController: NavigationController?, actionPerformed: ((StickerPackCollectionInfo, [ItemCollectionItem], StickerPackScreenPerformedAction) -> Void)? = nil) {
|
||||
self.context = context
|
||||
self.mode = mode
|
||||
self.parentNavigationController = parentNavigationController
|
||||
self.actionPerformed = actionPerformed
|
||||
|
||||
self.stickerPack = stickerPack
|
||||
|
||||
@@ -133,7 +136,7 @@ public final class StickerPackPreviewController: ViewController, StandalonePrese
|
||||
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: parentNavigationController, context: strongSelf.context, chatLocation: .peer(peer.id), animated: true))
|
||||
}
|
||||
}))
|
||||
})
|
||||
}, actionPerformed: self.actionPerformed)
|
||||
self.controllerNode.dismiss = { [weak self] in
|
||||
self?.presentingViewController?.dismiss(animated: false, completion: nil)
|
||||
}
|
||||
@@ -163,8 +166,28 @@ public final class StickerPackPreviewController: ViewController, StandalonePrese
|
||||
}
|
||||
|
||||
switch next {
|
||||
case let .result(_, items, _):
|
||||
case let .result(info, items, _):
|
||||
var preloadSignals: [Signal<Bool, NoError>] = []
|
||||
|
||||
if let thumbnail = info.thumbnail {
|
||||
let signal = Signal<Bool, NoError> { subscriber in
|
||||
let fetched = fetchedMediaResource(mediaBox: account.postbox.mediaBox, reference: .stickerPackThumbnail(stickerPack: .id(id: info.id.id, accessHash: info.accessHash), resource: thumbnail.resource)).start()
|
||||
let data = account.postbox.mediaBox.resourceData(thumbnail.resource, option: .incremental(waitUntilFetchStatus: false)).start(next: { data in
|
||||
if data.complete {
|
||||
subscriber.putNext(true)
|
||||
subscriber.putCompletion()
|
||||
} else {
|
||||
subscriber.putNext(false)
|
||||
}
|
||||
})
|
||||
return ActionDisposable {
|
||||
fetched.dispose()
|
||||
data.dispose()
|
||||
}
|
||||
}
|
||||
preloadSignals.append(signal)
|
||||
}
|
||||
|
||||
let topItems = items.prefix(16)
|
||||
for item in topItems {
|
||||
if let item = item as? StickerPackItem, item.file.isAnimatedSticker {
|
||||
|
||||
@@ -74,6 +74,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
||||
var dismiss: (() -> Void)?
|
||||
var cancel: (() -> Void)?
|
||||
var sendSticker: ((FileMediaReference, ASDisplayNode, CGRect) -> Bool)?
|
||||
private let actionPerformed: ((StickerPackCollectionInfo, [ItemCollectionItem], StickerPackScreenPerformedAction) -> Void)?
|
||||
|
||||
let ready = Promise<Bool>()
|
||||
private var didSetReady = false
|
||||
@@ -87,10 +88,11 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
||||
|
||||
private var hapticFeedback: HapticFeedback?
|
||||
|
||||
init(context: AccountContext, openShare: (() -> Void)?, openMention: @escaping (String) -> Void) {
|
||||
init(context: AccountContext, openShare: (() -> Void)?, openMention: @escaping (String) -> Void, actionPerformed: ((StickerPackCollectionInfo, [ItemCollectionItem], StickerPackScreenPerformedAction) -> Void)?) {
|
||||
self.context = context
|
||||
self.openShare = openShare
|
||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
self.actionPerformed = actionPerformed
|
||||
|
||||
self.wrappingScrollNode = ASScrollNode()
|
||||
self.wrappingScrollNode.view.alwaysBounceVertical = true
|
||||
@@ -509,23 +511,27 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
||||
}
|
||||
|
||||
@objc func installActionButtonPressed() {
|
||||
let dismissOnAction: Bool
|
||||
if let initiallyInstalled = self.stickerPackInitiallyInstalled, initiallyInstalled {
|
||||
dismissOnAction = false
|
||||
} else {
|
||||
dismissOnAction = true
|
||||
}
|
||||
let dismissOnAction = true
|
||||
if let stickerPack = self.stickerPack, let stickerSettings = self.stickerSettings {
|
||||
switch stickerPack {
|
||||
case let .result(info, items, installed):
|
||||
if installed {
|
||||
let _ = removeStickerPackInteractively(postbox: self.context.account.postbox, id: info.id, option: .delete).start()
|
||||
self.updateStickerPack(.result(info: info, items: items, installed: false), stickerSettings: stickerSettings)
|
||||
let _ = (removeStickerPackInteractively(postbox: self.context.account.postbox, id: info.id, option: .delete)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] indexAndItems in
|
||||
guard let strongSelf = self, let (positionInList, _) = indexAndItems else {
|
||||
return
|
||||
}
|
||||
strongSelf.actionPerformed?(info, items, .remove(positionInList: positionInList))
|
||||
})
|
||||
if !dismissOnAction {
|
||||
self.updateStickerPack(.result(info: info, items: items, installed: false), stickerSettings: stickerSettings)
|
||||
}
|
||||
} else {
|
||||
let _ = addStickerPackInteractively(postbox: self.context.account.postbox, info: info, items: items).start()
|
||||
if !dismissOnAction {
|
||||
self.updateStickerPack(.result(info: info, items: items, installed: true), stickerSettings: stickerSettings)
|
||||
}
|
||||
self.actionPerformed?(info, items, .add)
|
||||
}
|
||||
if dismissOnAction {
|
||||
self.cancelButtonPressed()
|
||||
|
||||
@@ -842,8 +842,13 @@ public final class StickerPackScreenImpl: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
public func StickerPackScreen(context: AccountContext, mainStickerPack: StickerPackReference, stickerPacks: [StickerPackReference], parentNavigationController: NavigationController? = nil, sendSticker: ((FileMediaReference, ASDisplayNode, CGRect) -> Bool)? = nil) -> ViewController {
|
||||
let controller = StickerPackPreviewController(context: context, stickerPack: mainStickerPack, mode: .default, parentNavigationController: parentNavigationController)
|
||||
public enum StickerPackScreenPerformedAction {
|
||||
case add
|
||||
case remove(positionInList: Int)
|
||||
}
|
||||
|
||||
public func StickerPackScreen(context: AccountContext, mainStickerPack: StickerPackReference, stickerPacks: [StickerPackReference], parentNavigationController: NavigationController? = nil, sendSticker: ((FileMediaReference, ASDisplayNode, CGRect) -> Bool)? = nil, actionPerformed: ((StickerPackCollectionInfo, [ItemCollectionItem], StickerPackScreenPerformedAction) -> Void)? = nil) -> ViewController {
|
||||
let controller = StickerPackPreviewController(context: context, stickerPack: mainStickerPack, mode: .default, parentNavigationController: parentNavigationController, actionPerformed: actionPerformed)
|
||||
controller.sendSticker = sendSticker
|
||||
return controller
|
||||
}
|
||||
|
||||
@@ -183,13 +183,12 @@ private let threadPool: ThreadPool = {
|
||||
}()
|
||||
|
||||
@available(iOS 9.0, *)
|
||||
public func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: CGSize, fitzModifier: EmojiFitzModifier? = nil, cacheKey: String) -> Signal<String, NoError> {
|
||||
public func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: CGSize, fitzModifier: EmojiFitzModifier? = nil, cacheKey: String) -> Signal<Data, NoError> {
|
||||
return Signal({ subscriber in
|
||||
let cancelled = Atomic<Bool>(value: false)
|
||||
|
||||
threadPool.addTask(ThreadPoolTask({ _ in
|
||||
if cancelled.with({ $0 }) {
|
||||
//print("cancelled 1")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -206,12 +205,6 @@ public func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: C
|
||||
let endFrame = Int(player.frameCount)
|
||||
|
||||
if cancelled.with({ $0 }) {
|
||||
//print("cancelled 2")
|
||||
return
|
||||
}
|
||||
|
||||
let path = NSTemporaryDirectory() + "\(arc4random64()).lz4v"
|
||||
guard let fileContext = ManagedFile(queue: nil, path: path, mode: .readwrite) else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -219,16 +212,19 @@ public func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: C
|
||||
|
||||
var currentFrame: Int32 = 0
|
||||
|
||||
let writeBuffer = WriteBuffer()
|
||||
var numberOfFramesCommitted = 0
|
||||
|
||||
var fps: Int32 = player.frameRate
|
||||
var frameCount: Int32 = player.frameCount
|
||||
let _ = fileContext.write(&fps, count: 4)
|
||||
let _ = fileContext.write(&frameCount, count: 4)
|
||||
writeBuffer.write(&fps, length: 4)
|
||||
writeBuffer.write(&frameCount, length: 4)
|
||||
var widthValue: Int32 = Int32(size.width)
|
||||
var heightValue: Int32 = Int32(size.height)
|
||||
var bytesPerRowValue: Int32 = Int32(bytesPerRow)
|
||||
let _ = fileContext.write(&widthValue, count: 4)
|
||||
let _ = fileContext.write(&heightValue, count: 4)
|
||||
let _ = fileContext.write(&bytesPerRowValue, count: 4)
|
||||
writeBuffer.write(&widthValue, length: 4)
|
||||
writeBuffer.write(&heightValue, length: 4)
|
||||
writeBuffer.write(&bytesPerRowValue, length: 4)
|
||||
|
||||
let frameLength = bytesPerRow * Int(size.height)
|
||||
assert(frameLength % 16 == 0)
|
||||
@@ -262,7 +258,6 @@ public func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: C
|
||||
|
||||
while currentFrame < endFrame {
|
||||
if cancelled.with({ $0 }) {
|
||||
//print("cancelled 3")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -298,8 +293,8 @@ public func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: C
|
||||
compressedFrameData.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
let length = compression_encode_buffer(bytes, compressedFrameDataLength, previousYuvaFrameData.assumingMemoryBound(to: UInt8.self), yuvaLength, scratchData, COMPRESSION_LZFSE)
|
||||
var frameLengthValue: Int32 = Int32(length)
|
||||
let _ = fileContext.write(&frameLengthValue, count: 4)
|
||||
let _ = fileContext.write(bytes, count: length)
|
||||
writeBuffer.write(&frameLengthValue, length: 4)
|
||||
writeBuffer.write(bytes, length: length)
|
||||
}
|
||||
|
||||
let tmp = previousYuvaFrameData
|
||||
@@ -309,16 +304,33 @@ public func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: C
|
||||
compressionTime += CACurrentMediaTime() - compressionStartTime
|
||||
|
||||
currentFrame += 1
|
||||
|
||||
numberOfFramesCommitted += 1
|
||||
|
||||
if numberOfFramesCommitted >= 5 {
|
||||
numberOfFramesCommitted = 0
|
||||
|
||||
subscriber.putNext(writeBuffer.makeData())
|
||||
writeBuffer.reset()
|
||||
|
||||
/*#if DEBUG
|
||||
usleep(500000)
|
||||
#endif*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if writeBuffer.length != 0 {
|
||||
subscriber.putNext(writeBuffer.makeData())
|
||||
}
|
||||
|
||||
subscriber.putNext(path)
|
||||
subscriber.putCompletion()
|
||||
print("animation render time \(CACurrentMediaTime() - startTime)")
|
||||
/*print("animation render time \(CACurrentMediaTime() - startTime)")
|
||||
print("of which drawing time \(drawingTime)")
|
||||
print("of which appending time \(appendingTime)")
|
||||
print("of which delta time \(deltaTime)")
|
||||
|
||||
print("of which compression time \(compressionTime)")
|
||||
print("of which compression time \(compressionTime)")*/
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
@@ -18,13 +18,13 @@ public final class AnimatedStickerResourceSource: AnimatedStickerNodeSource {
|
||||
self.fitzModifier = fitzModifier
|
||||
}
|
||||
|
||||
public func cachedDataPath(width: Int, height: Int) -> Signal<String, NoError> {
|
||||
public func cachedDataPath(width: Int, height: Int) -> Signal<(String, Bool), NoError> {
|
||||
return chatMessageAnimationData(postbox: self.account.postbox, resource: self.resource, fitzModifier: self.fitzModifier, width: width, height: height, synchronousLoad: false)
|
||||
|> filter { data in
|
||||
return data.complete
|
||||
return data.size != 0
|
||||
}
|
||||
|> map { data -> String in
|
||||
return data.path
|
||||
|> map { data -> (String, Bool) in
|
||||
return (data.path, data.complete)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ struct AccountMutableState {
|
||||
var storedMessages: Set<MessageId>
|
||||
var readInboxMaxIds: [PeerId: MessageId]
|
||||
var namespacesWithHolesFromPreviousState: [PeerId: Set<MessageId.Namespace>]
|
||||
var updatedOutgoingUniqueMessageIds: [Int64: Int32]
|
||||
|
||||
var storedMessagesByPeerIdAndTimestamp: [PeerId: Set<MessageIndex>]
|
||||
var displayAlerts: [(text: String, isDropAuth: Bool)] = []
|
||||
@@ -140,9 +141,10 @@ struct AccountMutableState {
|
||||
self.storedMessagesByPeerIdAndTimestamp = storedMessagesByPeerIdAndTimestamp
|
||||
self.branchOperationIndex = 0
|
||||
self.namespacesWithHolesFromPreviousState = [:]
|
||||
self.updatedOutgoingUniqueMessageIds = [:]
|
||||
}
|
||||
|
||||
init(initialState: AccountInitialState, operations: [AccountStateMutationOperation], state: AuthorizedAccountState.State, peers: [PeerId: Peer], chatStates: [PeerId: PeerChatState], peerChatInfos: [PeerId: PeerChatInfo], referencedMessageIds: Set<MessageId>, storedMessages: Set<MessageId>, readInboxMaxIds: [PeerId: MessageId], storedMessagesByPeerIdAndTimestamp: [PeerId: Set<MessageIndex>], namespacesWithHolesFromPreviousState: [PeerId: Set<MessageId.Namespace>], displayAlerts: [(text: String, isDropAuth: Bool)], branchOperationIndex: Int) {
|
||||
init(initialState: AccountInitialState, operations: [AccountStateMutationOperation], state: AuthorizedAccountState.State, peers: [PeerId: Peer], chatStates: [PeerId: PeerChatState], peerChatInfos: [PeerId: PeerChatInfo], referencedMessageIds: Set<MessageId>, storedMessages: Set<MessageId>, readInboxMaxIds: [PeerId: MessageId], storedMessagesByPeerIdAndTimestamp: [PeerId: Set<MessageIndex>], namespacesWithHolesFromPreviousState: [PeerId: Set<MessageId.Namespace>], updatedOutgoingUniqueMessageIds: [Int64: Int32], displayAlerts: [(text: String, isDropAuth: Bool)], branchOperationIndex: Int) {
|
||||
self.initialState = initialState
|
||||
self.operations = operations
|
||||
self.state = state
|
||||
@@ -154,12 +156,13 @@ struct AccountMutableState {
|
||||
self.readInboxMaxIds = readInboxMaxIds
|
||||
self.storedMessagesByPeerIdAndTimestamp = storedMessagesByPeerIdAndTimestamp
|
||||
self.namespacesWithHolesFromPreviousState = namespacesWithHolesFromPreviousState
|
||||
self.updatedOutgoingUniqueMessageIds = updatedOutgoingUniqueMessageIds
|
||||
self.displayAlerts = displayAlerts
|
||||
self.branchOperationIndex = branchOperationIndex
|
||||
}
|
||||
|
||||
func branch() -> AccountMutableState {
|
||||
return AccountMutableState(initialState: self.initialState, operations: self.operations, state: self.state, peers: self.peers, chatStates: self.chatStates, peerChatInfos: self.peerChatInfos, referencedMessageIds: self.referencedMessageIds, storedMessages: self.storedMessages, readInboxMaxIds: self.readInboxMaxIds, storedMessagesByPeerIdAndTimestamp: self.storedMessagesByPeerIdAndTimestamp, namespacesWithHolesFromPreviousState: self.namespacesWithHolesFromPreviousState, displayAlerts: self.displayAlerts, branchOperationIndex: self.operations.count)
|
||||
return AccountMutableState(initialState: self.initialState, operations: self.operations, state: self.state, peers: self.peers, chatStates: self.chatStates, peerChatInfos: self.peerChatInfos, referencedMessageIds: self.referencedMessageIds, storedMessages: self.storedMessages, readInboxMaxIds: self.readInboxMaxIds, storedMessagesByPeerIdAndTimestamp: self.storedMessagesByPeerIdAndTimestamp, namespacesWithHolesFromPreviousState: self.namespacesWithHolesFromPreviousState, updatedOutgoingUniqueMessageIds: self.updatedOutgoingUniqueMessageIds, displayAlerts: self.displayAlerts, branchOperationIndex: self.operations.count)
|
||||
}
|
||||
|
||||
mutating func merge(_ other: AccountMutableState) {
|
||||
@@ -180,6 +183,7 @@ struct AccountMutableState {
|
||||
self.namespacesWithHolesFromPreviousState[peerId]!.insert(namespace)
|
||||
}
|
||||
}
|
||||
self.updatedOutgoingUniqueMessageIds.merge(other.updatedOutgoingUniqueMessageIds, uniquingKeysWith: { lhs, _ in lhs })
|
||||
self.displayAlerts.append(contentsOf: other.displayAlerts)
|
||||
}
|
||||
|
||||
|
||||
@@ -1313,6 +1313,8 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
if let theme = TelegramTheme(apiTheme: theme) {
|
||||
updatedState.updateTheme(theme)
|
||||
}
|
||||
case let .updateMessageID(id, randomId):
|
||||
updatedState.updatedOutgoingUniqueMessageIds[randomId] = id
|
||||
default:
|
||||
break
|
||||
}
|
||||
@@ -2094,7 +2096,7 @@ private func recordPeerActivityTimestamp(peerId: PeerId, timestamp: Int32, into
|
||||
}
|
||||
}
|
||||
|
||||
func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountPeerId: PeerId, mediaBox: MediaBox, encryptionProvider: EncryptionProvider, transaction: Transaction, auxiliaryMethods: AccountAuxiliaryMethods, finalState: AccountFinalState) -> AccountReplayedFinalState? {
|
||||
func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountPeerId: PeerId, mediaBox: MediaBox, encryptionProvider: EncryptionProvider, transaction: Transaction, auxiliaryMethods: AccountAuxiliaryMethods, finalState: AccountFinalState, removePossiblyDeliveredMessagesUniqueIds: [Int64: PeerId]) -> AccountReplayedFinalState? {
|
||||
let verified = verifyTransaction(transaction, finalState: finalState.state)
|
||||
if !verified {
|
||||
Logger.shared.log("State", "failed to verify final state")
|
||||
@@ -2978,5 +2980,12 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP
|
||||
|
||||
addedIncomingMessageIds.append(contentsOf: addedSecretMessageIds)
|
||||
|
||||
for (uniqueId, messageIdValue) in finalState.state.updatedOutgoingUniqueMessageIds {
|
||||
if let peerId = removePossiblyDeliveredMessagesUniqueIds[uniqueId] {
|
||||
let messageId = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: messageIdValue)
|
||||
deleteMessagesInteractively(transaction: transaction, stateManager: nil, postbox: postbox, messageIds: [messageId], type: .forEveryone, deleteAllInGroup: false, removeIfPossiblyDelivered: false)
|
||||
}
|
||||
}
|
||||
|
||||
return AccountReplayedFinalState(state: finalState, addedIncomingMessageIds: addedIncomingMessageIds, wasScheduledMessageIds: wasScheduledMessageIds, addedSecretMessageIds: addedSecretMessageIds, updatedTypingActivities: updatedTypingActivities, updatedWebpages: updatedWebpages, updatedCalls: updatedCalls, updatedPeersNearby: updatedPeersNearby, isContactUpdates: isContactUpdates, delayNotificatonsUntil: delayNotificatonsUntil)
|
||||
}
|
||||
|
||||
@@ -75,6 +75,8 @@ public final class AccountStateManager {
|
||||
private let operationDisposable = MetaDisposable()
|
||||
private var operationTimer: SignalKitTimer?
|
||||
|
||||
private var removePossiblyDeliveredMessagesUniqueIds: [Int64: PeerId] = [:]
|
||||
|
||||
private var nextId: Int32 = 0
|
||||
private func getNextId() -> Int32 {
|
||||
self.nextId += 1
|
||||
@@ -369,6 +371,7 @@ public final class AccountStateManager {
|
||||
case let .pollDifference(currentEvents):
|
||||
self.operationTimer?.invalidate()
|
||||
self.currentIsUpdatingValue = true
|
||||
let queue = self.queue
|
||||
let accountManager = self.accountManager
|
||||
let postbox = self.postbox
|
||||
let network = self.network
|
||||
@@ -384,7 +387,7 @@ public final class AccountStateManager {
|
||||
}
|
||||
}
|
||||
|> take(1)
|
||||
|> mapToSignal { state -> Signal<(difference: Api.updates.Difference?, finalStatte: AccountReplayedFinalState?, skipBecauseOfError: Bool), NoError> in
|
||||
|> mapToSignal { [weak self] state -> Signal<(difference: Api.updates.Difference?, finalStatte: AccountReplayedFinalState?, skipBecauseOfError: Bool), NoError> in
|
||||
if let authorizedState = state.state {
|
||||
var flags: Int32 = 0
|
||||
var ptsTotalLimit: Int32? = nil
|
||||
@@ -423,15 +426,17 @@ public final class AccountStateManager {
|
||||
return .single((nil, nil, false))
|
||||
} else {
|
||||
return finalStateWithDifference(postbox: postbox, network: network, state: state, difference: difference)
|
||||
|> deliverOn(queue)
|
||||
|> mapToSignal { finalState -> Signal<(difference: Api.updates.Difference?, finalStatte: AccountReplayedFinalState?, skipBecauseOfError: Bool), NoError> in
|
||||
if !finalState.state.preCachedResources.isEmpty {
|
||||
for (resource, data) in finalState.state.preCachedResources {
|
||||
mediaBox.storeResourceData(resource.id, data: data)
|
||||
}
|
||||
}
|
||||
let removePossiblyDeliveredMessagesUniqueIds = self?.removePossiblyDeliveredMessagesUniqueIds ?? Dictionary()
|
||||
return postbox.transaction { transaction -> (difference: Api.updates.Difference?, finalStatte: AccountReplayedFinalState?, skipBecauseOfError: Bool) in
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
let replayedState = replayFinalState(accountManager: accountManager, postbox: postbox, accountPeerId: accountPeerId, mediaBox: mediaBox, encryptionProvider: network.encryptionProvider, transaction: transaction, auxiliaryMethods: auxiliaryMethods, finalState: finalState)
|
||||
let replayedState = replayFinalState(accountManager: accountManager, postbox: postbox, accountPeerId: accountPeerId, mediaBox: mediaBox, encryptionProvider: network.encryptionProvider, transaction: transaction, auxiliaryMethods: auxiliaryMethods, finalState: finalState, removePossiblyDeliveredMessagesUniqueIds: removePossiblyDeliveredMessagesUniqueIds)
|
||||
let deltaTime = CFAbsoluteTimeGetCurrent() - startTime
|
||||
if deltaTime > 1.0 {
|
||||
Logger.shared.log("State", "replayFinalState took \(deltaTime)s")
|
||||
@@ -535,8 +540,9 @@ public final class AccountStateManager {
|
||||
let mediaBox = postbox.mediaBox
|
||||
let queue = self.queue
|
||||
let signal = initialStateWithUpdateGroups(postbox: postbox, groups: groups)
|
||||
|> mapToSignal { state -> Signal<(AccountReplayedFinalState?, AccountFinalState), NoError> in
|
||||
|> mapToSignal { [weak self] state -> Signal<(AccountReplayedFinalState?, AccountFinalState), NoError> in
|
||||
return finalStateWithUpdateGroups(postbox: postbox, network: network, state: state, groups: groups)
|
||||
|> deliverOn(queue)
|
||||
|> mapToSignal { finalState in
|
||||
if !finalState.discard && !finalState.state.preCachedResources.isEmpty {
|
||||
for (resource, data) in finalState.state.preCachedResources {
|
||||
@@ -544,12 +550,14 @@ public final class AccountStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
let removePossiblyDeliveredMessagesUniqueIds = self?.removePossiblyDeliveredMessagesUniqueIds ?? Dictionary()
|
||||
|
||||
return postbox.transaction { transaction -> AccountReplayedFinalState? in
|
||||
if finalState.discard {
|
||||
return nil
|
||||
} else {
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
let result = replayFinalState(accountManager: accountManager, postbox: postbox, accountPeerId: accountPeerId, mediaBox: mediaBox, encryptionProvider: network.encryptionProvider, transaction: transaction, auxiliaryMethods: auxiliaryMethods, finalState: finalState)
|
||||
let result = replayFinalState(accountManager: accountManager, postbox: postbox, accountPeerId: accountPeerId, mediaBox: mediaBox, encryptionProvider: network.encryptionProvider, transaction: transaction, auxiliaryMethods: auxiliaryMethods, finalState: finalState, removePossiblyDeliveredMessagesUniqueIds: removePossiblyDeliveredMessagesUniqueIds)
|
||||
let deltaTime = CFAbsoluteTimeGetCurrent() - startTime
|
||||
if deltaTime > 1.0 {
|
||||
Logger.shared.log("State", "replayFinalState took \(deltaTime)s")
|
||||
@@ -758,9 +766,10 @@ public final class AccountStateManager {
|
||||
let mediaBox = self.postbox.mediaBox
|
||||
let network = self.network
|
||||
let auxiliaryMethods = self.auxiliaryMethods
|
||||
let removePossiblyDeliveredMessagesUniqueIds = self.removePossiblyDeliveredMessagesUniqueIds
|
||||
let signal = self.postbox.transaction { transaction -> AccountReplayedFinalState? in
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
let result = replayFinalState(accountManager: accountManager, postbox: postbox, accountPeerId: accountPeerId, mediaBox: mediaBox, encryptionProvider: network.encryptionProvider, transaction: transaction, auxiliaryMethods: auxiliaryMethods, finalState: finalState)
|
||||
let result = replayFinalState(accountManager: accountManager, postbox: postbox, accountPeerId: accountPeerId, mediaBox: mediaBox, encryptionProvider: network.encryptionProvider, transaction: transaction, auxiliaryMethods: auxiliaryMethods, finalState: finalState, removePossiblyDeliveredMessagesUniqueIds: removePossiblyDeliveredMessagesUniqueIds)
|
||||
let deltaTime = CFAbsoluteTimeGetCurrent() - startTime
|
||||
if deltaTime > 1.0 {
|
||||
Logger.shared.log("State", "replayFinalState took \(deltaTime)s")
|
||||
@@ -1019,6 +1028,12 @@ public final class AccountStateManager {
|
||||
}
|
||||
completion(nil)
|
||||
}
|
||||
|
||||
func removePossiblyDeliveredMessages(uniqueIds: [Int64: PeerId]) {
|
||||
self.queue.async {
|
||||
self.removePossiblyDeliveredMessagesUniqueIds.merge(uniqueIds, uniquingKeysWith: { _, rhs in rhs })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func messagesForNotification(transaction: Transaction, id: MessageId, alwaysReturnMessage: Bool) -> (messages: [Message], notify: Bool, sound: PeerMessageSound, displayContents: Bool) {
|
||||
|
||||
@@ -330,9 +330,9 @@ final class ChatHistoryPreloadManager {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
/*#if DEBUG
|
||||
#if DEBUG
|
||||
return
|
||||
#endif*/
|
||||
#endif
|
||||
|
||||
var indices: [(ChatHistoryPreloadIndex, Bool, Bool)] = []
|
||||
for entry in view.0.entries {
|
||||
|
||||
@@ -6,71 +6,92 @@ import MtProtoKit
|
||||
|
||||
import SyncCore
|
||||
|
||||
public func deleteMessagesInteractively(postbox: Postbox, messageIds initialMessageIds: [MessageId], type: InteractiveMessagesDeletionType, deleteAllInGroup: Bool = false) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
var messageIds: [MessageId] = []
|
||||
if deleteAllInGroup {
|
||||
for id in initialMessageIds {
|
||||
if let group = transaction.getMessageGroup(id) ?? transaction.getMessageForwardedGroup(id) {
|
||||
for message in group {
|
||||
if !messageIds.contains(message.id) {
|
||||
messageIds.append(message.id)
|
||||
}
|
||||
public func deleteMessagesInteractively(account: Account, messageIds: [MessageId], type: InteractiveMessagesDeletionType, deleteAllInGroup: Bool = false) -> Signal<Void, NoError> {
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
deleteMessagesInteractively(transaction: transaction, stateManager: account.stateManager, postbox: account.postbox, messageIds: messageIds, type: type, removeIfPossiblyDelivered: true)
|
||||
}
|
||||
}
|
||||
|
||||
func deleteMessagesInteractively(transaction: Transaction, stateManager: AccountStateManager?, postbox: Postbox, messageIds initialMessageIds: [MessageId], type: InteractiveMessagesDeletionType, deleteAllInGroup: Bool = false, removeIfPossiblyDelivered: Bool) {
|
||||
var messageIds: [MessageId] = []
|
||||
if deleteAllInGroup {
|
||||
for id in initialMessageIds {
|
||||
if let group = transaction.getMessageGroup(id) ?? transaction.getMessageForwardedGroup(id) {
|
||||
for message in group {
|
||||
if !messageIds.contains(message.id) {
|
||||
messageIds.append(message.id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageIds.append(id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageIds = initialMessageIds
|
||||
}
|
||||
|
||||
var messageIdsByPeerId: [PeerId: [MessageId]] = [:]
|
||||
for id in messageIds {
|
||||
if messageIdsByPeerId[id.peerId] == nil {
|
||||
messageIdsByPeerId[id.peerId] = [id]
|
||||
} else {
|
||||
messageIdsByPeerId[id.peerId]!.append(id)
|
||||
}
|
||||
}
|
||||
|
||||
var uniqueIds: [Int64: PeerId] = [:]
|
||||
|
||||
for (peerId, peerMessageIds) in messageIdsByPeerId {
|
||||
for id in peerMessageIds {
|
||||
if let message = transaction.getMessage(id) {
|
||||
for attribute in message.attributes {
|
||||
if let attribute = attribute as? OutgoingMessageInfoAttribute {
|
||||
uniqueIds[attribute.uniqueId] = peerId
|
||||
}
|
||||
} else {
|
||||
messageIds.append(id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageIds = initialMessageIds
|
||||
}
|
||||
|
||||
var messageIdsByPeerId: [PeerId: [MessageId]] = [:]
|
||||
for id in messageIds {
|
||||
if messageIdsByPeerId[id.peerId] == nil {
|
||||
messageIdsByPeerId[id.peerId] = [id]
|
||||
} else {
|
||||
messageIdsByPeerId[id.peerId]!.append(id)
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel || peerId.namespace == Namespaces.Peer.CloudGroup || peerId.namespace == Namespaces.Peer.CloudUser {
|
||||
let remoteMessageIds = peerMessageIds.filter { id in
|
||||
if id.namespace == Namespaces.Message.Local {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
for (peerId, peerMessageIds) in messageIdsByPeerId {
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel || peerId.namespace == Namespaces.Peer.CloudGroup || peerId.namespace == Namespaces.Peer.CloudUser {
|
||||
let remoteMessageIds = peerMessageIds.filter { id in
|
||||
if id.namespace == Namespaces.Message.Local {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
if !remoteMessageIds.isEmpty {
|
||||
cloudChatAddRemoveMessagesOperation(transaction: transaction, peerId: peerId, messageIds: remoteMessageIds, type: CloudChatRemoveMessagesType(type))
|
||||
}
|
||||
} else if peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
if let state = transaction.getPeerChatState(peerId) as? SecretChatState {
|
||||
var layer: SecretChatLayer?
|
||||
switch state.embeddedState {
|
||||
case .terminated, .handshake:
|
||||
break
|
||||
case .basicLayer:
|
||||
layer = .layer8
|
||||
case let .sequenceBasedLayer(sequenceState):
|
||||
layer = sequenceState.layerNegotiationState.activeLayer.secretChatLayer
|
||||
}
|
||||
if !remoteMessageIds.isEmpty {
|
||||
cloudChatAddRemoveMessagesOperation(transaction: transaction, peerId: peerId, messageIds: remoteMessageIds, type: CloudChatRemoveMessagesType(type))
|
||||
}
|
||||
} else if peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
if let state = transaction.getPeerChatState(peerId) as? SecretChatState {
|
||||
var layer: SecretChatLayer?
|
||||
switch state.embeddedState {
|
||||
case .terminated, .handshake:
|
||||
break
|
||||
case .basicLayer:
|
||||
layer = .layer8
|
||||
case let .sequenceBasedLayer(sequenceState):
|
||||
layer = sequenceState.layerNegotiationState.activeLayer.secretChatLayer
|
||||
if let layer = layer {
|
||||
var globallyUniqueIds: [Int64] = []
|
||||
for messageId in peerMessageIds {
|
||||
if let message = transaction.getMessage(messageId), let globallyUniqueId = message.globallyUniqueId {
|
||||
globallyUniqueIds.append(globallyUniqueId)
|
||||
}
|
||||
}
|
||||
if let layer = layer {
|
||||
var globallyUniqueIds: [Int64] = []
|
||||
for messageId in peerMessageIds {
|
||||
if let message = transaction.getMessage(messageId), let globallyUniqueId = message.globallyUniqueId {
|
||||
globallyUniqueIds.append(globallyUniqueId)
|
||||
}
|
||||
}
|
||||
let updatedState = addSecretChatOutgoingOperation(transaction: transaction, peerId: peerId, operation: SecretChatOutgoingOperationContents.deleteMessages(layer: layer, actionGloballyUniqueId: arc4random64(), globallyUniqueIds: globallyUniqueIds), state: state)
|
||||
if updatedState != state {
|
||||
transaction.setPeerChatState(peerId, state: updatedState)
|
||||
}
|
||||
let updatedState = addSecretChatOutgoingOperation(transaction: transaction, peerId: peerId, operation: SecretChatOutgoingOperationContents.deleteMessages(layer: layer, actionGloballyUniqueId: arc4random64(), globallyUniqueIds: globallyUniqueIds), state: state)
|
||||
if updatedState != state {
|
||||
transaction.setPeerChatState(peerId, state: updatedState)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: messageIds)
|
||||
}
|
||||
deleteMessages(transaction: transaction, mediaBox: postbox.mediaBox, ids: messageIds)
|
||||
|
||||
if !uniqueIds.isEmpty && removeIfPossiblyDelivered {
|
||||
stateManager?.removePossiblyDeliveredMessages(uniqueIds: uniqueIds)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ import Postbox
|
||||
import TelegramApi
|
||||
import SwiftSignalKit
|
||||
|
||||
public func groupsInCommon(account:Account, peerId:PeerId) -> Signal<[PeerId], NoError> {
|
||||
return account.postbox.transaction { transaction -> Signal<[PeerId], NoError> in
|
||||
public func groupsInCommon(account:Account, peerId:PeerId) -> Signal<[Peer], NoError> {
|
||||
return account.postbox.transaction { transaction -> Signal<[Peer], NoError> in
|
||||
if let peer = transaction.getPeer(peerId), let inputUser = apiInputUser(peer) {
|
||||
return account.network.request(Api.functions.messages.getCommonChats(userId: inputUser, maxId: 0, limit: 100))
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<[PeerId], NoError> in
|
||||
|> mapToSignal { result -> Signal<[Peer], NoError> in
|
||||
let chats: [Api.Chat]
|
||||
switch result {
|
||||
case let .chats(chats: apiChats):
|
||||
@@ -17,7 +17,7 @@ public func groupsInCommon(account:Account, peerId:PeerId) -> Signal<[PeerId], N
|
||||
chats = apiChats
|
||||
}
|
||||
|
||||
return account.postbox.transaction { transaction -> [PeerId] in
|
||||
return account.postbox.transaction { transaction -> [Peer] in
|
||||
var peers:[Peer] = []
|
||||
for chat in chats {
|
||||
if let peer = parseTelegramGroupOrChannel(chat: chat) {
|
||||
@@ -27,7 +27,7 @@ public func groupsInCommon(account:Account, peerId:PeerId) -> Signal<[PeerId], N
|
||||
updatePeers(transaction: transaction, peers: peers, update: { _, updated -> Peer? in
|
||||
return updated
|
||||
})
|
||||
return peers.map {$0.id}
|
||||
return peers
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@ import SwiftSignalKit
|
||||
|
||||
import SyncCore
|
||||
|
||||
public func addStickerPackInteractively(postbox: Postbox, info: StickerPackCollectionInfo, items: [ItemCollectionItem]) -> Signal<Void, NoError> {
|
||||
public func addStickerPackInteractively(postbox: Postbox, info: StickerPackCollectionInfo, items: [ItemCollectionItem], positionInList: Int? = nil) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
let namespace: SynchronizeInstalledStickerPacksOperationNamespace?
|
||||
switch info.id.namespace {
|
||||
@@ -23,7 +23,11 @@ public func addStickerPackInteractively(postbox: Postbox, info: StickerPackColle
|
||||
updatedInfos.remove(at: index)
|
||||
updatedInfos.insert(currentInfo, at: 0)
|
||||
} else {
|
||||
updatedInfos.insert(info, at: 0)
|
||||
if let positionInList = positionInList, positionInList <= updatedInfos.count {
|
||||
updatedInfos.insert(info, at: positionInList)
|
||||
} else {
|
||||
updatedInfos.insert(info, at: 0)
|
||||
}
|
||||
transaction.replaceItemCollectionItems(collectionId: info.id, items: items)
|
||||
}
|
||||
transaction.replaceItemCollectionInfos(namespace: info.id.namespace, itemCollectionInfos: updatedInfos.map { ($0.id, $0) })
|
||||
@@ -36,8 +40,8 @@ public enum RemoveStickerPackOption {
|
||||
case archive
|
||||
}
|
||||
|
||||
public func removeStickerPackInteractively(postbox: Postbox, id: ItemCollectionId, option: RemoveStickerPackOption) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
public func removeStickerPackInteractively(postbox: Postbox, id: ItemCollectionId, option: RemoveStickerPackOption) -> Signal<(Int, [ItemCollectionItem])?, NoError> {
|
||||
return postbox.transaction { transaction -> (Int, [ItemCollectionItem])? in
|
||||
let namespace: SynchronizeInstalledStickerPacksOperationNamespace?
|
||||
switch id.namespace {
|
||||
case Namespaces.ItemCollection.CloudStickerPacks:
|
||||
@@ -55,8 +59,14 @@ public func removeStickerPackInteractively(postbox: Postbox, id: ItemCollectionI
|
||||
case .archive:
|
||||
content = .archive([id])
|
||||
}
|
||||
let index = transaction.getItemCollectionsInfos(namespace: id.namespace).index(where: { $0.0 == id })
|
||||
let items = transaction.getItemCollectionItems(collectionId: id)
|
||||
|
||||
addSynchronizeInstalledStickerPacksOperation(transaction: transaction, namespace: namespace, content: content)
|
||||
transaction.removeItemCollection(collectionId: id)
|
||||
return index.flatMap { ($0, items) }
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,6 +420,7 @@ public func makeDefaultDarkPresentationTheme(preview: Bool) -> PresentationTheme
|
||||
|
||||
let inputPanel = PresentationThemeChatInputPanel(
|
||||
panelBackgroundColor: UIColor(rgb: 0x1c1c1d),
|
||||
panelBackgroundColorNoWallpaper: UIColor(rgb: 0x000000),
|
||||
panelSeparatorColor: UIColor(rgb: 0x3d3d40),
|
||||
panelControlAccentColor: UIColor(rgb: 0xffffff),
|
||||
panelControlColor: UIColor(rgb: 0x808080),
|
||||
|
||||
@@ -676,6 +676,7 @@ public func makeDefaultDarkTintedPresentationTheme(preview: Bool) -> Presentatio
|
||||
|
||||
let inputPanel = PresentationThemeChatInputPanel(
|
||||
panelBackgroundColor: mainBackgroundColor,
|
||||
panelBackgroundColorNoWallpaper: accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18),
|
||||
panelSeparatorColor: mainSeparatorColor,
|
||||
panelControlAccentColor: accentColor,
|
||||
panelControlColor: mainSecondaryTextColor.withAlphaComponent(0.5),
|
||||
|
||||
@@ -629,6 +629,7 @@ public func makeDefaultDayPresentationTheme(serviceBackgroundColor: UIColor?, da
|
||||
|
||||
let inputPanel = PresentationThemeChatInputPanel(
|
||||
panelBackgroundColor: UIColor(rgb: 0xf7f7f7),
|
||||
panelBackgroundColorNoWallpaper: UIColor(rgb: 0xffffff),
|
||||
panelSeparatorColor: UIColor(rgb: 0xb2b2b2),
|
||||
panelControlAccentColor: UIColor(rgb: 0x007ee5),
|
||||
panelControlColor: UIColor(rgb: 0x858e99),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -847,6 +847,7 @@ public final class PresentationThemeChatInputPanelMediaRecordingControl {
|
||||
|
||||
public final class PresentationThemeChatInputPanel {
|
||||
public let panelBackgroundColor: UIColor
|
||||
public let panelBackgroundColorNoWallpaper: UIColor
|
||||
public let panelSeparatorColor: UIColor
|
||||
public let panelControlAccentColor: UIColor
|
||||
public let panelControlColor: UIColor
|
||||
@@ -864,8 +865,9 @@ public final class PresentationThemeChatInputPanel {
|
||||
public let mediaRecordingDotColor: UIColor
|
||||
public let mediaRecordingControl: PresentationThemeChatInputPanelMediaRecordingControl
|
||||
|
||||
public init(panelBackgroundColor: UIColor, panelSeparatorColor: UIColor, panelControlAccentColor: UIColor, panelControlColor: UIColor, panelControlDisabledColor: UIColor, panelControlDestructiveColor: UIColor, inputBackgroundColor: UIColor, inputStrokeColor: UIColor, inputPlaceholderColor: UIColor, inputTextColor: UIColor, inputControlColor: UIColor, actionControlFillColor: UIColor, actionControlForegroundColor: UIColor, primaryTextColor: UIColor, secondaryTextColor: UIColor, mediaRecordingDotColor: UIColor, mediaRecordingControl: PresentationThemeChatInputPanelMediaRecordingControl) {
|
||||
public init(panelBackgroundColor: UIColor, panelBackgroundColorNoWallpaper: UIColor, panelSeparatorColor: UIColor, panelControlAccentColor: UIColor, panelControlColor: UIColor, panelControlDisabledColor: UIColor, panelControlDestructiveColor: UIColor, inputBackgroundColor: UIColor, inputStrokeColor: UIColor, inputPlaceholderColor: UIColor, inputTextColor: UIColor, inputControlColor: UIColor, actionControlFillColor: UIColor, actionControlForegroundColor: UIColor, primaryTextColor: UIColor, secondaryTextColor: UIColor, mediaRecordingDotColor: UIColor, mediaRecordingControl: PresentationThemeChatInputPanelMediaRecordingControl) {
|
||||
self.panelBackgroundColor = panelBackgroundColor
|
||||
self.panelBackgroundColorNoWallpaper = panelBackgroundColorNoWallpaper
|
||||
self.panelSeparatorColor = panelSeparatorColor
|
||||
self.panelControlAccentColor = panelControlAccentColor
|
||||
self.panelControlColor = panelControlColor
|
||||
@@ -884,8 +886,8 @@ public final class PresentationThemeChatInputPanel {
|
||||
self.mediaRecordingControl = mediaRecordingControl
|
||||
}
|
||||
|
||||
public func withUpdated(panelBackgroundColor: UIColor? = nil, panelSeparatorColor: UIColor? = nil, panelControlAccentColor: UIColor? = nil, panelControlColor: UIColor? = nil, panelControlDisabledColor: UIColor? = nil, panelControlDestructiveColor: UIColor? = nil, inputBackgroundColor: UIColor? = nil, inputStrokeColor: UIColor? = nil, inputPlaceholderColor: UIColor? = nil, inputTextColor: UIColor? = nil, inputControlColor: UIColor? = nil, actionControlFillColor: UIColor? = nil, actionControlForegroundColor: UIColor? = nil, primaryTextColor: UIColor? = nil, secondaryTextColor: UIColor? = nil, mediaRecordingDotColor: UIColor? = nil, mediaRecordingControl: PresentationThemeChatInputPanelMediaRecordingControl? = nil) -> PresentationThemeChatInputPanel {
|
||||
return PresentationThemeChatInputPanel(panelBackgroundColor: panelBackgroundColor ?? self.panelBackgroundColor, panelSeparatorColor: panelSeparatorColor ?? self.panelSeparatorColor, panelControlAccentColor: panelControlAccentColor ?? self.panelControlAccentColor, panelControlColor: panelControlColor ?? self.panelControlColor, panelControlDisabledColor: panelControlDisabledColor ?? self.panelControlDisabledColor, panelControlDestructiveColor: panelControlDestructiveColor ?? self.panelControlDestructiveColor, inputBackgroundColor: inputBackgroundColor ?? self.inputBackgroundColor, inputStrokeColor: inputStrokeColor ?? self.inputStrokeColor, inputPlaceholderColor: inputPlaceholderColor ?? self.inputPlaceholderColor, inputTextColor: inputTextColor ?? self.inputTextColor, inputControlColor: inputControlColor ?? self.inputControlColor, actionControlFillColor: actionControlFillColor ?? self.actionControlFillColor, actionControlForegroundColor: actionControlForegroundColor ?? self.actionControlForegroundColor, primaryTextColor: primaryTextColor ?? self.primaryTextColor, secondaryTextColor: secondaryTextColor ?? self.secondaryTextColor, mediaRecordingDotColor: mediaRecordingDotColor ?? self.mediaRecordingDotColor, mediaRecordingControl: mediaRecordingControl ?? self.mediaRecordingControl)
|
||||
public func withUpdated(panelBackgroundColor: UIColor? = nil, panelBackgroundColorNoWallpaper: UIColor? = nil, panelSeparatorColor: UIColor? = nil, panelControlAccentColor: UIColor? = nil, panelControlColor: UIColor? = nil, panelControlDisabledColor: UIColor? = nil, panelControlDestructiveColor: UIColor? = nil, inputBackgroundColor: UIColor? = nil, inputStrokeColor: UIColor? = nil, inputPlaceholderColor: UIColor? = nil, inputTextColor: UIColor? = nil, inputControlColor: UIColor? = nil, actionControlFillColor: UIColor? = nil, actionControlForegroundColor: UIColor? = nil, primaryTextColor: UIColor? = nil, secondaryTextColor: UIColor? = nil, mediaRecordingDotColor: UIColor? = nil, mediaRecordingControl: PresentationThemeChatInputPanelMediaRecordingControl? = nil) -> PresentationThemeChatInputPanel {
|
||||
return PresentationThemeChatInputPanel(panelBackgroundColor: panelBackgroundColor ?? self.panelBackgroundColor, panelBackgroundColorNoWallpaper: panelBackgroundColorNoWallpaper ?? self.panelBackgroundColorNoWallpaper, panelSeparatorColor: panelSeparatorColor ?? self.panelSeparatorColor, panelControlAccentColor: panelControlAccentColor ?? self.panelControlAccentColor, panelControlColor: panelControlColor ?? self.panelControlColor, panelControlDisabledColor: panelControlDisabledColor ?? self.panelControlDisabledColor, panelControlDestructiveColor: panelControlDestructiveColor ?? self.panelControlDestructiveColor, inputBackgroundColor: inputBackgroundColor ?? self.inputBackgroundColor, inputStrokeColor: inputStrokeColor ?? self.inputStrokeColor, inputPlaceholderColor: inputPlaceholderColor ?? self.inputPlaceholderColor, inputTextColor: inputTextColor ?? self.inputTextColor, inputControlColor: inputControlColor ?? self.inputControlColor, actionControlFillColor: actionControlFillColor ?? self.actionControlFillColor, actionControlForegroundColor: actionControlForegroundColor ?? self.actionControlForegroundColor, primaryTextColor: primaryTextColor ?? self.primaryTextColor, secondaryTextColor: secondaryTextColor ?? self.secondaryTextColor, mediaRecordingDotColor: mediaRecordingDotColor ?? self.mediaRecordingDotColor, mediaRecordingControl: mediaRecordingControl ?? self.mediaRecordingControl)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1318,6 +1318,7 @@ extension PresentationThemeChatInputPanelMediaRecordingControl: Codable {
|
||||
extension PresentationThemeChatInputPanel: Codable {
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case panelBg
|
||||
case panelBgNoWallpaper
|
||||
case panelSeparator
|
||||
case panelControlAccent
|
||||
case panelControl
|
||||
@@ -1338,7 +1339,10 @@ extension PresentationThemeChatInputPanel: Codable {
|
||||
|
||||
public convenience init(from decoder: Decoder) throws {
|
||||
let values = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.init(panelBackgroundColor: try decodeColor(values, .panelBg),
|
||||
let panelBackgroundColor = try decodeColor(values, .panelBg)
|
||||
let panelBackgroundColorNoWallpaper = try decodeColor(values, .panelBgNoWallpaper)
|
||||
self.init(panelBackgroundColor: panelBackgroundColor,
|
||||
panelBackgroundColorNoWallpaper: panelBackgroundColorNoWallpaper ?? panelBackgroundColor,
|
||||
panelSeparatorColor: try decodeColor(values, .panelSeparator),
|
||||
panelControlAccentColor: try decodeColor(values, .panelControlAccent),
|
||||
panelControlColor: try decodeColor(values, .panelControl),
|
||||
|
||||
@@ -67,10 +67,15 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
||||
}
|
||||
} else {
|
||||
var attributePeerIds: [(Int, PeerId?)] = [(0, message.author?.id)]
|
||||
let resultTitleString: (String, [(Int, NSRange)])
|
||||
if peerIds.count == 1 {
|
||||
attributePeerIds.append((1, peerIds.first))
|
||||
resultTitleString = strings.Notification_Invited(authorName, peerDebugDisplayTitles(peerIds, message.peers))
|
||||
} else {
|
||||
resultTitleString = strings.Notification_InvitedMultiple(authorName, peerDebugDisplayTitles(peerIds, message.peers))
|
||||
}
|
||||
attributedString = addAttributesToStringWithRanges(strings.Notification_Invited(authorName, peerDebugDisplayTitles(peerIds, message.peers)), body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: attributePeerIds))
|
||||
|
||||
attributedString = addAttributesToStringWithRanges(resultTitleString, body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: attributePeerIds))
|
||||
}
|
||||
case let .removedMembers(peerIds):
|
||||
if peerIds.first == message.author?.id {
|
||||
|
||||
@@ -23,6 +23,7 @@ import WatchBridge
|
||||
import SettingsUI
|
||||
import AppLock
|
||||
import AccountUtils
|
||||
import ContextUI
|
||||
|
||||
final class UnauthorizedApplicationContext {
|
||||
let sharedContext: SharedAccountContextImpl
|
||||
@@ -149,6 +150,21 @@ final class AuthorizedApplicationContext {
|
||||
|
||||
self.rootController = TelegramRootController(context: context)
|
||||
|
||||
self.rootController.globalOverlayControllersUpdated = { [weak self] in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
var hasContext = false
|
||||
for controller in strongSelf.rootController.globalOverlayControllers {
|
||||
if controller is ContextController {
|
||||
hasContext = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
strongSelf.notificationController.updateIsTemporaryHidden(hasContext)
|
||||
}
|
||||
|
||||
if KeyShortcutsController.isAvailable {
|
||||
let keyShortcutsController = KeyShortcutsController { [weak self] f in
|
||||
if let strongSelf = self, let appLockContext = strongSelf.context.sharedContext.appLockContext as? AppLockContextImpl {
|
||||
|
||||
@@ -1498,7 +1498,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.actionSheet.destructiveActionTextColor)
|
||||
}, action: { [weak self] controller, f in
|
||||
if let strongSelf = self {
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: [id], type: .forLocalPeer).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: [id], type: .forLocalPeer).start()
|
||||
}
|
||||
f(.dismissWithoutContent)
|
||||
})))
|
||||
@@ -2687,6 +2687,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self.chatDisplayNode.historyNode.contentPositionChanged = { [weak self] offset in
|
||||
if let strongSelf = self {
|
||||
let offsetAlpha: CGFloat
|
||||
let plainInputSeparatorAlpha: CGFloat
|
||||
switch offset {
|
||||
case let .known(offset):
|
||||
if offset < 40.0 {
|
||||
@@ -2694,13 +2695,21 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
} else {
|
||||
offsetAlpha = 1.0
|
||||
}
|
||||
if offset < 4.0 {
|
||||
plainInputSeparatorAlpha = 0.0
|
||||
} else {
|
||||
plainInputSeparatorAlpha = 1.0
|
||||
}
|
||||
case .unknown:
|
||||
offsetAlpha = 1.0
|
||||
plainInputSeparatorAlpha = 1.0
|
||||
case .none:
|
||||
offsetAlpha = 0.0
|
||||
plainInputSeparatorAlpha = 0.0
|
||||
}
|
||||
|
||||
strongSelf.chatDisplayNode.navigateButtons.displayDownButton = !offsetAlpha.isZero
|
||||
strongSelf.chatDisplayNode.updatePlainInputSeparatorAlpha(plainInputSeparatorAlpha, transition: .animated(duration: 0.2, curve: .easeInOut))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3087,10 +3096,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
}
|
||||
if isAction && (actions.options == .deleteGlobally || actions.options == .deleteLocally) {
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: actions.options == .deleteLocally ? .forLocalPeer : .forEveryone).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: actions.options == .deleteLocally ? .forLocalPeer : .forEveryone).start()
|
||||
completion(.dismissWithoutContent)
|
||||
} else if (messages.first?.flags.isSending ?? false) {
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: .forEveryone, deleteAllInGroup: true).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forEveryone, deleteAllInGroup: true).start()
|
||||
completion(.dismissWithoutContent)
|
||||
} else {
|
||||
if actions.options.intersection([.deleteLocally, .deleteGlobally]).isEmpty {
|
||||
@@ -7671,7 +7680,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}).start()
|
||||
let _ = clearAuthorHistory(account: strongSelf.context.account, peerId: peerId, memberId: author.id).start()
|
||||
} else if actions.contains(0) {
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
}
|
||||
if actions.contains(1) {
|
||||
let _ = removePeerMember(account: strongSelf.context.account, peerId: peerId, memberId: author.id).start()
|
||||
@@ -7709,7 +7718,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
}
|
||||
}))
|
||||
}
|
||||
@@ -7736,7 +7745,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
contextItems.append(.action(ContextMenuActionItem(text: globalTitle, textColor: .destructive, icon: { _ in nil }, action: { [weak self] _, f in
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
f(.dismissWithoutContent)
|
||||
}
|
||||
})))
|
||||
@@ -7744,7 +7753,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
}
|
||||
}))
|
||||
}
|
||||
@@ -7766,7 +7775,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
contextItems.append(.action(ContextMenuActionItem(text: localOptionText, textColor: .destructive, icon: { _ in nil }, action: { [weak self] _, f in
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: unsendPersonalMessages ? .forEveryone : .forLocalPeer).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: unsendPersonalMessages ? .forEveryone : .forLocalPeer).start()
|
||||
f(.dismissWithoutContent)
|
||||
}
|
||||
})))
|
||||
@@ -7774,7 +7783,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: unsendPersonalMessages ? .forEveryone : .forLocalPeer).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: unsendPersonalMessages ? .forEveryone : .forLocalPeer).start()
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -92,6 +92,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
|
||||
private let inputPanelBackgroundNode: ASDisplayNode
|
||||
private let inputPanelBackgroundSeparatorNode: ASDisplayNode
|
||||
private var plainInputSeparatorAlpha: CGFloat?
|
||||
private var usePlainInputSeparator: Bool
|
||||
|
||||
private let titleAccessoryPanelContainer: ChatControllerTitlePanelNodeContainer
|
||||
private var titleAccessoryPanelNode: ChatTitleAccessoryPanelNode?
|
||||
@@ -225,7 +227,14 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
self.loadingNode = ChatLoadingNode(theme: self.chatPresentationInterfaceState.theme, chatWallpaper: self.chatPresentationInterfaceState.chatWallpaper)
|
||||
|
||||
self.inputPanelBackgroundNode = ASDisplayNode()
|
||||
self.inputPanelBackgroundNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColor
|
||||
if self.chatPresentationInterfaceState.chatWallpaper == self.chatPresentationInterfaceState.theme.chat.defaultWallpaper, case .color = self.chatPresentationInterfaceState.chatWallpaper {
|
||||
self.inputPanelBackgroundNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColorNoWallpaper
|
||||
self.usePlainInputSeparator = true
|
||||
} else {
|
||||
self.inputPanelBackgroundNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColor
|
||||
self.usePlainInputSeparator = false
|
||||
self.plainInputSeparatorAlpha = nil
|
||||
}
|
||||
self.inputPanelBackgroundNode.isLayerBacked = true
|
||||
|
||||
self.inputPanelBackgroundSeparatorNode = ASDisplayNode()
|
||||
@@ -1384,6 +1393,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
self.performAnimateInAsOverlay(from: scheduledAnimateInAsOverlayFromNode, transition: animatedTransition)
|
||||
}
|
||||
|
||||
self.updatePlainInputSeparator(transition: transition)
|
||||
|
||||
self.derivedLayoutState = ChatControllerNodeDerivedLayoutState(inputContextPanelsFrame: inputContextPanelsFrame, inputContextPanelsOverMainPanelFrame: inputContextPanelsOverMainPanelFrame, inputNodeHeight: inputNodeHeightAndOverflow?.0, upperInputPositionBound: inputNodeHeightAndOverflow?.0 != nil ? self.upperInputPositionBound : nil)
|
||||
|
||||
//self.notifyTransitionCompletionListeners(transition: transition)
|
||||
@@ -1443,7 +1454,15 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
self.navigateButtons.updateTheme(theme: chatPresentationInterfaceState.theme)
|
||||
|
||||
if themeUpdated {
|
||||
self.inputPanelBackgroundNode.backgroundColor = chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColor
|
||||
if self.chatPresentationInterfaceState.chatWallpaper == self.chatPresentationInterfaceState.theme.chat.defaultWallpaper, case .color = self.chatPresentationInterfaceState.chatWallpaper {
|
||||
self.inputPanelBackgroundNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColorNoWallpaper
|
||||
self.usePlainInputSeparator = true
|
||||
} else {
|
||||
self.inputPanelBackgroundNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelBackgroundColor
|
||||
self.usePlainInputSeparator = false
|
||||
self.plainInputSeparatorAlpha = nil
|
||||
}
|
||||
self.updatePlainInputSeparator(transition: .immediate)
|
||||
self.inputPanelBackgroundSeparatorNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelSeparatorColor
|
||||
}
|
||||
|
||||
@@ -1657,7 +1676,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
if case let .peer(id) = self.chatPresentationInterfaceState.chatLocation {
|
||||
peerId = id
|
||||
}
|
||||
let inputNode = ChatMediaInputNode(context: self.context, peerId: peerId, controllerInteraction: self.controllerInteraction, theme: theme, strings: strings, fontSize: fontSize, gifPaneIsActiveUpdated: { [weak self] value in
|
||||
let inputNode = ChatMediaInputNode(context: self.context, peerId: peerId, controllerInteraction: self.controllerInteraction, chatWallpaper: self.chatPresentationInterfaceState.chatWallpaper, theme: theme, strings: strings, fontSize: fontSize, gifPaneIsActiveUpdated: { [weak self] value in
|
||||
if let strongSelf = self, let interfaceInteraction = strongSelf.interfaceInteraction {
|
||||
interfaceInteraction.updateInputModeAndDismissedButtonKeyboardMessageId { state in
|
||||
if case let .media(_, expanded) = state.inputMode {
|
||||
@@ -2275,4 +2294,27 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
func setEnablePredictiveTextInput(_ value: Bool) {
|
||||
self.textInputPanelNode?.enablePredictiveInput = value
|
||||
}
|
||||
|
||||
func updatePlainInputSeparatorAlpha(_ value: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||
if self.plainInputSeparatorAlpha != value {
|
||||
let immediate = self.plainInputSeparatorAlpha == nil
|
||||
self.plainInputSeparatorAlpha = value
|
||||
self.updatePlainInputSeparator(transition: immediate ? .immediate : transition)
|
||||
}
|
||||
}
|
||||
|
||||
func updatePlainInputSeparator(transition: ContainedViewLayoutTransition) {
|
||||
let resolvedValue: CGFloat
|
||||
if self.accessoryPanelNode != nil {
|
||||
resolvedValue = 1.0
|
||||
} else if self.usePlainInputSeparator {
|
||||
resolvedValue = self.plainInputSeparatorAlpha ?? 0.0
|
||||
} else {
|
||||
resolvedValue = 1.0
|
||||
}
|
||||
|
||||
if resolvedValue != self.inputPanelBackgroundSeparatorNode.alpha {
|
||||
transition.updateAlpha(node: self.inputPanelBackgroundSeparatorNode, alpha: resolvedValue, beginWithCurrentState: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ func inputNodeForChatPresentationIntefaceState(_ chatPresentationInterfaceState:
|
||||
if case let .peer(id) = chatPresentationInterfaceState.chatLocation {
|
||||
peerId = id
|
||||
}
|
||||
let inputNode = ChatMediaInputNode(context: context, peerId: peerId, controllerInteraction: controllerInteraction, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize, gifPaneIsActiveUpdated: { [weak interfaceInteraction] value in
|
||||
let inputNode = ChatMediaInputNode(context: context, peerId: peerId, controllerInteraction: controllerInteraction, chatWallpaper: chatPresentationInterfaceState.chatWallpaper, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize, gifPaneIsActiveUpdated: { [weak interfaceInteraction] value in
|
||||
if let interfaceInteraction = interfaceInteraction {
|
||||
interfaceInteraction.updateInputModeAndDismissedButtonKeyboardMessageId { state in
|
||||
if case let .media(_, expanded) = state.inputMode {
|
||||
|
||||
@@ -446,7 +446,7 @@ final class ChatMediaInputNode: ChatInputNode {
|
||||
return self._ready.get()
|
||||
}
|
||||
|
||||
init(context: AccountContext, peerId: PeerId?, controllerInteraction: ChatControllerInteraction, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, gifPaneIsActiveUpdated: @escaping (Bool) -> Void) {
|
||||
init(context: AccountContext, peerId: PeerId?, controllerInteraction: ChatControllerInteraction, chatWallpaper: TelegramWallpaper, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, gifPaneIsActiveUpdated: @escaping (Bool) -> Void) {
|
||||
self.context = context
|
||||
self.peerId = peerId
|
||||
self.controllerInteraction = controllerInteraction
|
||||
@@ -459,7 +459,12 @@ final class ChatMediaInputNode: ChatInputNode {
|
||||
|
||||
self.collectionListPanel = ASDisplayNode()
|
||||
self.collectionListPanel.clipsToBounds = true
|
||||
self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColor
|
||||
|
||||
if chatWallpaper == theme.chat.defaultWallpaper, case .color = chatWallpaper {
|
||||
self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColorNoWallpaper
|
||||
} else {
|
||||
self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColor
|
||||
}
|
||||
|
||||
self.collectionListSeparator = ASDisplayNode()
|
||||
self.collectionListSeparator.isLayerBacked = true
|
||||
@@ -913,12 +918,17 @@ final class ChatMediaInputNode: ChatInputNode {
|
||||
self.searchContainerNodeLoadedDisposable.dispose()
|
||||
}
|
||||
|
||||
private func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) {
|
||||
private func updateThemeAndStrings(chatWallpaper: TelegramWallpaper, theme: PresentationTheme, strings: PresentationStrings) {
|
||||
if self.theme !== theme || self.strings !== strings {
|
||||
self.theme = theme
|
||||
self.strings = strings
|
||||
|
||||
self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColor
|
||||
if chatWallpaper == theme.chat.defaultWallpaper, case .color = chatWallpaper {
|
||||
self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColorNoWallpaper
|
||||
} else {
|
||||
self.collectionListPanel.backgroundColor = theme.chat.inputPanel.panelBackgroundColor
|
||||
}
|
||||
|
||||
self.collectionListSeparator.backgroundColor = theme.chat.inputMediaPanel.panelSeparatorColor
|
||||
self.backgroundColor = theme.chat.inputMediaPanel.stickersBackgroundColor
|
||||
|
||||
@@ -1332,7 +1342,7 @@ final class ChatMediaInputNode: ChatInputNode {
|
||||
self.validLayout = (width, leftInset, rightInset, bottomInset, standardInputHeight, inputHeight, maximumHeight, inputPanelHeight, interfaceState, deviceMetrics, isVisible)
|
||||
|
||||
if self.theme !== interfaceState.theme || self.strings !== interfaceState.strings {
|
||||
self.updateThemeAndStrings(theme: interfaceState.theme, strings: interfaceState.strings)
|
||||
self.updateThemeAndStrings(chatWallpaper: interfaceState.chatWallpaper, theme: interfaceState.theme, strings: interfaceState.strings)
|
||||
}
|
||||
|
||||
var displaySearch = false
|
||||
|
||||
@@ -1015,7 +1015,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
||||
selectionNode.updateLayout(size: selectionFrame.size)
|
||||
self.subnodeTransform = CATransform3DMakeTranslation(offset, 0.0, 0.0);
|
||||
} else {
|
||||
let selectionNode = ChatMessageSelectionNode(theme: item.presentationData.theme.theme, toggle: { [weak self] value in
|
||||
let selectionNode = ChatMessageSelectionNode(wallpaper: item.presentationData.theme.wallpaper, theme: item.presentationData.theme.theme, toggle: { [weak self] value in
|
||||
if let strongSelf = self, let item = strongSelf.item {
|
||||
item.controllerInteraction.toggleMessagesSelection([item.message.id], value)
|
||||
}
|
||||
|
||||
@@ -2661,7 +2661,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode
|
||||
selectionNode.updateLayout(size: selectionFrame.size)
|
||||
self.subnodeTransform = CATransform3DMakeTranslation(offset, 0.0, 0.0);
|
||||
} else {
|
||||
let selectionNode = ChatMessageSelectionNode(theme: item.presentationData.theme.theme, toggle: { [weak self] value in
|
||||
let selectionNode = ChatMessageSelectionNode(wallpaper: item.presentationData.theme.wallpaper, theme: item.presentationData.theme.theme, toggle: { [weak self] value in
|
||||
if let strongSelf = self, let item = strongSelf.item {
|
||||
switch item.content {
|
||||
case let .message(message, _, _, _):
|
||||
|
||||
@@ -770,7 +770,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView {
|
||||
selectionNode.updateSelected(selected, animated: animated)
|
||||
self.subnodeTransform = CATransform3DMakeTranslation(offset, 0.0, 0.0);
|
||||
} else {
|
||||
let selectionNode = ChatMessageSelectionNode(theme: item.presentationData.theme.theme, toggle: { [weak self] value in
|
||||
let selectionNode = ChatMessageSelectionNode(wallpaper: item.presentationData.theme.wallpaper, theme: item.presentationData.theme.theme, toggle: { [weak self] value in
|
||||
if let strongSelf = self, let item = strongSelf.item {
|
||||
item.controllerInteraction.toggleMessagesSelection([item.message.id], value)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import UIKit
|
||||
import AsyncDisplayKit
|
||||
import TelegramPresentationData
|
||||
import CheckNode
|
||||
import SyncCore
|
||||
|
||||
final class ChatMessageSelectionNode: ASDisplayNode {
|
||||
private let toggle: (Bool) -> Void
|
||||
@@ -10,9 +11,17 @@ final class ChatMessageSelectionNode: ASDisplayNode {
|
||||
private(set) var selected = false
|
||||
private let checkNode: CheckNode
|
||||
|
||||
init(theme: PresentationTheme, toggle: @escaping (Bool) -> Void) {
|
||||
init(wallpaper: TelegramWallpaper, theme: PresentationTheme, toggle: @escaping (Bool) -> Void) {
|
||||
self.toggle = toggle
|
||||
self.checkNode = CheckNode(strokeColor: theme.list.itemCheckColors.strokeColor, fillColor: theme.list.itemCheckColors.fillColor, foregroundColor: theme.list.itemCheckColors.foregroundColor, style: .overlay)
|
||||
|
||||
let style: CheckNodeStyle
|
||||
if wallpaper == theme.chat.defaultWallpaper, case .color = wallpaper {
|
||||
style = .plain
|
||||
} else {
|
||||
style = .overlay
|
||||
}
|
||||
|
||||
self.checkNode = CheckNode(strokeColor: theme.list.itemCheckColors.strokeColor, fillColor: theme.list.itemCheckColors.fillColor, foregroundColor: theme.list.itemCheckColors.foregroundColor, style: style)
|
||||
self.checkNode.isUserInteractionEnabled = false
|
||||
|
||||
super.init()
|
||||
|
||||
@@ -796,7 +796,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
|
||||
selectionNode.updateSelected(selected, animated: animated)
|
||||
self.subnodeTransform = CATransform3DMakeTranslation(offset, 0.0, 0.0);
|
||||
} else {
|
||||
let selectionNode = ChatMessageSelectionNode(theme: item.presentationData.theme.theme, toggle: { [weak self] value in
|
||||
let selectionNode = ChatMessageSelectionNode(wallpaper: item.presentationData.theme.wallpaper, theme: item.presentationData.theme.theme, toggle: { [weak self] value in
|
||||
if let strongSelf = self, let item = strongSelf.item {
|
||||
item.controllerInteraction.toggleMessagesSelection([item.message.id], value)
|
||||
}
|
||||
|
||||
@@ -40,7 +40,13 @@ final class ChatRecentActionsController: TelegramBaseController {
|
||||
|
||||
self.interaction = ChatRecentActionsInteraction(displayInfoAlert: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
self?.present(textAlertController(context: strongSelf.context, title: strongSelf.presentationData.strings.Channel_AdminLog_InfoPanelAlertTitle, text: strongSelf.presentationData.strings.Channel_AdminLog_InfoPanelAlertText, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
let text: String
|
||||
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
||||
text = strongSelf.presentationData.strings.Channel_AdminLog_InfoPanelAlertText
|
||||
} else {
|
||||
text = strongSelf.presentationData.strings.Channel_AdminLog_InfoPanelChannelAlertText
|
||||
}
|
||||
self?.present(textAlertController(context: strongSelf.context, title: strongSelf.presentationData.strings.Channel_AdminLog_InfoPanelAlertTitle, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -724,7 +724,15 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
|
||||
let textFieldMinHeight = calclulateTextFieldMinHeight(interfaceState, metrics: metrics)
|
||||
let minimalInputHeight: CGFloat = 2.0 + textFieldMinHeight
|
||||
self.textInputBackgroundNode.image = textInputBackgroundImage(backgroundColor: interfaceState.theme.chat.inputPanel.panelBackgroundColor, strokeColor: interfaceState.theme.chat.inputPanel.inputStrokeColor, diameter: minimalInputHeight)
|
||||
|
||||
let backgroundColor: UIColor
|
||||
if interfaceState.theme.chat.defaultWallpaper == interfaceState.chatWallpaper, case .color = interfaceState.chatWallpaper {
|
||||
backgroundColor = interfaceState.theme.chat.inputPanel.panelBackgroundColorNoWallpaper
|
||||
} else {
|
||||
backgroundColor = interfaceState.theme.chat.inputPanel.panelBackgroundColor
|
||||
}
|
||||
|
||||
self.textInputBackgroundNode.image = textInputBackgroundImage(backgroundColor: backgroundColor, strokeColor: interfaceState.theme.chat.inputPanel.inputStrokeColor, diameter: minimalInputHeight)
|
||||
|
||||
self.searchLayoutClearButton.setImage(PresentationResourcesChat.chatInputTextFieldClearImage(interfaceState.theme), for: [])
|
||||
|
||||
@@ -1495,7 +1503,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
|
||||
@objc func _showTextStyleOptions(_ sender: Any) {
|
||||
if let textInputNode = self.textInputNode {
|
||||
self.inputMenu.format(view: textInputNode.view, rect: textInputNode.selectionRect.insetBy(dx: 0.0, dy: -1.0))
|
||||
self.inputMenu.format(view: textInputNode.view, rect: textInputNode.selectionRect.offsetBy(dx: 0.0, dy: -textInputNode.textView.contentOffset.y).insetBy(dx: 0.0, dy: -1.0))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -855,8 +855,11 @@ private func fetchAnimatedStickerRepresentation(account: Account, resource: Medi
|
||||
return Signal({ subscriber in
|
||||
if let data = try? Data(contentsOf: URL(fileURLWithPath: resourceData.path), options: [.mappedIfSafe]) {
|
||||
if #available(iOS 9.0, *) {
|
||||
return experimentalConvertCompressedLottieToCombinedMp4(data: data, size: CGSize(width: CGFloat(representation.width), height: CGFloat(representation.height)), fitzModifier: representation.fitzModifier, cacheKey: "\(resource.id.uniqueId)-\(representation.uniqueId)").start(next: { path in
|
||||
subscriber.putNext(.temporaryPath(path))
|
||||
subscriber.putNext(.reset)
|
||||
return experimentalConvertCompressedLottieToCombinedMp4(data: data, size: CGSize(width: CGFloat(representation.width), height: CGFloat(representation.height)), fitzModifier: representation.fitzModifier, cacheKey: "\(resource.id.uniqueId)-\(representation.uniqueId)").start(next: { data in
|
||||
subscriber.putNext(.data(data))
|
||||
}, completed: {
|
||||
subscriber.putNext(.done)
|
||||
subscriber.putCompletion()
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -28,7 +28,6 @@ func presentedLegacyCamera(context: AccountContext, peer: Peer, cameraView: TGAt
|
||||
} else {
|
||||
controller = TGCameraController()
|
||||
}
|
||||
controller.defaultVideoPreset = defaultVideoPresetForContext(context)
|
||||
|
||||
controller.presentScheduleController = { done in
|
||||
presentSchedulePicker { time in
|
||||
|
||||
@@ -101,4 +101,15 @@ public final class NotificationContainerController: ViewController {
|
||||
public func removeItems(_ f: (NotificationItem) -> Bool) {
|
||||
self.controllerNode.removeItems(f)
|
||||
}
|
||||
|
||||
public func updateIsTemporaryHidden(_ value: Bool) {
|
||||
if self.isNodeLoaded {
|
||||
if value != (self.controllerNode.alpha == 0.0) {
|
||||
let fromAlpha: CGFloat = value ? 1.0 : 0.0
|
||||
let toAlpha: CGFloat = value ? 0.0 : 1.0
|
||||
self.controllerNode.alpha = toAlpha
|
||||
self.controllerNode.layer.animateAlpha(from: fromAlpha, to: toAlpha, duration: 0.2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import SettingsUI
|
||||
import AlertUI
|
||||
import PresentationDataUtils
|
||||
import ShareController
|
||||
import UndoUI
|
||||
|
||||
private enum ChatMessageGalleryControllerData {
|
||||
case url(String)
|
||||
@@ -304,7 +305,31 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool {
|
||||
params.navigationController?.pushViewController(controller)
|
||||
return true
|
||||
case let .stickerPack(reference):
|
||||
let controller = StickerPackScreen(context: params.context, mainStickerPack: reference, stickerPacks: [reference], sendSticker: params.sendSticker)
|
||||
let controller = StickerPackScreen(context: params.context, mainStickerPack: reference, stickerPacks: [reference], sendSticker: params.sendSticker, actionPerformed: { info, items, action in
|
||||
let presentationData = params.context.sharedContext.currentPresentationData.with { $0 }
|
||||
var animateInAsReplacement = false
|
||||
if let navigationController = params.navigationController {
|
||||
for controller in navigationController.overlayControllers {
|
||||
if let controller = controller as? UndoOverlayController {
|
||||
controller.dismissWithCommitActionAndReplacementAnimation()
|
||||
animateInAsReplacement = true
|
||||
}
|
||||
}
|
||||
}
|
||||
switch action {
|
||||
case .add:
|
||||
params.navigationController?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, account: params.context.account), elevatedLayout: true, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
return true
|
||||
}))
|
||||
case let .remove(positionInList):
|
||||
params.navigationController?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_RemovedTitle, text: presentationData.strings.StickerPackActionInfo_RemovedText(info.title).0, undo: true, info: info, topItem: items.first, account: params.context.account), elevatedLayout: true, animateInAsReplacement: animateInAsReplacement, action: { action in
|
||||
if case .undo = action {
|
||||
let _ = addStickerPackInteractively(postbox: params.context.account.postbox, info: info, items: items, positionInList: positionInList).start()
|
||||
}
|
||||
return true
|
||||
}))
|
||||
}
|
||||
})
|
||||
params.dismissInput()
|
||||
params.present(controller, nil)
|
||||
return true
|
||||
|
||||
@@ -245,7 +245,7 @@ public class PeerMediaCollectionController: TelegramBaseController {
|
||||
c.dismiss(completion: {
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateInterfaceState(animated: true, { $0.withoutSelectionState() })
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
}
|
||||
})
|
||||
})))
|
||||
@@ -264,7 +264,7 @@ public class PeerMediaCollectionController: TelegramBaseController {
|
||||
c.dismiss(completion: {
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateInterfaceState(animated: true, { $0.withoutSelectionState() })
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: .forLocalPeer).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forLocalPeer).start()
|
||||
}
|
||||
})
|
||||
})))
|
||||
@@ -894,7 +894,7 @@ public class PeerMediaCollectionController: TelegramBaseController {
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateInterfaceState(animated: true, { $0.withoutSelectionState() })
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||
}
|
||||
}))
|
||||
}
|
||||
@@ -911,7 +911,7 @@ public class PeerMediaCollectionController: TelegramBaseController {
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateInterfaceState(animated: true, { $0.withoutSelectionState() })
|
||||
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: .forLocalPeer).start()
|
||||
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forLocalPeer).start()
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -148,7 +148,7 @@ class StickerPanePeerSpecificSetupGridItemNode: GridItemNode {
|
||||
let textSpacing: CGFloat = 3.0
|
||||
let buttonSpacing: CGFloat = 6.0
|
||||
|
||||
let (installLayout, installApply) = makeInstallLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.strings.Stickers_GroupChooseStickerPack, font: buttonFont, textColor: item.theme.list.itemAccentColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - leftInset - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
let (installLayout, installApply) = makeInstallLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.strings.Stickers_GroupChooseStickerPack, font: buttonFont, textColor: item.theme.list.itemCheckColors.foregroundColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - leftInset - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.strings.Stickers_GroupStickers.uppercased(), font: titleFont, textColor: item.theme.chat.inputMediaPanel.stickersSectionTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - leftInset - rightInset - 20.0 - installLayout.size.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
|
||||
@@ -260,17 +260,17 @@ public final class TextSelectionNode: ASDisplayNode {
|
||||
|
||||
let mappedPoint = strongSelf.view.convert(point, to: strongSelf.textNode.view)
|
||||
if let stringIndex = strongSelf.textNode.attributesAtPoint(mappedPoint, orNearest: true)?.0 {
|
||||
var updatedMin = currentRange.0
|
||||
var updatedMax = currentRange.1
|
||||
var updatedLeft = currentRange.0
|
||||
var updatedRight = currentRange.1
|
||||
switch knob {
|
||||
case .left:
|
||||
updatedMin = stringIndex
|
||||
updatedLeft = stringIndex
|
||||
case .right:
|
||||
updatedMax = stringIndex
|
||||
updatedRight = stringIndex
|
||||
}
|
||||
let updatedRange = NSRange(location: min(updatedMin, updatedMax), length: max(updatedMin, updatedMax) - min(updatedMin, updatedMax))
|
||||
if strongSelf.currentRange?.0 != updatedMin || strongSelf.currentRange?.1 != updatedMax {
|
||||
strongSelf.currentRange = (updatedMin, updatedMax)
|
||||
if strongSelf.currentRange?.0 != updatedLeft || strongSelf.currentRange?.1 != updatedRight {
|
||||
strongSelf.currentRange = (updatedLeft, updatedRight)
|
||||
let updatedRange = NSRange(location: min(updatedLeft, updatedRight), length: max(updatedLeft, updatedRight) - min(updatedLeft, updatedRight))
|
||||
strongSelf.updateSelection(range: updatedRange, animateIn: false)
|
||||
}
|
||||
|
||||
@@ -301,12 +301,12 @@ public final class TextSelectionNode: ASDisplayNode {
|
||||
let inputRange = CFRangeMake(0, string.length)
|
||||
let flag = UInt(kCFStringTokenizerUnitWord)
|
||||
let locale = CFLocaleCopyCurrent()
|
||||
let tokenizer = CFStringTokenizerCreate( kCFAllocatorDefault, string as CFString, inputRange, flag, locale)
|
||||
let tokenizer = CFStringTokenizerCreate(kCFAllocatorDefault, string as CFString, inputRange, flag, locale)
|
||||
var tokenType = CFStringTokenizerAdvanceToNextToken(tokenizer)
|
||||
|
||||
while !tokenType.isEmpty {
|
||||
let currentTokenRange = CFStringTokenizerGetCurrentTokenRange(tokenizer)
|
||||
if currentTokenRange.location <= stringIndex && currentTokenRange.location + currentTokenRange.length > stringIndex {
|
||||
if currentTokenRange.location <= stringIndex && currentTokenRange.location + currentTokenRange.length > stringIndex {
|
||||
resultRange = NSRange(location: currentTokenRange.location, length: currentTokenRange.length)
|
||||
break
|
||||
}
|
||||
@@ -377,7 +377,7 @@ public final class TextSelectionNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
public func pretendExtendSelection(to index: Int) {
|
||||
guard let cachedLayout = self.textNode.cachedLayout, let attributedString = cachedLayout.attributedString, let endRangeRect = cachedLayout.rangeRects(in: NSRange(location: index, length: 1))?.first else {
|
||||
guard let cachedLayout = self.textNode.cachedLayout, let attributedString = cachedLayout.attributedString, let endRangeRect = cachedLayout.rangeRects(in: NSRange(location: index, length: 1))?.rects.first else {
|
||||
return
|
||||
}
|
||||
let startPoint = self.rightKnob.frame.center
|
||||
@@ -397,15 +397,15 @@ public final class TextSelectionNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
private func updateSelection(range: NSRange?, animateIn: Bool) {
|
||||
var rects: [CGRect]?
|
||||
var rects: (rects: [CGRect], start: TextRangeRectEdge, end: TextRangeRectEdge)?
|
||||
|
||||
if let range = range {
|
||||
rects = self.textNode.rangeRects(in: range)
|
||||
}
|
||||
|
||||
self.currentRects = rects
|
||||
self.currentRects = rects?.rects
|
||||
|
||||
if let rects = rects, !rects.isEmpty {
|
||||
if let (rects, startEdge, endEdge) = rects, !rects.isEmpty {
|
||||
let highlightOverlay: LinkHighlightingNode
|
||||
if let current = self.highlightOverlay {
|
||||
highlightOverlay = current
|
||||
@@ -421,8 +421,8 @@ public final class TextSelectionNode: ASDisplayNode {
|
||||
highlightOverlay.frame = self.bounds
|
||||
highlightOverlay.updateRects(rects)
|
||||
if let image = self.leftKnob.image {
|
||||
self.leftKnob.frame = CGRect(origin: CGPoint(x: floor(rects[0].minX - 1.0 - image.size.width / 2.0), y: rects[0].minY - 1.0 - self.theme.knobDiameter), size: CGSize(width: image.size.width, height: self.theme.knobDiameter + rects[0].height + 2.0))
|
||||
self.rightKnob.frame = CGRect(origin: CGPoint(x: floor(rects[rects.count - 1].maxX + 1.0 - image.size.width / 2.0), y: rects[rects.count - 1].maxY + 1.0 - (rects[0].height + 2.0)), size: CGSize(width: image.size.width, height: self.theme.knobDiameter + rects[0].height + 2.0))
|
||||
self.leftKnob.frame = CGRect(origin: CGPoint(x: floor(startEdge.x - image.size.width / 2.0), y: startEdge.y + 1.0 - 12.0), size: CGSize(width: image.size.width, height: self.theme.knobDiameter + startEdge.height + 2.0))
|
||||
self.rightKnob.frame = CGRect(origin: CGPoint(x: floor(endEdge.x + 1.0 - image.size.width / 2.0), y: endEdge.y + endEdge.height + 3.0 - (endEdge.height + 2.0)), size: CGSize(width: image.size.width, height: self.theme.knobDiameter + endEdge.height + 2.0))
|
||||
}
|
||||
if self.leftKnob.alpha.isZero {
|
||||
highlightOverlay.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
|
||||
|
||||
@@ -19,6 +19,8 @@ static_library(
|
||||
"//submodules/AnimationUI:AnimationUI",
|
||||
"//submodules/AnimatedStickerNode:AnimatedStickerNode",
|
||||
"//submodules/AppBundle:AppBundle",
|
||||
"//submodules/StickerResources:StickerResources",
|
||||
"//submodules/TelegramAnimatedStickerNode:TelegramAnimatedStickerNode",
|
||||
],
|
||||
frameworks = [
|
||||
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
|
||||
|
||||
@@ -2,6 +2,9 @@ import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import TelegramPresentationData
|
||||
import SyncCore
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
|
||||
public enum UndoOverlayContent {
|
||||
case removedChat(text: String)
|
||||
@@ -12,6 +15,7 @@ public enum UndoOverlayContent {
|
||||
case emoji(path: String, text: String)
|
||||
case swipeToReply(title: String, text: String)
|
||||
case actionSucceeded(title: String, text: String, cancel: String)
|
||||
case stickersModified(title: String, text: String, undo: Bool, info: StickerPackCollectionInfo, topItem: ItemCollectionItem?, account: Account)
|
||||
}
|
||||
|
||||
public enum UndoOverlayAction {
|
||||
|
||||
@@ -9,16 +9,23 @@ import Markdown
|
||||
import RadialStatusNode
|
||||
import AppBundle
|
||||
import AnimatedStickerNode
|
||||
import TelegramAnimatedStickerNode
|
||||
import AnimationUI
|
||||
import SyncCore
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import StickerResources
|
||||
|
||||
final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
private let elevatedLayout: Bool
|
||||
private let statusNode: RadialStatusNode
|
||||
private var statusNode: RadialStatusNode?
|
||||
private let timerTextNode: ImmediateTextNode
|
||||
private let iconNode: ASImageNode?
|
||||
private let iconCheckNode: RadialStatusNode?
|
||||
private let animationNode: AnimationNode?
|
||||
private let animatedStickerNode: AnimatedStickerNode?
|
||||
private var animatedStickerNode: AnimatedStickerNode?
|
||||
private var stillStickerNode: TransformImageNode?
|
||||
private var stickerImageSize: CGSize?
|
||||
private let titleNode: ImmediateTextNode
|
||||
private let textNode: ImmediateTextNode
|
||||
private let buttonNode: HighlightTrackingButtonNode
|
||||
@@ -39,6 +46,8 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
|
||||
private var validLayout: ContainerViewLayout?
|
||||
|
||||
private var fetchResourceDisposable: Disposable?
|
||||
|
||||
init(presentationData: PresentationData, content: UndoOverlayContent, elevatedLayout: Bool, action: @escaping (UndoOverlayAction) -> Bool, dismiss: @escaping () -> Void) {
|
||||
self.elevatedLayout = elevatedLayout
|
||||
|
||||
@@ -77,6 +86,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(14.0), textColor: .white)
|
||||
displayUndo = true
|
||||
self.originalRemainingSeconds = 5
|
||||
self.statusNode = RadialStatusNode(backgroundNodeColor: .clear)
|
||||
case let .archivedChat(_, title, text, undo):
|
||||
if undo {
|
||||
self.iconNode = ASImageNode()
|
||||
@@ -169,12 +179,97 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
self.textNode.maximumNumberOfLines = 2
|
||||
displayUndo = false
|
||||
self.originalRemainingSeconds = 5
|
||||
case let .stickersModified(title, text, undo, info, topItem, account):
|
||||
self.iconNode = nil
|
||||
self.iconCheckNode = nil
|
||||
self.animationNode = nil
|
||||
|
||||
let stillStickerNode = TransformImageNode()
|
||||
|
||||
self.stillStickerNode = stillStickerNode
|
||||
|
||||
enum StickerPackThumbnailItem {
|
||||
case still(TelegramMediaImageRepresentation)
|
||||
case animated(MediaResource)
|
||||
}
|
||||
|
||||
var thumbnailItem: StickerPackThumbnailItem?
|
||||
var resourceReference: MediaResourceReference?
|
||||
|
||||
if let thumbnail = info.thumbnail {
|
||||
if info.flags.contains(.isAnimated) {
|
||||
thumbnailItem = .animated(thumbnail.resource)
|
||||
resourceReference = MediaResourceReference.stickerPackThumbnail(stickerPack: .id(id: info.id.id, accessHash: info.accessHash), resource: thumbnail.resource)
|
||||
} else {
|
||||
thumbnailItem = .still(thumbnail)
|
||||
resourceReference = MediaResourceReference.stickerPackThumbnail(stickerPack: .id(id: info.id.id, accessHash: info.accessHash), resource: thumbnail.resource)
|
||||
}
|
||||
} else if let item = topItem as? StickerPackItem {
|
||||
if item.file.isAnimatedSticker {
|
||||
thumbnailItem = .animated(item.file.resource)
|
||||
resourceReference = MediaResourceReference.media(media: .standalone(media: item.file), resource: item.file.resource)
|
||||
} else if let dimensions = item.file.dimensions, let resource = chatMessageStickerResource(file: item.file, small: true) as? TelegramMediaResource {
|
||||
thumbnailItem = .still(TelegramMediaImageRepresentation(dimensions: dimensions, resource: resource))
|
||||
resourceReference = MediaResourceReference.media(media: .standalone(media: item.file), resource: resource)
|
||||
}
|
||||
}
|
||||
|
||||
var updatedImageSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>?
|
||||
var updatedFetchSignal: Signal<FetchResourceSourceType, FetchResourceError>?
|
||||
|
||||
let imageBoundingSize = CGSize(width: 34.0, height: 34.0)
|
||||
|
||||
if let thumbnailItem = thumbnailItem {
|
||||
switch thumbnailItem {
|
||||
case let .still(representation):
|
||||
let stillImageSize = representation.dimensions.cgSize.aspectFitted(imageBoundingSize)
|
||||
self.stickerImageSize = stillImageSize
|
||||
|
||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: account.postbox, resource: representation.resource)
|
||||
case let .animated(resource):
|
||||
self.stickerImageSize = imageBoundingSize
|
||||
|
||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: account.postbox, resource: resource, animated: true)
|
||||
}
|
||||
if let resourceReference = resourceReference {
|
||||
updatedFetchSignal = fetchedMediaResource(mediaBox: account.postbox.mediaBox, reference: resourceReference)
|
||||
}
|
||||
} else {
|
||||
updatedImageSignal = .single({ _ in return nil })
|
||||
updatedFetchSignal = .complete()
|
||||
}
|
||||
|
||||
self.titleNode.attributedText = NSAttributedString(string: title, font: Font.semibold(14.0), textColor: .white)
|
||||
let body = MarkdownAttributeSet(font: Font.regular(14.0), textColor: .white)
|
||||
let bold = MarkdownAttributeSet(font: Font.semibold(14.0), textColor: .white)
|
||||
let attributedText = parseMarkdownIntoAttributedString(text, attributes: MarkdownAttributes(body: body, bold: bold, link: body, linkAttribute: { _ in return nil }), textAlignment: .natural)
|
||||
self.textNode.attributedText = attributedText
|
||||
self.textNode.maximumNumberOfLines = 2
|
||||
displayUndo = undo
|
||||
self.originalRemainingSeconds = 2
|
||||
|
||||
if let updatedFetchSignal = updatedFetchSignal {
|
||||
self.fetchResourceDisposable = updatedFetchSignal.start()
|
||||
}
|
||||
|
||||
if let updatedImageSignal = updatedImageSignal {
|
||||
stillStickerNode.setSignal(updatedImageSignal)
|
||||
}
|
||||
|
||||
if let thumbnailItem = thumbnailItem {
|
||||
switch thumbnailItem {
|
||||
case .still:
|
||||
break
|
||||
case let .animated(resource):
|
||||
let animatedStickerNode = AnimatedStickerNode()
|
||||
self.animatedStickerNode = animatedStickerNode
|
||||
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: account, resource: resource), width: 80, height: 80, mode: .cached)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.remainingSeconds = self.originalRemainingSeconds
|
||||
|
||||
self.statusNode = RadialStatusNode(backgroundNodeColor: .clear)
|
||||
|
||||
self.undoButtonTextNode = ImmediateTextNode()
|
||||
self.undoButtonTextNode.displaysAsynchronously = false
|
||||
self.undoButtonTextNode.attributedText = NSAttributedString(string: undoText, font: Font.regular(17.0), textColor: undoTextColor)
|
||||
@@ -199,13 +294,14 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
switch content {
|
||||
case .removedChat:
|
||||
self.panelWrapperNode.addSubnode(self.timerTextNode)
|
||||
self.panelWrapperNode.addSubnode(self.statusNode)
|
||||
case .archivedChat, .hidArchive, .revealedArchive, .succeed, .emoji, .swipeToReply, .actionSucceeded:
|
||||
case .archivedChat, .hidArchive, .revealedArchive, .succeed, .emoji, .swipeToReply, .actionSucceeded, .stickersModified:
|
||||
break
|
||||
}
|
||||
self.statusNode.flatMap(self.panelWrapperNode.addSubnode)
|
||||
self.iconNode.flatMap(self.panelWrapperNode.addSubnode)
|
||||
self.iconCheckNode.flatMap(self.panelWrapperNode.addSubnode)
|
||||
self.animationNode.flatMap(self.panelWrapperNode.addSubnode)
|
||||
self.stillStickerNode.flatMap(self.panelWrapperNode.addSubnode)
|
||||
self.animatedStickerNode.flatMap(self.panelWrapperNode.addSubnode)
|
||||
self.panelWrapperNode.addSubnode(self.titleNode)
|
||||
self.panelWrapperNode.addSubnode(self.textNode)
|
||||
@@ -230,6 +326,14 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
}
|
||||
self.buttonNode.addTarget(self, action: #selector(self.buttonPressed), forControlEvents: .touchUpInside)
|
||||
self.undoButtonNode.addTarget(self, action: #selector(self.undoButtonPressed), forControlEvents: .touchUpInside)
|
||||
|
||||
self.animatedStickerNode?.started = { [weak self] in
|
||||
self?.stillStickerNode?.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
deinit {
|
||||
self.fetchResourceDisposable?.dispose()
|
||||
}
|
||||
|
||||
override func didLoad() {
|
||||
@@ -371,7 +475,22 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
transition.updateFrame(node: animationNode, frame: iconFrame)
|
||||
}
|
||||
|
||||
if let animatedStickerNode = self.animatedStickerNode {
|
||||
if let stickerImageSize = self.stickerImageSize {
|
||||
let iconSize = stickerImageSize
|
||||
let iconFrame = CGRect(origin: CGPoint(x: floor((leftInset - iconSize.width) / 2.0), y: floor((contentHeight - iconSize.height) / 2.0)), size: iconSize)
|
||||
|
||||
if let stillStickerNode = self.stillStickerNode {
|
||||
let makeImageLayout = stillStickerNode.asyncLayout()
|
||||
let imageApply = makeImageLayout(TransformImageArguments(corners: ImageCorners(), imageSize: stickerImageSize, boundingSize: stickerImageSize, intrinsicInsets: UIEdgeInsets()))
|
||||
let _ = imageApply()
|
||||
transition.updateFrame(node: stillStickerNode, frame: iconFrame)
|
||||
}
|
||||
|
||||
if let animatedStickerNode = self.animatedStickerNode {
|
||||
animatedStickerNode.updateLayout(size: iconFrame.size)
|
||||
transition.updateFrame(node: animatedStickerNode, frame: iconFrame)
|
||||
}
|
||||
} else if let animatedStickerNode = self.animatedStickerNode {
|
||||
let iconSize = CGSize(width: 32.0, height: 32.0)
|
||||
let iconFrame = CGRect(origin: CGPoint(x: floor((leftInset - iconSize.width) / 2.0), y: floor((contentHeight - iconSize.height) / 2.0)), size: iconSize)
|
||||
animatedStickerNode.updateLayout(size: iconFrame.size)
|
||||
@@ -381,9 +500,11 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
let timerTextSize = self.timerTextNode.updateLayout(CGSize(width: 100.0, height: 100.0))
|
||||
transition.updateFrame(node: self.timerTextNode, frame: CGRect(origin: CGPoint(x: floor((leftInset - timerTextSize.width) / 2.0), y: floor((contentHeight - timerTextSize.height) / 2.0)), size: timerTextSize))
|
||||
let statusSize: CGFloat = 30.0
|
||||
transition.updateFrame(node: self.statusNode, frame: CGRect(origin: CGPoint(x: floor((leftInset - statusSize) / 2.0), y: floor((contentHeight - statusSize) / 2.0)), size: CGSize(width: statusSize, height: statusSize)))
|
||||
if firstLayout {
|
||||
self.statusNode.transitionToState(.secretTimeout(color: .white, icon: nil, beginTime: CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970, timeout: Double(self.remainingSeconds), sparks: false), completion: {})
|
||||
if let statusNode = self.statusNode {
|
||||
transition.updateFrame(node: statusNode, frame: CGRect(origin: CGPoint(x: floor((leftInset - statusSize) / 2.0), y: floor((contentHeight - statusSize) / 2.0)), size: CGSize(width: statusSize, height: statusSize)))
|
||||
if firstLayout {
|
||||
statusNode.transitionToState(.secretTimeout(color: .white, icon: nil, beginTime: CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970, timeout: Double(self.remainingSeconds), sparks: false), completion: {})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,6 +530,8 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
})
|
||||
}
|
||||
|
||||
self.animatedStickerNode?.visibility = true
|
||||
|
||||
self.checkTimer()
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user