diff --git a/submodules/GradientBackground/Sources/GradientBackground.swift b/submodules/GradientBackground/Sources/GradientBackground.swift index 7e55be5a08..a58d894df9 100644 --- a/submodules/GradientBackground/Sources/GradientBackground.swift +++ b/submodules/GradientBackground/Sources/GradientBackground.swift @@ -3,61 +3,6 @@ import UIKit import Display import AsyncDisplayKit -private struct GradientPoint { - var color: UIColor - var position: CGPoint -} - -private func applyTransformerToPoints(step: Int, substep: Int) -> [GradientPoint] { - var points: [GradientPoint] = [] - - var firstSet: [CGPoint] - var secondSet: [CGPoint] - - let colors: [UIColor] = [ - UIColor(rgb: 0x7FA381), - UIColor(rgb: 0xFFF5C5), - UIColor(rgb: 0x336F55), - UIColor(rgb: 0xFBE37D) - ] - - let firstStepPoints: [CGPoint] = [ - CGPoint(x: 0.823, y: 0.086), - CGPoint(x: 0.362, y: 0.254), - CGPoint(x: 0.184, y: 0.923), - CGPoint(x: 0.648, y: 0.759) - ] - - let nextStepPoints: [CGPoint] = [ - CGPoint(x: 0.59, y: 0.16), - CGPoint(x: 0.28, y: 0.58), - CGPoint(x: 0.42, y: 0.83), - CGPoint(x: 0.74, y: 0.42) - ] - - if step % 2 == 0 { - firstSet = shiftArray(array: firstStepPoints, offset: step / 2) - secondSet = shiftArray(array: nextStepPoints, offset: step / 2) - } else { - firstSet = shiftArray(array: nextStepPoints, offset: step / 2) - secondSet = shiftArray(array: firstStepPoints, offset: step / 2 + 1) - } - - for index in 0 ..< colors.count { - let point = transformPoint( - points: (firstSet[index], secondSet[index]), - substep: substep - ) - - points.append(GradientPoint( - color: colors[index], - position: point - )) - } - - return points -} - private func shiftArray(array: [CGPoint], offset: Int) -> [CGPoint] { var newArray = array var offset = offset @@ -69,14 +14,6 @@ private func shiftArray(array: [CGPoint], offset: Int) -> [CGPoint] { return newArray } -private func transformPoint(points: (first: CGPoint, second: CGPoint), substep: Int) -> CGPoint { - let delta = CGFloat(substep) / CGFloat(30) - let x = points.first.x + (points.second.x - points.first.x) * delta - let y = points.first.y + (points.second.y - points.first.y) * delta - - return CGPoint(x: x, y: y) -} - private func generateGradientComponent(size: CGSize, color: UIColor) -> UIImage? { UIGraphicsBeginImageContextWithOptions(size, false, 1.0) @@ -86,15 +23,13 @@ private func generateGradientComponent(size: CGSize, color: UIColor) -> UIImage? c?.setBlendMode(.normal) - //var gradLocs: [CGFloat] = [0, 0.1, 0.35, 1] - var gradLocs: [CGFloat] = [0.0, 1.0] + var gradLocs: [CGFloat] = [0.0, 0.1, 1.0] let colorSpace = CGColorSpaceCreateDeviceRGB() let radius = min(size.width / 2.0, size.height / 2.0) let colors = [ color.cgColor, - //color.withAlphaComponent(0.8).cgColor, - //color.withAlphaComponent(0.3).cgColor, + color.cgColor, color.withAlphaComponent(0).cgColor ] @@ -112,35 +47,14 @@ private func generateGradientComponent(size: CGSize, color: UIColor) -> UIImage? } public final class GradientBackgroundNode: ASDisplayNode { - //private let imageView: UIImageView - private var pointImages: [UIImageView] = [] private let dimView: UIView - private let firstStepPoints: [CGPoint] = [ - CGPoint(x: 0.823, y: 0.086), - CGPoint(x: 0.362, y: 0.254), - CGPoint(x: 0.184, y: 0.923), - CGPoint(x: 0.648, y: 0.759) - ] - - private let nextStepPoints: [CGPoint] = [ - CGPoint(x: 0.59, y: 0.16), - CGPoint(x: 0.28, y: 0.58), - CGPoint(x: 0.42, y: 0.83), - CGPoint(x: 0.74, y: 0.42) - ] - private var phase: Int = 0 - private var subphase: Int = 0 - - private var timer: Timer? private var validLayout: CGSize? override public init() { - //self.imageView = UIImageView() - self.dimView = UIView() self.dimView.backgroundColor = UIColor(white: 1.0, alpha: 0.0) @@ -151,23 +65,6 @@ public final class GradientBackgroundNode: ASDisplayNode { self.backgroundColor = .white self.clipsToBounds = true - //self.view.addSubview(self.imageView) - - /*let compositingModes: [String] = CIFilter - .filterNames(inCategory: nil) // fetch all the available filters - .filter { $0.contains("Compositing")} // retrieve only the compositing ones - .map { - let capitalizedFilter = $0.dropFirst(2) // drop the CIn prefix - let first = capitalizedFilter.first! // fetch the first letter - // lowercase the first letter and drop the `Compositing` suffix - return "\(first.lowercased())\(capitalizedFilter.dropFirst().dropLast("Compositing".count))" - }*/ - - //print("compositingModes: \(compositingModes)") - - //self.imageView.alpha = 0.5 - //self.imageView.layer.compositingFilter = "multiplyBlendMode" - let colors: [UIColor] = [ UIColor(rgb: 0x7FA381), UIColor(rgb: 0xFFF5C5), @@ -183,24 +80,6 @@ public final class GradientBackgroundNode: ASDisplayNode { } self.view.addSubview(self.dimView) - - /*if #available(iOS 10.0, *) { - let timer = Timer(timeInterval: 2.0, repeats: true, block: { [weak self] _ in - guard let strongSelf = self else { - return - } - strongSelf.phase = (strongSelf.phase + 1) % 4 - if let size = strongSelf.validLayout { - strongSelf.updateLayout(size: size, transition: .animated(duration: 0.5, curve: .spring)) - } - }) - self.timer = timer - RunLoop.main.add(timer, forMode: .common) - }*/ - } - - deinit { - self.timer?.invalidate() } public func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) { @@ -211,10 +90,10 @@ public final class GradientBackgroundNode: ASDisplayNode { let positions: [CGPoint] let basePositions: [CGPoint] = [ - CGPoint(x: 0.1, y: 0.1), - CGPoint(x: 0.1, y: 0.9), - CGPoint(x: 0.9, y: 0.9), - CGPoint(x: 0.9, y: 0.1), + CGPoint(x: 0.2, y: 0.2), + CGPoint(x: 0.2, y: 0.8), + CGPoint(x: 0.8, y: 0.8), + CGPoint(x: 0.8, y: 0.2), ] switch self.phase % 4 { @@ -230,7 +109,7 @@ public final class GradientBackgroundNode: ASDisplayNode { preconditionFailure() } - for i in 0 ..< firstStepPoints.count { + for i in 0 ..< positions.count { if self.pointImages.count <= i { break } diff --git a/submodules/Postbox/Sources/TimestampBasedMessageAttributesTable.swift b/submodules/Postbox/Sources/TimestampBasedMessageAttributesTable.swift index 8285b09ee2..541cf987e4 100644 --- a/submodules/Postbox/Sources/TimestampBasedMessageAttributesTable.swift +++ b/submodules/Postbox/Sources/TimestampBasedMessageAttributesTable.swift @@ -1,6 +1,6 @@ import Foundation -public struct TimestampBasedMessageAttributesEntry { +public struct TimestampBasedMessageAttributesEntry: CustomStringConvertible { public let tag: UInt16 public let timestamp: Int32 public let messageId: MessageId @@ -8,6 +8,10 @@ public struct TimestampBasedMessageAttributesEntry { public var index: MessageIndex { return MessageIndex(id: self.messageId, timestamp: timestamp) } + + public var description: String { + return "(tag: \(self.tag), timestamp: \(self.timestamp), messageId: \(self.messageId))" + } } enum TimestampBasedMessageAttributesOperation { @@ -53,7 +57,11 @@ final class TimestampBasedMessageAttributesTable: Table { } func set(tag: UInt16, id: MessageId, timestamp: Int32, operations: inout [TimestampBasedMessageAttributesOperation]) { - if let previousTimestamp = self.indexTable.get(tag: tag, id: id) { + let previousTimestamp = self.indexTable.get(tag: tag, id: id) + + postboxLog("TimestampBasedMessageAttributesTable set(tag: \(tag), id: \(id), timestamp: \(timestamp)) previousTimestamp: \(String(describing: previousTimestamp))") + + if let previousTimestamp = previousTimestamp { if previousTimestamp == timestamp { return } else { @@ -67,7 +75,11 @@ final class TimestampBasedMessageAttributesTable: Table { } func remove(tag: UInt16, id: MessageId, operations: inout [TimestampBasedMessageAttributesOperation]) { - if let previousTimestamp = self.indexTable.get(tag: tag, id: id) { + let previousTimestamp = self.indexTable.get(tag: tag, id: id) + + postboxLog("TimestampBasedMessageAttributesTable remove(tag: \(tag), id: \(id)) previousTimestamp: \(String(describing: previousTimestamp))") + + if let previousTimestamp = previousTimestamp { self.valueBox.remove(self.table, key: self.key(tag: tag, timestamp: previousTimestamp, id: id), secure: false) self.indexTable.remove(tag: tag, id: id) operations.append(.remove(TimestampBasedMessageAttributesEntry(tag: tag, timestamp: previousTimestamp, messageId: id))) diff --git a/submodules/Postbox/Sources/TimestampBasedMessageAttributesView.swift b/submodules/Postbox/Sources/TimestampBasedMessageAttributesView.swift index bbff66b6d0..a253f1ba23 100644 --- a/submodules/Postbox/Sources/TimestampBasedMessageAttributesView.swift +++ b/submodules/Postbox/Sources/TimestampBasedMessageAttributesView.swift @@ -7,6 +7,8 @@ final class MutableTimestampBasedMessageAttributesView { init(postbox: Postbox, tag: UInt16) { self.tag = tag self.head = postbox.timestampBasedMessageAttributesTable.head(tag: tag) + + postboxLog("MutableTimestampBasedMessageAttributesView: tag: \(tag) head: \(String(describing: self.head))") } func replay(postbox: Postbox, operations: [TimestampBasedMessageAttributesOperation]) -> Bool { diff --git a/submodules/TelegramCore/Sources/State/ManagedAutoremoveMessageOperations.swift b/submodules/TelegramCore/Sources/State/ManagedAutoremoveMessageOperations.swift index 6d739dd4a3..ea0c902016 100644 --- a/submodules/TelegramCore/Sources/State/ManagedAutoremoveMessageOperations.swift +++ b/submodules/TelegramCore/Sources/State/ManagedAutoremoveMessageOperations.swift @@ -62,7 +62,9 @@ func managedAutoremoveMessageOperations(network: Network, postbox: Postbox, isRe |> distinctUntilChanged*/ let timeOffset: Signal = .single(0.0) - + + Logger.shared.log("Autoremove", "starting isRemove: \(isRemove)") + let disposable = combineLatest(timeOffset, postbox.timestampBasedMessageAttributesView(tag: isRemove ? 0 : 1)).start(next: { timeOffset, view in let (disposeOperations, beginOperations) = helper.with { helper -> (disposeOperations: [Disposable], beginOperations: [(TimestampBasedMessageAttributesEntry, MetaDisposable)]) in return helper.update(view.head) diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index f000849f15..cd921e97bf 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit f000849f159e255fabec70ea18312eb8ae6c69e0 +Subproject commit cd921e97bfc6af347ff7f938bd2f40e839f64f79