mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Refactoring
This commit is contained in:
parent
f675add6f9
commit
2d66131682
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/TelegramAudio:TelegramAudio",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -536,7 +536,7 @@ public enum CreateGroupMode {
|
||||
case locatedGroup(latitude: Double, longitude: Double, address: String?)
|
||||
}
|
||||
|
||||
public protocol AppLockContext: class {
|
||||
public protocol AppLockContext: AnyObject {
|
||||
var invalidAttempts: Signal<AccessChallengeAttempts?, NoError> { get }
|
||||
var autolockDeadline: Signal<Int32?, NoError> { get }
|
||||
|
||||
@ -545,10 +545,10 @@ public protocol AppLockContext: class {
|
||||
func failedUnlockAttempt()
|
||||
}
|
||||
|
||||
public protocol RecentSessionsController: class {
|
||||
public protocol RecentSessionsController: AnyObject {
|
||||
}
|
||||
|
||||
public protocol SharedAccountContext: class {
|
||||
public protocol SharedAccountContext: AnyObject {
|
||||
var sharedContainerPath: String { get }
|
||||
var basePath: String { get }
|
||||
var mainWindow: Window1? { get }
|
||||
@ -703,16 +703,16 @@ public final class TonContext {
|
||||
public protocol ComposeController: ViewController {
|
||||
}
|
||||
|
||||
public protocol ChatLocationContextHolder: class {
|
||||
public protocol ChatLocationContextHolder: AnyObject {
|
||||
}
|
||||
|
||||
public protocol AccountGroupCallContext: class {
|
||||
public protocol AccountGroupCallContext: AnyObject {
|
||||
}
|
||||
|
||||
public protocol AccountGroupCallContextCache: class {
|
||||
public protocol AccountGroupCallContextCache: AnyObject {
|
||||
}
|
||||
|
||||
public protocol AccountContext: class {
|
||||
public protocol AccountContext: AnyObject {
|
||||
var sharedContext: SharedAccountContext { get }
|
||||
var account: Account { get }
|
||||
var engine: TelegramEngine { get }
|
||||
|
@ -6,7 +6,7 @@ import SwiftSignalKit
|
||||
|
||||
public typealias DeviceContactStableId = String
|
||||
|
||||
public protocol DeviceContactDataManager: class {
|
||||
public protocol DeviceContactDataManager: AnyObject {
|
||||
func personNameDisplayOrder() -> Signal<PresentationPersonNameOrder, NoError>
|
||||
func basicData() -> Signal<[DeviceContactStableId: DeviceContactBasicData], NoError>
|
||||
func basicDataForNormalizedPhoneNumber(_ normalizedNumber: DeviceContactNormalizedPhoneNumber) -> Signal<[(DeviceContactStableId, DeviceContactBasicData)], NoError>
|
||||
|
@ -4,7 +4,7 @@ import Postbox
|
||||
import TelegramUIPreferences
|
||||
import SwiftSignalKit
|
||||
|
||||
public protocol DownloadedMediaStoreManager: class {
|
||||
public protocol DownloadedMediaStoreManager: AnyObject {
|
||||
func store(_ media: AnyMediaReference, timestamp: Int32, peerType: MediaAutoDownloadPeerType)
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,8 @@ public func isMediaStreamable(message: Message, media: TelegramMediaFile) -> Boo
|
||||
return false
|
||||
}
|
||||
for attribute in media.attributes {
|
||||
if case let .Video(video) = attribute {
|
||||
if video.flags.contains(.supportsStreaming) {
|
||||
if case let .Video(_, _, flags) = attribute {
|
||||
if flags.contains(.supportsStreaming) {
|
||||
return true
|
||||
}
|
||||
break
|
||||
@ -41,8 +41,8 @@ public func isMediaStreamable(media: TelegramMediaFile) -> Bool {
|
||||
return false
|
||||
}
|
||||
for attribute in media.attributes {
|
||||
if case let .Video(video) = attribute {
|
||||
if video.flags.contains(.supportsStreaming) {
|
||||
if case let .Video(_, _, flags) = attribute {
|
||||
if flags.contains(.supportsStreaming) {
|
||||
return true
|
||||
}
|
||||
break
|
||||
|
@ -132,7 +132,7 @@ public enum MediaManagerPlayerType {
|
||||
case file
|
||||
}
|
||||
|
||||
public protocol MediaManager: class {
|
||||
public protocol MediaManager: AnyObject {
|
||||
var audioSession: ManagedAudioSession { get }
|
||||
var galleryHiddenMediaManager: GalleryHiddenMediaManager { get }
|
||||
var universalVideoManager: UniversalVideoManager { get }
|
||||
@ -177,11 +177,11 @@ public enum GalleryHiddenMediaId: Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol GalleryHiddenMediaTarget: class {
|
||||
public protocol GalleryHiddenMediaTarget: AnyObject {
|
||||
func getTransitionInfo(messageId: MessageId, media: Media) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))?
|
||||
}
|
||||
|
||||
public protocol GalleryHiddenMediaManager: class {
|
||||
public protocol GalleryHiddenMediaManager: AnyObject {
|
||||
func hiddenIds() -> Signal<Set<GalleryHiddenMediaId>, NoError>
|
||||
func addSource(_ signal: Signal<GalleryHiddenMediaId?, NoError>) -> Int
|
||||
func removeSource(_ index: Int)
|
||||
@ -190,7 +190,7 @@ public protocol GalleryHiddenMediaManager: class {
|
||||
func findTarget(messageId: MessageId, media: Media) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))?
|
||||
}
|
||||
|
||||
public protocol UniversalVideoManager: class {
|
||||
public protocol UniversalVideoManager: AnyObject {
|
||||
func attachUniversalVideoContent(content: UniversalVideoContent, priority: UniversalVideoPriority, create: () -> UniversalVideoContentNode & ASDisplayNode, update: @escaping (((UniversalVideoContentNode & ASDisplayNode), Bool)?) -> Void) -> (AnyHashable, Int32)
|
||||
func detachUniversalVideoContent(id: AnyHashable, index: Int32)
|
||||
func withUniversalVideoContent(id: AnyHashable, _ f: ((UniversalVideoContentNode & ASDisplayNode)?) -> Void)
|
||||
@ -218,7 +218,7 @@ public struct RecordedAudioData {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol ManagedAudioRecorder: class {
|
||||
public protocol ManagedAudioRecorder: AnyObject {
|
||||
var beginWithTone: Bool { get }
|
||||
var micLevel: Signal<Float, NoError> { get }
|
||||
var recordingState: Signal<AudioRecordingState, NoError> { get }
|
||||
|
@ -1,5 +1,5 @@
|
||||
import Foundation
|
||||
|
||||
public protocol OverlayAudioPlayerController: class {
|
||||
public protocol OverlayAudioPlayerController: AnyObject {
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public final class OverlayMediaControllerEmbeddingItem {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol OverlayMediaController: class {
|
||||
public protocol OverlayMediaController: AnyObject {
|
||||
var updatePossibleEmbeddingItem: ((OverlayMediaControllerEmbeddingItem?) -> Void)? { get set }
|
||||
var embedPossibleEmbeddingItem: ((OverlayMediaControllerEmbeddingItem) -> Bool)? { get set }
|
||||
|
||||
|
@ -131,7 +131,7 @@ public final class PresentationCallVideoView {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol PresentationCall: class {
|
||||
public protocol PresentationCall: AnyObject {
|
||||
var context: AccountContext { get }
|
||||
var isIntegratedWithCallKit: Bool { get }
|
||||
var internalId: CallSessionInternalId { get }
|
||||
@ -391,7 +391,7 @@ public extension GroupCallParticipantsContext.Participant {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol PresentationGroupCall: class {
|
||||
public protocol PresentationGroupCall: AnyObject {
|
||||
var account: Account { get }
|
||||
var accountContext: AccountContext { get }
|
||||
var internalId: CallSessionInternalId { get }
|
||||
|
@ -156,7 +156,7 @@ public protocol SharedMediaPlaylistLocation {
|
||||
func isEqual(to: SharedMediaPlaylistLocation) -> Bool
|
||||
}
|
||||
|
||||
public protocol SharedMediaPlaylist: class {
|
||||
public protocol SharedMediaPlaylist: AnyObject {
|
||||
var id: SharedMediaPlaylistId { get }
|
||||
var location: SharedMediaPlaylistLocation { get }
|
||||
var state: Signal<SharedMediaPlaylistState, NoError> { get }
|
||||
|
@ -3,5 +3,5 @@ import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
|
||||
public protocol ThemeUpdateManager: class {
|
||||
public protocol ThemeUpdateManager: AnyObject {
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import Display
|
||||
import TelegramAudio
|
||||
import UniversalMediaPlayer
|
||||
|
||||
public protocol UniversalVideoContentNode: class {
|
||||
public protocol UniversalVideoContentNode: AnyObject {
|
||||
var ready: Signal<Void, NoError> { get }
|
||||
var status: Signal<MediaPlayerStatus, NoError> { get }
|
||||
var bufferingStatus: Signal<(IndexSet, Int)?, NoError> { get }
|
||||
@ -47,7 +47,7 @@ public extension UniversalVideoContent {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol UniversalVideoDecoration: class {
|
||||
public protocol UniversalVideoDecoration: AnyObject {
|
||||
var backgroundNode: ASDisplayNode? { get }
|
||||
var contentContainerNode: ASDisplayNode { get }
|
||||
var foregroundNode: ASDisplayNode? { get }
|
||||
|
@ -18,7 +18,7 @@ public enum WallpaperUploadManagerStatus {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol WallpaperUploadManager: class {
|
||||
public protocol WallpaperUploadManager: AnyObject {
|
||||
func stateSignal() -> Signal<WallpaperUploadManagerStatus, NoError>
|
||||
func presentationDataUpdated(_ presentationData: PresentationData)
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public struct WatchRunningTasks: Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol WatchManager: class {
|
||||
public protocol WatchManager: AnyObject {
|
||||
var watchAppInstalled: Signal<Bool, NoError> { get }
|
||||
var navigateToMessageRequested: Signal<MessageId, NoError> { get }
|
||||
var runningTasks: Signal<WatchRunningTasks?, NoError> { get }
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/Postbox:Postbox",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/Display:Display",
|
||||
],
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -88,7 +88,7 @@ public final class AnimatedStickerFrame {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol AnimatedStickerFrameSource: class {
|
||||
public protocol AnimatedStickerFrameSource: AnyObject {
|
||||
var frameRate: Int { get }
|
||||
var frameCount: Int { get }
|
||||
var frameIndex: Int { get }
|
||||
@ -139,7 +139,10 @@ public final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource
|
||||
var frameRate = 0
|
||||
var frameCount = 0
|
||||
|
||||
if !self.data.withUnsafeBytes({ (bytes: UnsafePointer<UInt8>) -> Bool in
|
||||
if !self.data.withUnsafeBytes({ buffer -> Bool in
|
||||
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return false
|
||||
}
|
||||
var frameRateValue: Int32 = 0
|
||||
var frameCountValue: Int32 = 0
|
||||
var widthValue: Int32 = 0
|
||||
@ -180,7 +183,10 @@ public final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource
|
||||
self.decodeBuffer = Data(count: self.bytesPerRow * height)
|
||||
self.frameBuffer = Data(count: self.bytesPerRow * height)
|
||||
let frameBufferLength = self.frameBuffer.count
|
||||
self.frameBuffer.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
self.frameBuffer.withUnsafeMutableBytes { buffer -> Void in
|
||||
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
memset(bytes, 0, frameBufferLength)
|
||||
}
|
||||
}
|
||||
@ -199,12 +205,19 @@ public final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource
|
||||
|
||||
let frameIndex = self.frameIndex
|
||||
|
||||
self.data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Void in
|
||||
self.data.withUnsafeBytes { buffer -> Void in
|
||||
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
|
||||
if self.offset + 4 > dataLength {
|
||||
if self.dataComplete {
|
||||
self.frameIndex = 0
|
||||
self.offset = self.initialOffset
|
||||
self.frameBuffer.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
self.frameBuffer.withUnsafeMutableBytes { buffer -> Void in
|
||||
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
memset(bytes, 0, frameBufferLength)
|
||||
}
|
||||
}
|
||||
@ -221,9 +234,21 @@ public final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource
|
||||
self.offset += 4
|
||||
|
||||
if draw {
|
||||
self.scratchBuffer.withUnsafeMutableBytes { (scratchBytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
self.decodeBuffer.withUnsafeMutableBytes { (decodeBytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
self.frameBuffer.withUnsafeMutableBytes { (frameBytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
self.scratchBuffer.withUnsafeMutableBytes { scratchBuffer -> Void in
|
||||
guard let scratchBytes = scratchBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
|
||||
self.decodeBuffer.withUnsafeMutableBytes { decodeBuffer -> Void in
|
||||
guard let decodeBytes = decodeBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
|
||||
self.frameBuffer.withUnsafeMutableBytes { frameBuffer -> Void in
|
||||
guard let frameBytes = frameBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
|
||||
compression_decode_buffer(decodeBytes, decodeBufferLength, bytes.advanced(by: self.offset), Int(frameLength), UnsafeMutableRawPointer(scratchBytes), COMPRESSION_LZFSE)
|
||||
|
||||
var lhs = UnsafeMutableRawPointer(frameBytes).assumingMemoryBound(to: UInt64.self)
|
||||
@ -253,7 +278,10 @@ public final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource
|
||||
isLastFrame = true
|
||||
self.frameIndex = 0
|
||||
self.offset = self.initialOffset
|
||||
self.frameBuffer.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
self.frameBuffer.withUnsafeMutableBytes { buffer -> Void in
|
||||
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
memset(bytes, 0, frameBufferLength)
|
||||
}
|
||||
}
|
||||
@ -351,7 +379,10 @@ private final class ManagedFileImpl {
|
||||
assert(queue.isCurrent())
|
||||
}
|
||||
var result = Data(count: count)
|
||||
result.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<Int8>) -> Void in
|
||||
result.withUnsafeMutableBytes { buffer -> Void in
|
||||
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
let readCount = self.read(bytes, count)
|
||||
assert(readCount == count)
|
||||
}
|
||||
@ -399,7 +430,7 @@ private func compressFrame(width: Int, height: Int, rgbData: Data) -> Data? {
|
||||
assert(yuvaPixelsPerAlphaRow % 2 == 0)
|
||||
|
||||
let yuvaLength = Int(width) * Int(height) * 2 + yuvaPixelsPerAlphaRow * Int(height) / 2
|
||||
var yuvaFrameData = malloc(yuvaLength)!
|
||||
let yuvaFrameData = malloc(yuvaLength)!
|
||||
defer {
|
||||
free(yuvaFrameData)
|
||||
}
|
||||
@ -422,7 +453,10 @@ private func compressFrame(width: Int, height: Int, rgbData: Data) -> Data? {
|
||||
|
||||
var maybeResultSize: Int?
|
||||
|
||||
compressedFrameData.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
compressedFrameData.withUnsafeMutableBytes { buffer -> Void in
|
||||
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
let length = compression_encode_buffer(bytes, compressedFrameDataLength, yuvaFrameData.assumingMemoryBound(to: UInt8.self), yuvaLength, scratchData, COMPRESSION_LZFSE)
|
||||
maybeResultSize = length
|
||||
}
|
||||
@ -579,9 +613,21 @@ private final class AnimatedStickerDirectFrameSourceCache {
|
||||
|
||||
let decodeBufferLength = self.decodeBuffer.count
|
||||
|
||||
compressedData.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Void in
|
||||
self.scratchBuffer.withUnsafeMutableBytes { (scratchBytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
self.decodeBuffer.withUnsafeMutableBytes { (decodeBytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
compressedData.withUnsafeBytes { buffer -> Void in
|
||||
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
|
||||
self.scratchBuffer.withUnsafeMutableBytes { scratchBuffer -> Void in
|
||||
guard let scratchBytes = scratchBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
|
||||
self.decodeBuffer.withUnsafeMutableBytes { decodeBuffer -> Void in
|
||||
guard let decodeBytes = decodeBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
|
||||
let resultLength = compression_decode_buffer(decodeBytes, decodeBufferLength, bytes, length, UnsafeMutableRawPointer(scratchBytes), COMPRESSION_LZFSE)
|
||||
|
||||
frameData = Data(bytes: decodeBytes, count: resultLength)
|
||||
@ -644,7 +690,11 @@ private final class AnimatedStickerDirectFrameSource: AnimatedStickerFrameSource
|
||||
return AnimatedStickerFrame(data: yuvData, type: .yuva, width: self.width, height: self.height, bytesPerRow: 0, index: frameIndex, isLastFrame: frameIndex == self.frameCount - 1, totalFrames: self.frameCount)
|
||||
} else {
|
||||
var frameData = Data(count: self.bytesPerRow * self.height)
|
||||
frameData.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Void in
|
||||
frameData.withUnsafeMutableBytes { buffer -> Void in
|
||||
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
|
||||
memset(bytes, 0, self.bytesPerRow * self.height)
|
||||
self.animation.renderFrame(with: Int32(frameIndex), into: bytes, width: Int32(self.width), height: Int32(self.height), bytesPerRow: Int32(self.bytesPerRow))
|
||||
}
|
||||
@ -853,7 +903,7 @@ public final class AnimatedStickerNode: ASDisplayNode {
|
||||
strongSelf.isSetUpForPlayback = false
|
||||
strongSelf.isPlaying = true
|
||||
}
|
||||
var fromIndex = strongSelf.playFromIndex
|
||||
let fromIndex = strongSelf.playFromIndex
|
||||
strongSelf.playFromIndex = nil
|
||||
strongSelf.play(fromIndex: fromIndex)
|
||||
} else if strongSelf.canDisplayFirstFrame {
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/rlottie:RLottieBinding",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
|
@ -150,7 +150,7 @@ public final class AppLockContextImpl: AppLockContext {
|
||||
strongSelf.autolockTimeout.set(nil)
|
||||
strongSelf.autolockReportTimeout.set(nil)
|
||||
} else {
|
||||
if let autolockTimeout = passcodeSettings.autolockTimeout, !appInForeground {
|
||||
if let _ = passcodeSettings.autolockTimeout, !appInForeground {
|
||||
shouldDisplayCoveringView = true
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ public final class AppLockContextImpl: AppLockContext {
|
||||
}
|
||||
passcodeController.ensureInputFocused()
|
||||
} else {
|
||||
let passcodeController = PasscodeEntryController(applicationBindings: strongSelf.applicationBindings, accountManager: strongSelf.accountManager, appLockContext: strongSelf, presentationData: presentationData, presentationDataSignal: strongSelf.presentationDataSignal, statusBarHost: window?.statusBarHost, challengeData: accessChallengeData.data, biometrics: biometrics, arguments: PasscodeEntryControllerPresentationArguments(animated: !becameActiveRecently, lockIconInitialFrame: { [weak self] in
|
||||
let passcodeController = PasscodeEntryController(applicationBindings: strongSelf.applicationBindings, accountManager: strongSelf.accountManager, appLockContext: strongSelf, presentationData: presentationData, presentationDataSignal: strongSelf.presentationDataSignal, statusBarHost: window?.statusBarHost, challengeData: accessChallengeData.data, biometrics: biometrics, arguments: PasscodeEntryControllerPresentationArguments(animated: !becameActiveRecently, lockIconInitialFrame: {
|
||||
if let lockViewFrame = lockIconInitialFrame() {
|
||||
return lockViewFrame
|
||||
} else {
|
||||
@ -203,7 +203,7 @@ public final class AppLockContextImpl: AppLockContext {
|
||||
passcodeController.isOpaqueWhenInOverlay = true
|
||||
strongSelf.passcodeController = passcodeController
|
||||
if let rootViewController = strongSelf.rootController {
|
||||
if let presentedViewController = rootViewController.presentedViewController as? UIActivityViewController {
|
||||
if let _ = rootViewController.presentedViewController as? UIActivityViewController {
|
||||
} else {
|
||||
rootViewController.dismiss(animated: false, completion: nil)
|
||||
}
|
||||
@ -227,14 +227,14 @@ public final class AppLockContextImpl: AppLockContext {
|
||||
window.coveringView = coveringView
|
||||
|
||||
if let rootViewController = strongSelf.rootController {
|
||||
if let presentedViewController = rootViewController.presentedViewController as? UIActivityViewController {
|
||||
if let _ = rootViewController.presentedViewController as? UIActivityViewController {
|
||||
} else {
|
||||
rootViewController.dismiss(animated: false, completion: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let coveringView = strongSelf.coveringView {
|
||||
if let _ = strongSelf.coveringView {
|
||||
strongSelf.coveringView = nil
|
||||
strongSelf.window?.coveringView = nil
|
||||
}
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -151,14 +151,14 @@ private final class ArchivedStickersNoticeAlertContentNode: AlertContentNode {
|
||||
}
|
||||
|
||||
private func dequeueTransition() {
|
||||
guard let layout = self.validLayout, let transition = self.enqueuedTransitions.first else {
|
||||
guard let _ = self.validLayout, let transition = self.enqueuedTransitions.first else {
|
||||
return
|
||||
}
|
||||
self.enqueuedTransitions.remove(at: 0)
|
||||
|
||||
var options = ListViewDeleteAndInsertOptions()
|
||||
let options = ListViewDeleteAndInsertOptions()
|
||||
|
||||
self.listView.transaction(deleteIndices: transition.deletions, insertIndicesAndItems: transition.insertions, updateIndicesAndItems: transition.updates, options: options, updateSizeAndInsets: nil, updateOpaqueState: nil, completion: { [weak self] _ in
|
||||
self.listView.transaction(deleteIndices: transition.deletions, insertIndicesAndItems: transition.insertions, updateIndicesAndItems: transition.updates, options: options, updateSizeAndInsets: nil, updateOpaqueState: nil, completion: { _ in
|
||||
})
|
||||
}
|
||||
|
||||
@ -302,14 +302,14 @@ public func archivedStickerPacksNoticeController(context: AccountContext, archiv
|
||||
})])
|
||||
|
||||
let controller = AlertController(theme: AlertControllerTheme(presentationData: presentationData), contentNode: contentNode)
|
||||
let presentationDataDisposable = context.sharedContext.presentationData.start(next: { [weak controller, weak contentNode] presentationData in
|
||||
let presentationDataDisposable = context.sharedContext.presentationData.start(next: { [weak controller] presentationData in
|
||||
controller?.theme = AlertControllerTheme(presentationData: presentationData)
|
||||
})
|
||||
controller.dismissed = {
|
||||
presentationDataDisposable.dispose()
|
||||
disposable.dispose()
|
||||
}
|
||||
dismissImpl = { [weak controller, weak contentNode] in
|
||||
dismissImpl = { [weak controller] in
|
||||
controller?.dismissAnimated()
|
||||
}
|
||||
return controller
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
|
@ -253,12 +253,10 @@ private final class AuthDataTransferSplashScreenNode: ViewControllerTracingNode
|
||||
let animationFitSize = CGSize(width: min(500.0, layout.size.width - sideInset + 20.0), height: 500.0)
|
||||
let animationSize = self.animationNode?.preferredSize()?.fitted(animationFitSize) ?? animationFitSize
|
||||
let iconSize: CGSize = animationSize
|
||||
var iconOffset = CGPoint()
|
||||
let iconOffset = CGPoint()
|
||||
|
||||
let titleSize = self.titleNode.updateLayout(CGSize(width: layout.size.width - sideInset * 2.0, height: layout.size.height))
|
||||
|
||||
let hasRTL = self.badgeTextNodes.first?.cachedLayout?.hasRTL ?? false
|
||||
|
||||
var badgeTextSizes: [CGSize] = []
|
||||
var textSizes: [CGSize] = []
|
||||
var textContentHeight: CGFloat = 0.0
|
||||
@ -290,9 +288,9 @@ private final class AuthDataTransferSplashScreenNode: ViewControllerTracingNode
|
||||
|
||||
let buttonFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - buttonWidth) / 2.0), y: layout.size.height - bottomInset - buttonHeight), size: CGSize(width: buttonWidth, height: buttonHeight))
|
||||
transition.updateFrame(node: self.buttonNode, frame: buttonFrame)
|
||||
self.buttonNode.updateLayout(width: buttonFrame.width, transition: transition)
|
||||
let _ = self.buttonNode.updateLayout(width: buttonFrame.width, transition: transition)
|
||||
|
||||
var maxContentVerticalOrigin = buttonFrame.minY - 12.0 - contentHeight
|
||||
let maxContentVerticalOrigin = buttonFrame.minY - 12.0 - contentHeight
|
||||
|
||||
contentVerticalOrigin = min(contentVerticalOrigin, maxContentVerticalOrigin)
|
||||
|
||||
|
@ -44,7 +44,7 @@ private func generateFrameImage() -> UIImage? {
|
||||
context.setLineWidth(4.0)
|
||||
context.setLineCap(.round)
|
||||
|
||||
var path = CGMutablePath();
|
||||
let path = CGMutablePath()
|
||||
path.move(to: CGPoint(x: 2.0, y: 2.0 + 26.0))
|
||||
path.addArc(tangent1End: CGPoint(x: 2.0, y: 2.0), tangent2End: CGPoint(x: 2.0 + 26.0, y: 2.0), radius: 6.0)
|
||||
path.addLine(to: CGPoint(x: 2.0 + 26.0, y: 2.0))
|
||||
@ -412,8 +412,8 @@ private final class AuthTransferScanScreenNode: ViewControllerTracingNode, UIScr
|
||||
let dimAlpha: CGFloat
|
||||
let dimRect: CGRect
|
||||
let controlsAlpha: CGFloat
|
||||
var centerDimAlpha: CGFloat = 0.0
|
||||
var frameAlpha: CGFloat = 1.0
|
||||
let centerDimAlpha: CGFloat = 0.0
|
||||
let frameAlpha: CGFloat = 1.0
|
||||
if let focusedRect = self.focusedRect {
|
||||
controlsAlpha = 0.0
|
||||
dimAlpha = 1.0
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
|
@ -60,8 +60,7 @@ public func peerAvatarImageData(account: Account, peerReference: PeerReference?,
|
||||
subscriber.putNext(nil)
|
||||
}
|
||||
}
|
||||
}, error: { error in
|
||||
subscriber.putError(error)
|
||||
}, error: { _ in
|
||||
}, completed: {
|
||||
subscriber.putCompletion()
|
||||
})
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
|
@ -55,7 +55,7 @@ final class BotCheckoutActionButton: HighlightableButtonNode {
|
||||
let previousState = self.state
|
||||
self.state = state
|
||||
|
||||
if let (absoluteRect, containerSize) = self.validLayout, let previousState = previousState {
|
||||
if let (absoluteRect, containerSize) = self.validLayout, let _ = previousState {
|
||||
self.updateLayout(absoluteRect: absoluteRect, containerSize: containerSize, transition: .immediate)
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ final class BotCheckoutPaymentMethodSheetController: ActionSheetController {
|
||||
|
||||
init(context: AccountContext, currentMethod: BotCheckoutPaymentMethod?, methods: [BotCheckoutPaymentMethod], applyValue: @escaping (BotCheckoutPaymentMethod) -> Void, newCard: @escaping () -> Void) {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let theme = presentationData.theme
|
||||
let strings = presentationData.strings
|
||||
|
||||
super.init(theme: ActionSheetControllerTheme(presentationData: presentationData))
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -321,7 +321,7 @@ final class CallListControllerNode: ASDisplayNode {
|
||||
}, openInfo: { [weak self] peerId, messages in
|
||||
self?.openInfo(peerId, messages)
|
||||
}, delete: { [weak self] messageIds in
|
||||
guard let strongSelf = self, let peerId = messageIds.first?.peerId else {
|
||||
guard let peerId = messageIds.first?.peerId else {
|
||||
return
|
||||
}
|
||||
let _ = (context.engine.data.get(
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
],
|
||||
visibility = [
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -6,11 +6,13 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/TextFormat:TextFormat",
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
|
@ -1,6 +1,5 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TextFormat
|
||||
import AccountContext
|
||||
@ -12,13 +11,13 @@ public enum ChatTextInputMediaRecordingButtonMode: Int32 {
|
||||
}
|
||||
|
||||
public struct ChatInterfaceSelectionState: Codable, Equatable {
|
||||
public let selectedIds: Set<MessageId>
|
||||
public let selectedIds: Set<EngineMessage.Id>
|
||||
|
||||
public static func ==(lhs: ChatInterfaceSelectionState, rhs: ChatInterfaceSelectionState) -> Bool {
|
||||
return lhs.selectedIds == rhs.selectedIds
|
||||
}
|
||||
|
||||
public init(selectedIds: Set<MessageId>) {
|
||||
public init(selectedIds: Set<EngineMessage.Id>) {
|
||||
self.selectedIds = selectedIds
|
||||
}
|
||||
|
||||
@ -26,7 +25,7 @@ public struct ChatInterfaceSelectionState: Codable, Equatable {
|
||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
if let data = try? container.decodeIfPresent(Data.self, forKey: "i") {
|
||||
self.selectedIds = Set(MessageId.decodeArrayFromBuffer(ReadBuffer(data: data)))
|
||||
self.selectedIds = Set(EngineMessage.Id.decodeArrayFromData(data))
|
||||
} else {
|
||||
self.selectedIds = Set()
|
||||
}
|
||||
@ -35,20 +34,19 @@ public struct ChatInterfaceSelectionState: Codable, Equatable {
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
let buffer = WriteBuffer()
|
||||
MessageId.encodeArrayToBuffer(Array(selectedIds), buffer: buffer)
|
||||
let data = EngineMessage.Id.encodeArrayToData(Array(selectedIds))
|
||||
|
||||
try container.encode(buffer.makeData(), forKey: "i")
|
||||
try container.encode(data, forKey: "i")
|
||||
}
|
||||
}
|
||||
|
||||
public struct ChatEditMessageState: Codable, Equatable {
|
||||
public let messageId: MessageId
|
||||
public let messageId: EngineMessage.Id
|
||||
public let inputState: ChatTextInputState
|
||||
public let disableUrlPreview: String?
|
||||
public let inputTextMaxLength: Int32?
|
||||
|
||||
public init(messageId: MessageId, inputState: ChatTextInputState, disableUrlPreview: String?, inputTextMaxLength: Int32?) {
|
||||
public init(messageId: EngineMessage.Id, inputState: ChatTextInputState, disableUrlPreview: String?, inputTextMaxLength: Int32?) {
|
||||
self.messageId = messageId
|
||||
self.inputState = inputState
|
||||
self.disableUrlPreview = disableUrlPreview
|
||||
@ -58,8 +56,8 @@ public struct ChatEditMessageState: Codable, Equatable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
self.messageId = MessageId(
|
||||
peerId: PeerId((try? container.decode(Int64.self, forKey: "mp")) ?? 0),
|
||||
self.messageId = EngineMessage.Id(
|
||||
peerId: EnginePeer.Id((try? container.decode(Int64.self, forKey: "mp")) ?? 0),
|
||||
namespace: (try? container.decode(Int32.self, forKey: "mn")) ?? 0,
|
||||
id: (try? container.decode(Int32.self, forKey: "mi")) ?? 0
|
||||
)
|
||||
@ -102,10 +100,10 @@ public struct ChatEditMessageState: Codable, Equatable {
|
||||
}
|
||||
|
||||
public struct ChatInterfaceMessageActionsState: Codable, Equatable {
|
||||
public var closedButtonKeyboardMessageId: MessageId?
|
||||
public var dismissedButtonKeyboardMessageId: MessageId?
|
||||
public var processedSetupReplyMessageId: MessageId?
|
||||
public var closedPinnedMessageId: MessageId?
|
||||
public var closedButtonKeyboardMessageId: EngineMessage.Id?
|
||||
public var dismissedButtonKeyboardMessageId: EngineMessage.Id?
|
||||
public var processedSetupReplyMessageId: EngineMessage.Id?
|
||||
public var closedPinnedMessageId: EngineMessage.Id?
|
||||
public var closedPeerSpecificPackSetup: Bool = false
|
||||
public var dismissedAddContactPhoneNumber: String?
|
||||
|
||||
@ -122,7 +120,7 @@ public struct ChatInterfaceMessageActionsState: Codable, Equatable {
|
||||
self.dismissedAddContactPhoneNumber = nil
|
||||
}
|
||||
|
||||
public init(closedButtonKeyboardMessageId: MessageId?, dismissedButtonKeyboardMessageId: MessageId?, processedSetupReplyMessageId: MessageId?, closedPinnedMessageId: MessageId?, closedPeerSpecificPackSetup: Bool, dismissedAddContactPhoneNumber: String?) {
|
||||
public init(closedButtonKeyboardMessageId: EngineMessage.Id?, dismissedButtonKeyboardMessageId: EngineMessage.Id?, processedSetupReplyMessageId: EngineMessage.Id?, closedPinnedMessageId: EngineMessage.Id?, closedPeerSpecificPackSetup: Bool, dismissedAddContactPhoneNumber: String?) {
|
||||
self.closedButtonKeyboardMessageId = closedButtonKeyboardMessageId
|
||||
self.dismissedButtonKeyboardMessageId = dismissedButtonKeyboardMessageId
|
||||
self.processedSetupReplyMessageId = processedSetupReplyMessageId
|
||||
@ -135,25 +133,25 @@ public struct ChatInterfaceMessageActionsState: Codable, Equatable {
|
||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
if let closedMessageIdPeerId = try? container.decodeIfPresent(Int64.self, forKey: "cb.p"), let closedMessageIdNamespace = try? container.decodeIfPresent(Int32.self, forKey: "cb.n"), let closedMessageIdId = try? container.decodeIfPresent(Int32.self, forKey: "cb.i") {
|
||||
self.closedButtonKeyboardMessageId = MessageId(peerId: PeerId(closedMessageIdPeerId), namespace: closedMessageIdNamespace, id: closedMessageIdId)
|
||||
self.closedButtonKeyboardMessageId = EngineMessage.Id(peerId: EnginePeer.Id(closedMessageIdPeerId), namespace: closedMessageIdNamespace, id: closedMessageIdId)
|
||||
} else {
|
||||
self.closedButtonKeyboardMessageId = nil
|
||||
}
|
||||
|
||||
if let messageIdPeerId = try? container.decodeIfPresent(Int64.self, forKey: "dismissedbuttons.p"), let messageIdNamespace = try? container.decodeIfPresent(Int32.self, forKey: "dismissedbuttons.n"), let messageIdId = try? container.decodeIfPresent(Int32.self, forKey: "dismissedbuttons.i") {
|
||||
self.dismissedButtonKeyboardMessageId = MessageId(peerId: PeerId(messageIdPeerId), namespace: messageIdNamespace, id: messageIdId)
|
||||
self.dismissedButtonKeyboardMessageId = EngineMessage.Id(peerId: EnginePeer.Id(messageIdPeerId), namespace: messageIdNamespace, id: messageIdId)
|
||||
} else {
|
||||
self.dismissedButtonKeyboardMessageId = nil
|
||||
}
|
||||
|
||||
if let processedMessageIdPeerId = try? container.decodeIfPresent(Int64.self, forKey: "pb.p"), let processedMessageIdNamespace = try? container.decodeIfPresent(Int32.self, forKey: "pb.n"), let processedMessageIdId = try? container.decodeIfPresent(Int32.self, forKey: "pb.i") {
|
||||
self.processedSetupReplyMessageId = MessageId(peerId: PeerId(processedMessageIdPeerId), namespace: processedMessageIdNamespace, id: processedMessageIdId)
|
||||
self.processedSetupReplyMessageId = EngineMessage.Id(peerId: EnginePeer.Id(processedMessageIdPeerId), namespace: processedMessageIdNamespace, id: processedMessageIdId)
|
||||
} else {
|
||||
self.processedSetupReplyMessageId = nil
|
||||
}
|
||||
|
||||
if let closedPinnedMessageIdPeerId = try? container.decodeIfPresent(Int64.self, forKey: "cp.p"), let closedPinnedMessageIdNamespace = try? container.decodeIfPresent(Int32.self, forKey: "cp.n"), let closedPinnedMessageIdId = try? container.decodeIfPresent(Int32.self, forKey: "cp.i") {
|
||||
self.closedPinnedMessageId = MessageId(peerId: PeerId(closedPinnedMessageIdPeerId), namespace: closedPinnedMessageIdNamespace, id: closedPinnedMessageIdId)
|
||||
self.closedPinnedMessageId = EngineMessage.Id(peerId: EnginePeer.Id(closedPinnedMessageIdPeerId), namespace: closedPinnedMessageIdNamespace, id: closedPinnedMessageIdId)
|
||||
} else {
|
||||
self.closedPinnedMessageId = nil
|
||||
}
|
||||
@ -217,10 +215,10 @@ public struct ChatInterfaceMessageActionsState: Codable, Equatable {
|
||||
}
|
||||
|
||||
public struct ChatInterfaceHistoryScrollState: Codable, Equatable {
|
||||
public let messageIndex: MessageIndex
|
||||
public let messageIndex: EngineMessage.Index
|
||||
public let relativeOffset: Double
|
||||
|
||||
public init(messageIndex: MessageIndex, relativeOffset: Double) {
|
||||
public init(messageIndex: EngineMessage.Index, relativeOffset: Double) {
|
||||
self.messageIndex = messageIndex
|
||||
self.relativeOffset = relativeOffset
|
||||
}
|
||||
@ -228,9 +226,9 @@ public struct ChatInterfaceHistoryScrollState: Codable, Equatable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
self.messageIndex = MessageIndex(
|
||||
id: MessageId(
|
||||
peerId: PeerId((try? container.decode(Int64.self, forKey: "m.p")) ?? 0),
|
||||
self.messageIndex = EngineMessage.Index(
|
||||
id: EngineMessage.Id(
|
||||
peerId: EnginePeer.Id((try? container.decode(Int64.self, forKey: "m.p")) ?? 0),
|
||||
namespace: (try? container.decode(Int32.self, forKey: "m.n")) ?? 0,
|
||||
id: (try? container.decode(Int32.self, forKey: "m.i")) ?? 0
|
||||
),
|
||||
@ -264,8 +262,8 @@ public final class ChatInterfaceState: Codable, Equatable {
|
||||
public let timestamp: Int32
|
||||
public let composeInputState: ChatTextInputState
|
||||
public let composeDisableUrlPreview: String?
|
||||
public let replyMessageId: MessageId?
|
||||
public let forwardMessageIds: [MessageId]?
|
||||
public let replyMessageId: EngineMessage.Id?
|
||||
public let forwardMessageIds: [EngineMessage.Id]?
|
||||
public let editMessage: ChatEditMessageState?
|
||||
public let selectionState: ChatInterfaceSelectionState?
|
||||
public let messageActionsState: ChatInterfaceMessageActionsState
|
||||
@ -290,7 +288,7 @@ public final class ChatInterfaceState: Codable, Equatable {
|
||||
return result
|
||||
}
|
||||
|
||||
public var historyScrollMessageIndex: MessageIndex? {
|
||||
public var historyScrollMessageIndex: EngineMessage.Index? {
|
||||
return self.historyScrollState?.messageIndex
|
||||
}
|
||||
|
||||
@ -317,7 +315,7 @@ public final class ChatInterfaceState: Codable, Equatable {
|
||||
self.inputLanguage = nil
|
||||
}
|
||||
|
||||
public init(timestamp: Int32, composeInputState: ChatTextInputState, composeDisableUrlPreview: String?, replyMessageId: MessageId?, forwardMessageIds: [MessageId]?, editMessage: ChatEditMessageState?, selectionState: ChatInterfaceSelectionState?, messageActionsState: ChatInterfaceMessageActionsState, historyScrollState: ChatInterfaceHistoryScrollState?, mediaRecordingMode: ChatTextInputMediaRecordingButtonMode, silentPosting: Bool, inputLanguage: String?) {
|
||||
public init(timestamp: Int32, composeInputState: ChatTextInputState, composeDisableUrlPreview: String?, replyMessageId: EngineMessage.Id?, forwardMessageIds: [EngineMessage.Id]?, editMessage: ChatEditMessageState?, selectionState: ChatInterfaceSelectionState?, messageActionsState: ChatInterfaceMessageActionsState, historyScrollState: ChatInterfaceHistoryScrollState?, mediaRecordingMode: ChatTextInputMediaRecordingButtonMode, silentPosting: Bool, inputLanguage: String?) {
|
||||
self.timestamp = timestamp
|
||||
self.composeInputState = composeInputState
|
||||
self.composeDisableUrlPreview = composeDisableUrlPreview
|
||||
@ -350,12 +348,12 @@ public final class ChatInterfaceState: Codable, Equatable {
|
||||
let replyMessageIdNamespace: Int32? = try? container.decodeIfPresent(Int32.self, forKey: "r.n")
|
||||
let replyMessageIdId: Int32? = try? container.decodeIfPresent(Int32.self, forKey: "r.i")
|
||||
if let replyMessageIdPeerId = replyMessageIdPeerId, let replyMessageIdNamespace = replyMessageIdNamespace, let replyMessageIdId = replyMessageIdId {
|
||||
self.replyMessageId = MessageId(peerId: PeerId(replyMessageIdPeerId), namespace: replyMessageIdNamespace, id: replyMessageIdId)
|
||||
self.replyMessageId = EngineMessage.Id(peerId: EnginePeer.Id(replyMessageIdPeerId), namespace: replyMessageIdNamespace, id: replyMessageIdId)
|
||||
} else {
|
||||
self.replyMessageId = nil
|
||||
}
|
||||
if let forwardMessageIdsData = try? container.decodeIfPresent(Data.self, forKey: "fm") {
|
||||
self.forwardMessageIds = MessageId.decodeArrayFromBuffer(ReadBuffer(data: forwardMessageIdsData))
|
||||
self.forwardMessageIds = EngineMessage.Id.decodeArrayFromData(forwardMessageIdsData)
|
||||
} else {
|
||||
self.forwardMessageIds = nil
|
||||
}
|
||||
@ -404,9 +402,7 @@ public final class ChatInterfaceState: Codable, Equatable {
|
||||
try container.encodeNil(forKey: "r.i")
|
||||
}
|
||||
if let forwardMessageIds = self.forwardMessageIds {
|
||||
let buffer = WriteBuffer()
|
||||
MessageId.encodeArrayToBuffer(forwardMessageIds, buffer: buffer)
|
||||
try container.encode(buffer.makeData(), forKey: "fm")
|
||||
try container.encode(EngineMessage.Id.encodeArrayToData(forwardMessageIds), forKey: "fm")
|
||||
} else {
|
||||
try container.encodeNil(forKey: "fm")
|
||||
}
|
||||
@ -490,16 +486,16 @@ public final class ChatInterfaceState: Codable, Equatable {
|
||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: updatedComposeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: updatedEditMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||
}
|
||||
|
||||
public func withUpdatedReplyMessageId(_ replyMessageId: MessageId?) -> ChatInterfaceState {
|
||||
public func withUpdatedReplyMessageId(_ replyMessageId: EngineMessage.Id?) -> ChatInterfaceState {
|
||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||
}
|
||||
|
||||
public func withUpdatedForwardMessageIds(_ forwardMessageIds: [MessageId]?) -> ChatInterfaceState {
|
||||
public func withUpdatedForwardMessageIds(_ forwardMessageIds: [EngineMessage.Id]?) -> ChatInterfaceState {
|
||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||
}
|
||||
|
||||
public func withUpdatedSelectedMessages(_ messageIds: [MessageId]) -> ChatInterfaceState {
|
||||
var selectedIds = Set<MessageId>()
|
||||
public func withUpdatedSelectedMessages(_ messageIds: [EngineMessage.Id]) -> ChatInterfaceState {
|
||||
var selectedIds = Set<EngineMessage.Id>()
|
||||
if let selectionState = self.selectionState {
|
||||
selectedIds.formUnion(selectionState.selectedIds)
|
||||
}
|
||||
@ -509,8 +505,8 @@ public final class ChatInterfaceState: Codable, Equatable {
|
||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: ChatInterfaceSelectionState(selectedIds: selectedIds), messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||
}
|
||||
|
||||
public func withToggledSelectedMessages(_ messageIds: [MessageId], value: Bool) -> ChatInterfaceState {
|
||||
var selectedIds = Set<MessageId>()
|
||||
public func withToggledSelectedMessages(_ messageIds: [EngineMessage.Id], value: Bool) -> ChatInterfaceState {
|
||||
var selectedIds = Set<EngineMessage.Id>()
|
||||
if let selectionState = self.selectionState {
|
||||
selectedIds.formUnion(selectionState.selectedIds)
|
||||
}
|
||||
@ -560,20 +556,20 @@ public final class ChatInterfaceState: Codable, Equatable {
|
||||
guard let opaqueData = state.opaqueData else {
|
||||
return ChatInterfaceState().withUpdatedSynchronizeableInputState(state.synchronizeableInputState)
|
||||
}
|
||||
guard var decodedState = try? AdaptedPostboxDecoder().decode(ChatInterfaceState.self, from: opaqueData) else {
|
||||
guard var decodedState = try? EngineDecoder.decode(ChatInterfaceState.self, from: opaqueData) else {
|
||||
return ChatInterfaceState().withUpdatedSynchronizeableInputState(state.synchronizeableInputState)
|
||||
}
|
||||
decodedState = decodedState.withUpdatedSynchronizeableInputState(state.synchronizeableInputState)
|
||||
return decodedState
|
||||
}
|
||||
|
||||
public static func update(engine: TelegramEngine, peerId: PeerId, threadId: Int64?, _ f: @escaping (ChatInterfaceState) -> ChatInterfaceState) -> Signal<Never, NoError> {
|
||||
public static func update(engine: TelegramEngine, peerId: EnginePeer.Id, threadId: Int64?, _ f: @escaping (ChatInterfaceState) -> ChatInterfaceState) -> Signal<Never, NoError> {
|
||||
return engine.peers.getOpaqueChatInterfaceState(peerId: peerId, threadId: threadId)
|
||||
|> mapToSignal { previousOpaqueState -> Signal<Never, NoError> in
|
||||
let previousState = previousOpaqueState.flatMap(ChatInterfaceState.parse)
|
||||
let updatedState = f(previousState ?? ChatInterfaceState())
|
||||
|
||||
let updatedOpaqueData = try? AdaptedPostboxEncoder().encode(updatedState)
|
||||
let updatedOpaqueData = try? EngineEncoder.encode(updatedState)
|
||||
|
||||
return engine.peers.setOpaqueChatInterfaceState(
|
||||
peerId: peerId,
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
|
@ -6,11 +6,13 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/SearchBarNode:SearchBarNode",
|
||||
],
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
|
@ -6,11 +6,13 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/ListSectionHeaderNode:ListSectionHeaderNode",
|
||||
"//submodules/HorizontalPeerItem:HorizontalPeerItem",
|
||||
|
@ -3,7 +3,6 @@ import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import MergeLists
|
||||
@ -32,13 +31,13 @@ private func calculateItemCustomWidth(width: CGFloat) -> CGFloat {
|
||||
|
||||
private struct ChatListSearchRecentPeersEntry: Comparable, Identifiable {
|
||||
let index: Int
|
||||
let peer: Peer
|
||||
let presence: PeerPresence?
|
||||
let peer: EnginePeer
|
||||
let presence: EnginePeer.Presence?
|
||||
let unreadBadge: (Int32, Bool)?
|
||||
let theme: PresentationTheme
|
||||
let strings: PresentationStrings
|
||||
let itemCustomWidth: CGFloat?
|
||||
var stableId: PeerId {
|
||||
var stableId: EnginePeer.Id {
|
||||
return self.peer.id
|
||||
}
|
||||
|
||||
@ -49,14 +48,10 @@ private struct ChatListSearchRecentPeersEntry: Comparable, Identifiable {
|
||||
if lhs.itemCustomWidth != rhs.itemCustomWidth {
|
||||
return false
|
||||
}
|
||||
if !lhs.peer.isEqual(rhs.peer) {
|
||||
if lhs.peer != rhs.peer {
|
||||
return false
|
||||
}
|
||||
if let lhsPresence = lhs.presence, let rhsPresence = rhs.presence {
|
||||
if !lhsPresence.isEqual(to: rhsPresence) {
|
||||
return false
|
||||
}
|
||||
} else if (lhs.presence != nil) != (rhs.presence != nil) {
|
||||
if lhs.presence != rhs.presence {
|
||||
return false
|
||||
}
|
||||
if lhs.unreadBadge?.0 != rhs.unreadBadge?.0 {
|
||||
@ -78,7 +73,7 @@ private struct ChatListSearchRecentPeersEntry: Comparable, Identifiable {
|
||||
return lhs.index < rhs.index
|
||||
}
|
||||
|
||||
func item(context: AccountContext, mode: HorizontalPeerItemMode, peerSelected: @escaping (Peer) -> Void, peerContextAction: @escaping (Peer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (PeerId) -> Bool) -> ListViewItem {
|
||||
func item(context: AccountContext, mode: HorizontalPeerItemMode, peerSelected: @escaping (EnginePeer) -> Void, peerContextAction: @escaping (EnginePeer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (EnginePeer.Id) -> Bool) -> ListViewItem {
|
||||
return HorizontalPeerItem(theme: self.theme, strings: self.strings, mode: mode, context: context, peer: self.peer, presence: self.presence, unreadBadge: self.unreadBadge, action: peerSelected, contextAction: { peer, node, gesture in
|
||||
peerContextAction(peer, node, gesture)
|
||||
}, isPeerSelected: isPeerSelected, customWidth: self.itemCustomWidth)
|
||||
@ -93,7 +88,7 @@ private struct ChatListSearchRecentNodeTransition {
|
||||
let animated: Bool
|
||||
}
|
||||
|
||||
private func preparedRecentPeersTransition(context: AccountContext, mode: HorizontalPeerItemMode, peerSelected: @escaping (Peer) -> Void, peerContextAction: @escaping (Peer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (PeerId) -> Bool, share: Bool = false, from fromEntries: [ChatListSearchRecentPeersEntry], to toEntries: [ChatListSearchRecentPeersEntry], firstTime: Bool, animated: Bool) -> ChatListSearchRecentNodeTransition {
|
||||
private func preparedRecentPeersTransition(context: AccountContext, mode: HorizontalPeerItemMode, peerSelected: @escaping (EnginePeer) -> Void, peerContextAction: @escaping (EnginePeer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (EnginePeer.Id) -> Bool, share: Bool = false, from fromEntries: [ChatListSearchRecentPeersEntry], to toEntries: [ChatListSearchRecentPeersEntry], firstTime: Bool, animated: Bool) -> ChatListSearchRecentNodeTransition {
|
||||
let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromEntries, rightList: toEntries)
|
||||
|
||||
let deletions = deleteIndices.map { ListViewDeleteItem(index: $0, directionHint: nil) }
|
||||
@ -111,9 +106,9 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode {
|
||||
private let listView: ListView
|
||||
private let share: Bool
|
||||
|
||||
private let peerSelected: (Peer) -> Void
|
||||
private let peerContextAction: (Peer, ASDisplayNode, ContextGesture?) -> Void
|
||||
private let isPeerSelected: (PeerId) -> Bool
|
||||
private let peerSelected: (EnginePeer) -> Void
|
||||
private let peerContextAction: (EnginePeer, ASDisplayNode, ContextGesture?) -> Void
|
||||
private let isPeerSelected: (EnginePeer.Id) -> Bool
|
||||
|
||||
private let disposable = MetaDisposable()
|
||||
private let itemCustomWidthValuePromise: ValuePromise<CGFloat?> = ValuePromise(nil, ignoreRepeated: true)
|
||||
@ -127,7 +122,7 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode {
|
||||
return self.ready.get()
|
||||
}
|
||||
|
||||
public init(context: AccountContext, theme: PresentationTheme, mode: HorizontalPeerItemMode, strings: PresentationStrings, peerSelected: @escaping (Peer) -> Void, peerContextAction: @escaping (Peer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (PeerId) -> Bool, share: Bool = false) {
|
||||
public init(context: AccountContext, theme: PresentationTheme, mode: HorizontalPeerItemMode, strings: PresentationStrings, peerSelected: @escaping (EnginePeer) -> Void, peerContextAction: @escaping (EnginePeer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (EnginePeer.Id) -> Bool, share: Bool = false) {
|
||||
self.theme = theme
|
||||
self.strings = strings
|
||||
self.themeAndStringsPromise = Promise((self.theme, self.strings))
|
||||
@ -149,7 +144,7 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode {
|
||||
|
||||
let peersDisposable = DisposableSet()
|
||||
|
||||
let recent: Signal<([Peer], [PeerId: (Int32, Bool)], [PeerId : PeerPresence]), NoError> = context.engine.peers.recentPeers()
|
||||
let recent: Signal<([EnginePeer], [EnginePeer.Id: (Int32, Bool)], [EnginePeer.Id : EnginePeer.Presence]), NoError> = context.engine.peers.recentPeers()
|
||||
|> filter { value -> Bool in
|
||||
switch value {
|
||||
case .disabled:
|
||||
@ -163,14 +158,21 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode {
|
||||
case .disabled:
|
||||
return .single(([], [:], [:]))
|
||||
case let .peers(peers):
|
||||
return combineLatest(queue: .mainQueue(), peers.filter { !$0.isDeleted }.map {context.account.postbox.peerView(id: $0.id)}) |> mapToSignal { peerViews -> Signal<([Peer], [PeerId: (Int32, Bool)], [PeerId: PeerPresence]), NoError> in
|
||||
return combineLatest(queue: .mainQueue(),
|
||||
peers.filter {
|
||||
!$0.isDeleted
|
||||
}.map {
|
||||
context.account.postbox.peerView(id: $0.id)
|
||||
}
|
||||
)
|
||||
|> mapToSignal { peerViews -> Signal<([EnginePeer], [EnginePeer.Id: (Int32, Bool)], [EnginePeer.Id: EnginePeer.Presence]), NoError> in
|
||||
return context.account.postbox.unreadMessageCountsView(items: peerViews.map {
|
||||
.peer($0.peerId)
|
||||
})
|
||||
|> map { values in
|
||||
var peers: [Peer] = []
|
||||
var unread: [PeerId: (Int32, Bool)] = [:]
|
||||
var presences: [PeerId: PeerPresence] = [:]
|
||||
var peers: [EnginePeer] = []
|
||||
var unread: [EnginePeer.Id: (Int32, Bool)] = [:]
|
||||
var presences: [EnginePeer.Id: EnginePeer.Presence] = [:]
|
||||
for peerView in peerViews {
|
||||
if let peer = peerViewMainPeer(peerView) {
|
||||
var isMuted: Bool = false
|
||||
@ -189,10 +191,10 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
if let presence = peerView.peerPresences[peer.id] {
|
||||
presences[peer.id] = presence
|
||||
presences[peer.id] = EnginePeer.Presence(presence)
|
||||
}
|
||||
|
||||
peers.append(peer)
|
||||
peers.append(EnginePeer(peer))
|
||||
}
|
||||
}
|
||||
return (peers, unread, presences)
|
||||
@ -286,7 +288,7 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode {
|
||||
self.itemCustomWidthValuePromise.set(itemCustomWidth)
|
||||
}
|
||||
|
||||
public func viewAndPeerAtPoint(_ point: CGPoint) -> (UIView, PeerId)? {
|
||||
public func viewAndPeerAtPoint(_ point: CGPoint) -> (UIView, EnginePeer.Id)? {
|
||||
let adjustedPoint = self.view.convert(point, to: self.listView.view)
|
||||
var selectedItemNode: ASDisplayNode?
|
||||
self.listView.forEachItemNode { itemNode in
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -272,7 +272,7 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch
|
||||
}
|
||||
|
||||
let archiveEnabled = !isSavedMessages && peerId != PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000)) && peerId == context.account.peerId
|
||||
if let (group, index) = groupAndIndex {
|
||||
if let (group, _) = groupAndIndex {
|
||||
if archiveEnabled {
|
||||
let isArchived = group == Namespaces.PeerGroup.archive
|
||||
items.append(.action(ContextMenuActionItem(text: isArchived ? strings.ChatList_Context_Unarchive : strings.ChatList_Context_Archive, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: isArchived ? "Chat/Context Menu/Unarchive" : "Chat/Context Menu/Archive"), color: theme.contextMenu.primaryColor) }, action: { _, f in
|
||||
@ -361,14 +361,15 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch
|
||||
|
||||
joinChannelDisposable.set((createSignal
|
||||
|> deliverOnMainQueue).start(next: { _ in
|
||||
if let navigationController = (chatListController?.navigationController as? NavigationController) {
|
||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
|
||||
}
|
||||
}, error: { _ in
|
||||
if let chatListController = chatListController {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
chatListController.present(textAlertController(context: context, title: nil, text: presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
}
|
||||
}, completed: {
|
||||
if let navigationController = (chatListController?.navigationController as? NavigationController) {
|
||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
|
||||
}
|
||||
}))
|
||||
f(.default)
|
||||
})))
|
||||
|
@ -836,10 +836,10 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
}
|
||||
|
||||
switch item.content {
|
||||
case let .groupReference(groupReference):
|
||||
let chatListController = ChatListControllerImpl(context: strongSelf.context, groupId: groupReference.groupId, controlsHistoryPreload: false, hideNetworkActivityStatus: true, previewing: true, enableDebugActions: false)
|
||||
case let .groupReference(groupId, _, _, _, _):
|
||||
let chatListController = ChatListControllerImpl(context: strongSelf.context, groupId: groupId, controlsHistoryPreload: false, hideNetworkActivityStatus: true, previewing: true, enableDebugActions: false)
|
||||
chatListController.navigationPresentation = .master
|
||||
let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: archiveContextMenuItems(context: strongSelf.context, groupId: groupReference.groupId, chatListController: strongSelf), reactionItems: [], gesture: gesture)
|
||||
let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: archiveContextMenuItems(context: strongSelf.context, groupId: groupId, chatListController: strongSelf), reactionItems: [], gesture: gesture)
|
||||
strongSelf.presentInGlobalOverlay(contextController)
|
||||
case let .peer(_, peer, _, _, _, _, _, _, promoInfo, _, _, _):
|
||||
let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .peer(peer.peerId), subject: nil, botStart: nil, mode: .standard(previewing: true))
|
||||
@ -1481,8 +1481,8 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
switch entry {
|
||||
case .all:
|
||||
return nil
|
||||
case let .filter(filter):
|
||||
return filter.id
|
||||
case let .filter(id, _, _):
|
||||
return id
|
||||
}
|
||||
}
|
||||
|
||||
@ -1996,7 +1996,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
return false
|
||||
}
|
||||
if value == .commit {
|
||||
let context = strongSelf.context
|
||||
let presentationData = strongSelf.presentationData
|
||||
let progressSignal = Signal<Never, NoError> { subscriber in
|
||||
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
|
||||
|
@ -1165,10 +1165,7 @@ final class ChatListControllerNode: ASDisplayNode {
|
||||
return nil
|
||||
}
|
||||
|
||||
var filter: ChatListNodePeersFilter = []
|
||||
if false, case .group = self.groupId {
|
||||
filter.insert(.excludeRecent)
|
||||
}
|
||||
let filter: ChatListNodePeersFilter = []
|
||||
|
||||
let contentNode = ChatListSearchContainerNode(context: self.context, filter: filter, groupId: self.groupId, displaySearchFilters: displaySearchFilters, initialFilter: initialFilter, openPeer: { [weak self] peer, _, dismissSearch in
|
||||
self?.requestOpenPeerFromSearch?(peer, dismissSearch)
|
||||
|
@ -157,7 +157,6 @@ class ChatListFilterPresetCategoryItemNode: ItemListRevealOptionsItemNode, ItemL
|
||||
|
||||
func asyncLayout() -> (_ item: ChatListFilterPresetCategoryItem, _ params: ListViewItemLayoutParams, _ neighbors: ItemListNeighbors, _ headerAtTop: Bool) -> (ListViewItemNodeLayout, (Bool, Bool) -> Void) {
|
||||
let makeTitleLayout = TextNode.asyncLayout(self.titleNode)
|
||||
let editableControlLayout = ItemListEditableControlNode.asyncLayout(self.editableControlNode)
|
||||
|
||||
let currentItem = self.item
|
||||
|
||||
@ -193,16 +192,10 @@ class ChatListFilterPresetCategoryItemNode: ItemListRevealOptionsItemNode, ItemL
|
||||
avatarSize = 40.0
|
||||
leftInset = 65.0 + params.leftInset
|
||||
|
||||
var editableControlSizeAndApply: (CGFloat, (CGFloat) -> ItemListEditableControlNode)?
|
||||
let editableControlSizeAndApply: (CGFloat, (CGFloat) -> ItemListEditableControlNode)? = nil
|
||||
|
||||
let editingOffset: CGFloat
|
||||
if false {
|
||||
let sizeAndApply = editableControlLayout(item.presentationData.theme, false)
|
||||
editableControlSizeAndApply = sizeAndApply
|
||||
editingOffset = sizeAndApply.0
|
||||
} else {
|
||||
editingOffset = 0.0
|
||||
}
|
||||
|
||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - 12.0 - editingOffset - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
|
@ -260,8 +260,8 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry {
|
||||
return .index(3)
|
||||
case .addIncludePeer:
|
||||
return .index(4)
|
||||
case let .includeCategory(includeCategory):
|
||||
return .includeCategory(includeCategory.category)
|
||||
case let .includeCategory(_, category, _, _):
|
||||
return .includeCategory(category)
|
||||
case .includeExpand:
|
||||
return .index(5)
|
||||
case .includePeerInfo:
|
||||
@ -270,16 +270,16 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry {
|
||||
return .index(7)
|
||||
case .addExcludePeer:
|
||||
return .index(8)
|
||||
case let .excludeCategory(excludeCategory):
|
||||
return .excludeCategory(excludeCategory.category)
|
||||
case let .excludeCategory(_, category, _, _):
|
||||
return .excludeCategory(category)
|
||||
case .excludeExpand:
|
||||
return .index(9)
|
||||
case .excludePeerInfo:
|
||||
return .index(10)
|
||||
case let .includePeer(peer):
|
||||
return .peer(peer.peer.peerId)
|
||||
case let .excludePeer(peer):
|
||||
return .peer(peer.peer.peerId)
|
||||
case let .includePeer(_, peer, _):
|
||||
return .peer(peer.peerId)
|
||||
case let .excludePeer(_, peer, _):
|
||||
return .peer(peer.peerId)
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,10 +295,10 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry {
|
||||
return .includeIndex(0)
|
||||
case .addIncludePeer:
|
||||
return .includeIndex(1)
|
||||
case let .includeCategory(includeCategory):
|
||||
return .includeIndex(2 + includeCategory.index)
|
||||
case let .includePeer(includePeer):
|
||||
return .includeIndex(200 + includePeer.index)
|
||||
case let .includeCategory(index, _, _, _):
|
||||
return .includeIndex(2 + index)
|
||||
case let .includePeer(index, _, _):
|
||||
return .includeIndex(200 + index)
|
||||
case .includeExpand:
|
||||
return .includeIndex(999)
|
||||
case .includePeerInfo:
|
||||
@ -307,10 +307,10 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry {
|
||||
return .excludeIndex(0)
|
||||
case .addExcludePeer:
|
||||
return .excludeIndex(1)
|
||||
case let .excludeCategory(excludeCategory):
|
||||
return .excludeIndex(2 + excludeCategory.index)
|
||||
case let .excludePeer(excludePeer):
|
||||
return .excludeIndex(200 + excludePeer.index)
|
||||
case let .excludeCategory(index, _, _, _):
|
||||
return .excludeIndex(2 + index)
|
||||
case let .excludePeer(index, _, _):
|
||||
return .excludeIndex(200 + index)
|
||||
case .excludeExpand:
|
||||
return .excludeIndex(999)
|
||||
case .excludePeerInfo:
|
||||
|
@ -94,16 +94,16 @@ private enum ChatListFilterPresetListEntry: ItemListNodeEntry {
|
||||
return 0
|
||||
case .listHeader:
|
||||
return 100
|
||||
case let .preset(preset):
|
||||
return 101 + preset.index.value
|
||||
case let .preset(index, _, _, _, _, _, _):
|
||||
return 101 + index.value
|
||||
case .addItem:
|
||||
return 1000
|
||||
case .listFooter:
|
||||
return 1001
|
||||
case .suggestedListHeader:
|
||||
return 1002
|
||||
case let .suggestedPreset(suggestedPreset):
|
||||
return 1003 + suggestedPreset.index.value
|
||||
case let .suggestedPreset(index, _, _, _):
|
||||
return 1003 + index.value
|
||||
case .suggestedAddCustom:
|
||||
return 2000
|
||||
}
|
||||
@ -115,14 +115,14 @@ private enum ChatListFilterPresetListEntry: ItemListNodeEntry {
|
||||
return .screenHeader
|
||||
case .suggestedListHeader:
|
||||
return .suggestedListHeader
|
||||
case let .suggestedPreset(suggestedPreset):
|
||||
return .suggestedPreset(suggestedPreset.preset)
|
||||
case let .suggestedPreset(_, _, _, preset):
|
||||
return .suggestedPreset(preset)
|
||||
case .suggestedAddCustom:
|
||||
return .suggestedAddCustom
|
||||
case .listHeader:
|
||||
return .listHeader
|
||||
case let .preset(preset):
|
||||
return .preset(preset.preset.id)
|
||||
case let .preset(_, _, _, preset, _, _, _):
|
||||
return .preset(preset.id)
|
||||
case .addItem:
|
||||
return .addItem
|
||||
case .listFooter:
|
||||
@ -297,8 +297,6 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch
|
||||
presentControllerImpl?(actionSheet)
|
||||
})
|
||||
|
||||
let chatCountCache = Atomic<[ChatListFilterData: Int]>(value: [:])
|
||||
|
||||
let filtersWithCountsSignal = context.engine.peers.updatedChatListFilters()
|
||||
|> distinctUntilChanged
|
||||
|> mapToSignal { filters -> Signal<[(ChatListFilter, Int)], NoError> in
|
||||
@ -430,7 +428,7 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch
|
||||
}
|
||||
controller.setReorderEntry({ (fromIndex: Int, toIndex: Int, entries: [ChatListFilterPresetListEntry]) -> Signal<Bool, NoError> in
|
||||
let fromEntry = entries[fromIndex]
|
||||
guard case let .preset(fromFilter) = fromEntry else {
|
||||
guard case let .preset(_, _, _, fromPreset, _, _, _) = fromEntry else {
|
||||
return .single(false)
|
||||
}
|
||||
var referenceFilter: ChatListFilter?
|
||||
@ -438,8 +436,8 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch
|
||||
var afterAll = false
|
||||
if toIndex < entries.count {
|
||||
switch entries[toIndex] {
|
||||
case let .preset(toFilter):
|
||||
referenceFilter = toFilter.preset
|
||||
case let .preset(_, _, _, preset, _, _, _):
|
||||
referenceFilter = preset
|
||||
default:
|
||||
if entries[toIndex] < fromEntry {
|
||||
beforeAll = true
|
||||
@ -459,7 +457,7 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch
|
||||
var filters = filtersWithAppliedOrder(filters: filtersWithCountsValue, order: updatedFilterOrderValue).map { $0.0 }
|
||||
let initialOrder = filters.map { $0.id }
|
||||
|
||||
if let index = filters.firstIndex(where: { $0.id == fromFilter.preset.id }) {
|
||||
if let index = filters.firstIndex(where: { $0.id == fromPreset.id }) {
|
||||
filters.remove(at: index)
|
||||
}
|
||||
if let referenceFilter = referenceFilter {
|
||||
@ -467,21 +465,21 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch
|
||||
for i in 0 ..< filters.count {
|
||||
if filters[i].id == referenceFilter.id {
|
||||
if fromIndex < toIndex {
|
||||
filters.insert(fromFilter.preset, at: i + 1)
|
||||
filters.insert(fromPreset, at: i + 1)
|
||||
} else {
|
||||
filters.insert(fromFilter.preset, at: i)
|
||||
filters.insert(fromPreset, at: i)
|
||||
}
|
||||
inserted = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !inserted {
|
||||
filters.append(fromFilter.preset)
|
||||
filters.append(fromPreset)
|
||||
}
|
||||
} else if beforeAll {
|
||||
filters.insert(fromFilter.preset, at: 0)
|
||||
filters.insert(fromPreset, at: 0)
|
||||
} else if afterAll {
|
||||
filters.append(fromFilter.preset)
|
||||
filters.append(fromPreset)
|
||||
}
|
||||
|
||||
let updatedOrder = filters.map { $0.id }
|
||||
|
@ -146,7 +146,7 @@ private final class ItemNode: ASDisplayNode {
|
||||
return
|
||||
}
|
||||
|
||||
if isExtracted, let theme = strongSelf.theme {
|
||||
if isExtracted {
|
||||
strongSelf.extractedBackgroundNode.image = generateStretchableFilledCircleImage(diameter: 32.0, color: strongSelf.isSelected ? UIColor(rgb: 0xbbbbbb) : UIColor(rgb: 0xf1f1f1))
|
||||
}
|
||||
transition.updateAlpha(node: strongSelf.extractedBackgroundNode, alpha: isExtracted ? 1.0 : 0.0, completion: { _ in
|
||||
@ -652,8 +652,8 @@ final class ChatListFilterTabInlineContainerNode: ASDisplayNode {
|
||||
strongSelf.scrollNode.view.panGestureRecognizer.isEnabled = true
|
||||
strongSelf.scrollNode.view.setContentOffset(strongSelf.scrollNode.view.contentOffset, animated: false)
|
||||
switch filter {
|
||||
case let .filter(filter):
|
||||
strongSelf.contextGesture?(filter.id, sourceNode, gesture)
|
||||
case let .filter(id, _, _):
|
||||
strongSelf.contextGesture?(id, sourceNode, gesture)
|
||||
default:
|
||||
strongSelf.contextGesture?(nil, sourceNode, gesture)
|
||||
}
|
||||
@ -666,11 +666,11 @@ final class ChatListFilterTabInlineContainerNode: ASDisplayNode {
|
||||
return
|
||||
}
|
||||
switch filter {
|
||||
case let .filter(filter):
|
||||
case let .filter(id, _, _):
|
||||
strongSelf.scrollNode.view.panGestureRecognizer.isEnabled = false
|
||||
strongSelf.scrollNode.view.panGestureRecognizer.isEnabled = true
|
||||
strongSelf.scrollNode.view.setContentOffset(strongSelf.scrollNode.view.contentOffset, animated: false)
|
||||
strongSelf.contextGesture?(filter.id, sourceNode, gesture)
|
||||
strongSelf.contextGesture?(id, sourceNode, gesture)
|
||||
default:
|
||||
strongSelf.contextGesture?(nil, sourceNode, gesture)
|
||||
}
|
||||
@ -685,9 +685,9 @@ final class ChatListFilterTabInlineContainerNode: ASDisplayNode {
|
||||
unreadCount = count
|
||||
unreadHasUnmuted = true
|
||||
isNoFilter = true
|
||||
case let .filter(filter):
|
||||
unreadCount = filter.unread.value
|
||||
unreadHasUnmuted = filter.unread.hasUnmuted
|
||||
case let .filter(_, _, unread):
|
||||
unreadCount = unread.value
|
||||
unreadHasUnmuted = unread.hasUnmuted
|
||||
}
|
||||
if !wasAdded && (itemNodePair.regular.unreadCount != 0) != (unreadCount != 0) {
|
||||
badgeAnimations[filter.id] = (unreadCount != 0) ? .in : .out
|
||||
@ -831,8 +831,6 @@ final class ChatListFilterTabInlineContainerNode: ASDisplayNode {
|
||||
|
||||
self.scrollNode.view.contentSize = CGSize(width: itemsBackgroundRightX + 8.0, height: size.height)
|
||||
|
||||
var previousFrame: CGRect?
|
||||
var nextFrame: CGRect?
|
||||
var selectedFrame: CGRect?
|
||||
if let selectedFilter = selectedFilter, let currentIndex = reorderedFilters.firstIndex(where: { $0.id == selectedFilter }) {
|
||||
func interpolateFrame(from fromValue: CGRect, to toValue: CGRect, t: CGFloat) -> CGRect {
|
||||
|
@ -122,9 +122,9 @@ class ChatListRecentPeersListItemNode: ListViewItemNode {
|
||||
peersNode.updateThemeAndStrings(theme: item.theme, strings: item.strings)
|
||||
} else {
|
||||
peersNode = ChatListSearchRecentPeersNode(context: item.context, theme: item.theme, mode: .list, strings: item.strings, peerSelected: { peer in
|
||||
self?.item?.peerSelected(peer)
|
||||
self?.item?.peerSelected(peer._asPeer())
|
||||
}, peerContextAction: { peer, node, gesture in
|
||||
self?.item?.peerContextAction(peer, node, gesture)
|
||||
self?.item?.peerContextAction(peer._asPeer(), node, gesture)
|
||||
}, isPeerSelected: { _ in
|
||||
return false
|
||||
})
|
||||
|
@ -827,14 +827,11 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
||||
if let strongSelf = self, !actions.options.isEmpty {
|
||||
let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData)
|
||||
var items: [ActionSheetItem] = []
|
||||
var personalPeerName: String?
|
||||
var isChannel = false
|
||||
let personalPeerName: String? = nil
|
||||
|
||||
if actions.options.contains(.deleteGlobally) {
|
||||
let globalTitle: String
|
||||
if isChannel {
|
||||
globalTitle = strongSelf.presentationData.strings.Conversation_DeleteMessagesForMe
|
||||
} else if let personalPeerName = personalPeerName {
|
||||
if let personalPeerName = personalPeerName {
|
||||
globalTitle = strongSelf.presentationData.strings.Conversation_DeleteMessagesFor(personalPeerName).string
|
||||
} else {
|
||||
globalTitle = strongSelf.presentationData.strings.Conversation_DeleteMessagesForEveryone
|
||||
@ -854,14 +851,7 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
||||
}))
|
||||
}
|
||||
if actions.options.contains(.deleteLocally) {
|
||||
var localOptionText = strongSelf.presentationData.strings.Conversation_DeleteMessagesForMe
|
||||
// if strongSelf.context.account.peerId == strongSelf.peerId {
|
||||
// if messageIds.count == 1 {
|
||||
// localOptionText = strongSelf.presentationData.strings.Conversation_Moderate_Delete
|
||||
// } else {
|
||||
// localOptionText = strongSelf.presentationData.strings.Conversation_DeleteManyMessages
|
||||
// }
|
||||
// }
|
||||
let localOptionText = strongSelf.presentationData.strings.Conversation_DeleteMessagesForMe
|
||||
items.append(ActionSheetButtonItem(title: localOptionText, color: .destructive, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
|
@ -676,12 +676,12 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
if peerValue.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
enablePreview = false
|
||||
}
|
||||
case let .groupReference(groupReference):
|
||||
if let previousItem = previousItem, case let .groupReference(previousGroupReference) = previousItem.content, groupReference.hiddenByDefault != previousGroupReference.hiddenByDefault {
|
||||
case let .groupReference(_, _, _, _, hiddenByDefault):
|
||||
if let previousItem = previousItem, case let .groupReference(_, _, _, _, previousHiddenByDefault) = previousItem.content, hiddenByDefault != previousHiddenByDefault {
|
||||
UIView.transition(with: self.avatarNode.view, duration: 0.3, options: [.transitionCrossDissolve], animations: {
|
||||
}, completion: nil)
|
||||
}
|
||||
self.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer.flatMap(EnginePeer.init), overrideImage: .archivedChatsIcon(hiddenByDefault: groupReference.hiddenByDefault), emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads)
|
||||
self.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer.flatMap(EnginePeer.init), overrideImage: .archivedChatsIcon(hiddenByDefault: hiddenByDefault), emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads)
|
||||
}
|
||||
|
||||
if let peer = peer {
|
||||
@ -825,7 +825,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
var groupHiddenByDefault = false
|
||||
|
||||
switch item.content {
|
||||
case let .peer(messagesValue, peerValue, combinedReadStateValue, isRemovedFromTotalUnreadCountValue, peerPresenceValue, summaryInfoValue, embeddedStateValue, inputActivitiesValue, promoInfoValue, ignoreUnreadBadge, displayAsMessageValue, hasFailedMessagesValue):
|
||||
case let .peer(messagesValue, peerValue, combinedReadStateValue, isRemovedFromTotalUnreadCountValue, peerPresenceValue, summaryInfoValue, embeddedStateValue, inputActivitiesValue, promoInfoValue, ignoreUnreadBadge, displayAsMessageValue, _):
|
||||
messages = messagesValue
|
||||
contentPeer = .chat(peerValue)
|
||||
combinedReadState = combinedReadStateValue
|
||||
@ -1280,7 +1280,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
}
|
||||
}
|
||||
|
||||
var isMuted = isRemovedFromTotalUnreadCount
|
||||
let isMuted = isRemovedFromTotalUnreadCount
|
||||
if isMuted {
|
||||
currentMutedIconImage = PresentationResourcesChatList.mutedIcon(item.presentationData.theme)
|
||||
}
|
||||
@ -1351,7 +1351,6 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
|
||||
let layoutOffset: CGFloat = 0.0
|
||||
|
||||
let rawContentOriginX = 2.0
|
||||
let rawContentWidth = params.width - leftInset - params.rightInset - 10.0 - editingOffset
|
||||
|
||||
let (dateLayout, dateApply) = dateLayout(TextNodeLayoutArguments(attributedString: dateAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: rawContentWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
@ -1417,7 +1416,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
if !displayAsMessage {
|
||||
if let peer = renderedPeer.chatMainPeer as? TelegramUser, let presence = presence as? TelegramUserPresence, !isServicePeer(peer) && !peer.flags.contains(.isSupport) && peer.id != item.context.account.peerId {
|
||||
let updatedPresence = TelegramUserPresence(status: presence.status, lastActivity: 0)
|
||||
let relativeStatus = relativeUserPresenceStatus(updatedPresence, relativeTo: timestamp)
|
||||
let relativeStatus = relativeUserPresenceStatus(EnginePeer.Presence(updatedPresence), relativeTo: timestamp)
|
||||
if case .online = relativeStatus {
|
||||
online = true
|
||||
}
|
||||
@ -1825,7 +1824,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
}
|
||||
|
||||
let separatorInset: CGFloat
|
||||
if case let .groupReference(groupReference) = item.content, groupReference.hiddenByDefault {
|
||||
if case let .groupReference(_, _, _, _, hiddenByDefault) = item.content, hiddenByDefault {
|
||||
separatorInset = 0.0
|
||||
} else if (!nextIsPinned && item.index.pinningIndex != nil) || last {
|
||||
separatorInset = 0.0
|
||||
@ -1840,7 +1839,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
if item.selected {
|
||||
backgroundColor = theme.itemSelectedBackgroundColor
|
||||
} else if item.index.pinningIndex != nil {
|
||||
if case let .groupReference(groupReference) = item.content, groupReference.hiddenByDefault {
|
||||
if case let .groupReference(_, _, _, _, hiddenByDefault) = item.content, hiddenByDefault {
|
||||
backgroundColor = theme.itemBackgroundColor
|
||||
} else {
|
||||
backgroundColor = theme.pinnedItemBackgroundColor
|
||||
|
@ -964,8 +964,8 @@ public final class ChatListNode: ListView {
|
||||
if index.messageIndex.id.peerId == removingPeerId {
|
||||
didIncludeRemovingPeerId = true
|
||||
}
|
||||
} else if case let .GroupReferenceEntry(entry) = entry {
|
||||
didIncludeHiddenByDefaultArchive = entry.hiddenByDefault
|
||||
} else if case let .GroupReferenceEntry(_, _, _, _, _, _, _, _, hiddenByDefault) = entry {
|
||||
didIncludeHiddenByDefaultArchive = hiddenByDefault
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -973,16 +973,16 @@ public final class ChatListNode: ListView {
|
||||
var doesIncludeArchive = false
|
||||
var doesIncludeHiddenByDefaultArchive = false
|
||||
for entry in processedView.filteredEntries {
|
||||
if case let .PeerEntry(peerEntry) = entry {
|
||||
if peerEntry.index.pinningIndex != nil {
|
||||
updatedPinnedChats.append(peerEntry.index.messageIndex.id.peerId)
|
||||
if case let .PeerEntry(index, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) = entry {
|
||||
if index.pinningIndex != nil {
|
||||
updatedPinnedChats.append(index.messageIndex.id.peerId)
|
||||
}
|
||||
if peerEntry.index.messageIndex.id.peerId == removingPeerId {
|
||||
if index.messageIndex.id.peerId == removingPeerId {
|
||||
doesIncludeRemovingPeerId = true
|
||||
}
|
||||
} else if case let .GroupReferenceEntry(entry) = entry {
|
||||
} else if case let .GroupReferenceEntry(_, _, _, _, _, _, _, _, hiddenByDefault) = entry {
|
||||
doesIncludeArchive = true
|
||||
doesIncludeHiddenByDefaultArchive = entry.hiddenByDefault
|
||||
doesIncludeHiddenByDefaultArchive = hiddenByDefault
|
||||
}
|
||||
}
|
||||
if previousPinnedChats != updatedPinnedChats {
|
||||
@ -1343,8 +1343,8 @@ public final class ChatListNode: ListView {
|
||||
var isHiddenArchiveVisible = false
|
||||
strongSelf.forEachItemNode({ itemNode in
|
||||
if let itemNode = itemNode as? ChatListItemNode, let item = itemNode.item {
|
||||
if case let .groupReference(groupReference) = item.content {
|
||||
if groupReference.hiddenByDefault {
|
||||
if case let .groupReference(_, _, _, _, hiddenByDefault) = item.content {
|
||||
if hiddenByDefault {
|
||||
isHiddenArchiveVisible = true
|
||||
}
|
||||
}
|
||||
@ -1599,8 +1599,8 @@ public final class ChatListNode: ListView {
|
||||
for item in transition.insertItems {
|
||||
if let item = item.item as? ChatListItem {
|
||||
switch item.content {
|
||||
case let .peer(peer):
|
||||
insertedPeerIds.append(peer.peer.peerId)
|
||||
case let .peer(_, peer, _, _, _, _, _, _, _, _, _, _):
|
||||
insertedPeerIds.append(peer.peerId)
|
||||
case .groupReference:
|
||||
break
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ enum ChatListNodeEntry: Comparable, Identifiable {
|
||||
return .index(index)
|
||||
case .ArchiveIntro:
|
||||
return .index(ChatListIndex.absoluteUpperBound.successor)
|
||||
case let .AdditionalCategory(additionalCategory):
|
||||
return .additionalCategory(additionalCategory.index)
|
||||
case let .AdditionalCategory(index, _, _, _, _, _, _):
|
||||
return .additionalCategory(index)
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,8 +81,8 @@ enum ChatListNodeEntry: Comparable, Identifiable {
|
||||
return .GroupId(groupId)
|
||||
case .ArchiveIntro:
|
||||
return .ArchiveIntro
|
||||
case let .AdditionalCategory(additionalCategory):
|
||||
return .additionalCategory(additionalCategory.id)
|
||||
case let .AdditionalCategory(_, id, _, _, _, _, _):
|
||||
return .additionalCategory(id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,12 +12,12 @@ enum ChatListNodeLocation: Equatable {
|
||||
|
||||
var filter: ChatListFilter? {
|
||||
switch self {
|
||||
case let .initial(initial):
|
||||
return initial.filter
|
||||
case let .navigation(navigation):
|
||||
return navigation.filter
|
||||
case let .scroll(scroll):
|
||||
return scroll.filter
|
||||
case let .initial(_, filter):
|
||||
return filter
|
||||
case let .navigation(_, filter):
|
||||
return filter
|
||||
case let .scroll(_, _, _, _, filter):
|
||||
return filter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/Postbox:Postbox",
|
||||
|
@ -14,15 +14,15 @@ private func fetchRawData(prefix: String) -> Signal<Data, FetchError> {
|
||||
return Signal { subscriber in
|
||||
#if targetEnvironment(simulator)
|
||||
return EmptyDisposable
|
||||
#endif
|
||||
|
||||
#else
|
||||
let container = CKContainer.default()
|
||||
let publicDatabase = container.database(with: .public)
|
||||
let recordId = CKRecord.ID(recordName: "emergency-datacenter-\(prefix)")
|
||||
publicDatabase.fetch(withRecordID: recordId, completionHandler: { record, error in
|
||||
if let error = error {
|
||||
print("publicDatabase.fetch error: \(error)")
|
||||
if let error = error as? NSError, error.domain == CKError.errorDomain, error.code == 1 {
|
||||
let nsError = error as NSError
|
||||
if nsError.domain == CKError.errorDomain, nsError.code == 1 {
|
||||
subscriber.putError(.networkUnavailable)
|
||||
} else {
|
||||
subscriber.putError(.generic)
|
||||
@ -46,8 +46,8 @@ private func fetchRawData(prefix: String) -> Signal<Data, FetchError> {
|
||||
})
|
||||
|
||||
return ActionDisposable {
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Source/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
],
|
||||
visibility = [
|
||||
|
@ -80,7 +80,7 @@ public final class RootHostView<EnvironmentType: Equatable>: UIViewController {
|
||||
self.environment._isUpdated = false
|
||||
|
||||
transition.setFrame(view: self.componentView, frame: CGRect(origin: CGPoint(), size: size))
|
||||
self.componentView.update(
|
||||
let _ = self.componentView.update(
|
||||
transition: transition,
|
||||
component: self.content,
|
||||
environment: {
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
@ -17,6 +20,7 @@ swift_library(
|
||||
"//submodules/AlertUI:AlertUI",
|
||||
"//submodules/PresentationDataUtils:PresentationDataUtils",
|
||||
"//submodules/TextFormat:TextFormat",
|
||||
"//submodules/ObjCRuntimeUtils:ObjCRuntimeUtils",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -260,8 +260,8 @@ private enum CreatePollEntry: ItemListNodeEntry {
|
||||
switch self {
|
||||
case .text:
|
||||
return CreatePollEntryTag.text
|
||||
case let .option(option):
|
||||
return CreatePollEntryTag.option(option.id)
|
||||
case let .option(id, _, _, _, _, _, _, _, _):
|
||||
return CreatePollEntryTag.option(id)
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -276,8 +276,8 @@ private enum CreatePollEntry: ItemListNodeEntry {
|
||||
return .text
|
||||
case .optionsHeader:
|
||||
return .optionsHeader
|
||||
case let .option(option):
|
||||
return .option(option.id)
|
||||
case let .option(id, _, _, _, _, _, _, _, _):
|
||||
return .option(id)
|
||||
case .optionsInfo:
|
||||
return .optionsInfo
|
||||
case .anonymousVotes:
|
||||
@ -305,7 +305,7 @@ private enum CreatePollEntry: ItemListNodeEntry {
|
||||
return 1
|
||||
case .optionsHeader:
|
||||
return 2
|
||||
case let .option(option):
|
||||
case .option:
|
||||
return 3
|
||||
case .optionsInfo:
|
||||
return 1001
|
||||
@ -328,10 +328,10 @@ private enum CreatePollEntry: ItemListNodeEntry {
|
||||
|
||||
static func <(lhs: CreatePollEntry, rhs: CreatePollEntry) -> Bool {
|
||||
switch lhs {
|
||||
case let .option(lhsOption):
|
||||
case let .option(_, lhsOrdering, _, _, _, _, _, _, _):
|
||||
switch rhs {
|
||||
case let .option(rhsOption):
|
||||
return lhsOption.ordering < rhsOption.ordering
|
||||
case let .option(_, rhsOrdering, _, _, _, _, _, _, _):
|
||||
return lhsOrdering < rhsOrdering
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -992,17 +992,16 @@ public func createPollController(context: AccountContext, peer: Peer, isQuiz: Bo
|
||||
}
|
||||
controller.setReorderEntry({ (fromIndex: Int, toIndex: Int, entries: [CreatePollEntry]) -> Signal<Bool, NoError> in
|
||||
let fromEntry = entries[fromIndex]
|
||||
guard case let .option(option) = fromEntry else {
|
||||
guard case let .option(id, _, _, _, _, _, _, _, _) = fromEntry else {
|
||||
return .single(false)
|
||||
}
|
||||
let id = option.id
|
||||
var referenceId: Int?
|
||||
var beforeAll = false
|
||||
var afterAll = false
|
||||
if toIndex < entries.count {
|
||||
switch entries[toIndex] {
|
||||
case let .option(toOption):
|
||||
referenceId = toOption.id
|
||||
case let .option(toId, _, _, _, _, _, _, _, _):
|
||||
referenceId = toId
|
||||
default:
|
||||
if entries[toIndex] < fromEntry {
|
||||
beforeAll = true
|
||||
|
@ -6,6 +6,7 @@ import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
import ItemListUI
|
||||
import TextFormat
|
||||
import ObjCRuntimeUtils
|
||||
|
||||
public enum CreatePollTextInputItemTextLimitMode {
|
||||
case characters
|
||||
@ -292,7 +293,7 @@ public class CreatePollTextInputItemNode: ListViewItemNode, ASEditableTextNodeDe
|
||||
let textLength: Int
|
||||
switch maxLength.mode {
|
||||
case .characters:
|
||||
textLength = item.text.string.count ?? 0
|
||||
textLength = item.text.string.count
|
||||
case .bytes:
|
||||
textLength = item.text.string.data(using: .utf8, allowLossyConversion: true)?.count ?? 0
|
||||
}
|
||||
@ -511,7 +512,7 @@ public class CreatePollTextInputItemNode: ListViewItemNode, ASEditableTextNodeDe
|
||||
}
|
||||
|
||||
public func editableTextNodeTarget(forAction action: Selector) -> ASEditableTextNodeTargetForAction? {
|
||||
if action == Selector(("_showTextStyleOptions:")) {
|
||||
if action == makeSelectorFromString("_showTextStyleOptions:") {
|
||||
if case .general = self.inputMenu.state {
|
||||
if self.textNode.attributedText == nil || self.textNode.attributedText!.length == 0 || self.textNode.selectedRange.length == 0 {
|
||||
return ASEditableTextNodeTargetForAction(target: nil)
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
|
@ -87,7 +87,6 @@ public final class ConfettiView: UIView {
|
||||
let velocityYRange = Float(3.0) ..< Float(5.0)
|
||||
let angularVelocityRange = Float(1.0) ..< Float(6.0)
|
||||
let sizeVariation = Float(0.8) ..< Float(1.6)
|
||||
let topDelayRange = Float(0.0) ..< Float(0.0)
|
||||
|
||||
for i in 0 ..< 70 {
|
||||
let (image, size) = images[i % imageCount]
|
||||
@ -99,9 +98,6 @@ public final class ConfettiView: UIView {
|
||||
|
||||
let sideMassRange: Range<Float> = 110.0 ..< 120.0
|
||||
let sideOriginYBase: Float = Float(frame.size.height * 9.0 / 10.0)
|
||||
let sideOriginYVariation: Float = Float(frame.size.height / 12.0)
|
||||
let sideOriginYRange = Float(sideOriginYBase - sideOriginYVariation) ..< Float(sideOriginYBase + sideOriginYVariation)
|
||||
let sideOriginXRange = Float(0.0) ..< Float(100.0)
|
||||
let sideOriginVelocityValueRange = Float(1.1) ..< Float(1.3)
|
||||
let sideOriginVelocityValueScaling: Float = 2400.0 * Float(frame.height) / 896.0
|
||||
let sideOriginVelocityBase: Float = Float.pi / 2.0 + atanf(Float(CGFloat(sideOriginYBase) / (frame.size.width * 0.8)))
|
||||
@ -152,11 +148,7 @@ public final class ConfettiView: UIView {
|
||||
self.slowdownStartTimestamps[0] = 0.33
|
||||
|
||||
var haveParticlesAboveGround = false
|
||||
let minPositionY: CGFloat = 0.0
|
||||
let maxPositionY = self.bounds.height + 30.0
|
||||
let minDampingX: CGFloat = 40.0
|
||||
let maxDampingX: CGFloat = self.bounds.width - 40.0
|
||||
let centerX: CGFloat = self.bounds.width / 2.0
|
||||
let dt: Float = 1.0 * 1.0 / 60.0
|
||||
|
||||
let typeDelays: [Float] = [0.0, 0.01, 0.08]
|
||||
@ -220,7 +212,7 @@ public final class ConfettiView: UIView {
|
||||
var typesWithPositiveVelocity: [Bool] = [false, false, false]
|
||||
|
||||
for particle in self.particles {
|
||||
let (localDt, damping_) = dtAndDamping[particle.type]
|
||||
let (localDt, _) = dtAndDamping[particle.type]
|
||||
if localDt.isZero {
|
||||
continue
|
||||
}
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -1258,8 +1258,8 @@ public final class ContactListNode: ASDisplayNode {
|
||||
var peers: [(Peer, Int32)] = []
|
||||
for entry in view.entries {
|
||||
switch entry {
|
||||
case let .MessageEntry(messageEntry):
|
||||
if let peer = messageEntry.5.peer {
|
||||
case let .MessageEntry(_, _, _, _, _, renderedPeer, _, _, _, _):
|
||||
if let peer = renderedPeer.peer {
|
||||
if peer is TelegramGroup {
|
||||
peers.append((peer, 0))
|
||||
} else if let channel = peer as? TelegramChannel, case .group = channel.info {
|
||||
|
@ -48,7 +48,7 @@ private enum InviteContactsEntry: Comparable, Identifiable {
|
||||
|
||||
func item(context: AccountContext, presentationData: PresentationData, interaction: InviteContactsInteraction) -> ListViewItem {
|
||||
switch self {
|
||||
case let .option(_, option, theme, _):
|
||||
case let .option(_, option, _, _):
|
||||
return ContactListActionItem(presentationData: ItemListPresentationData(presentationData), title: option.title, icon: option.icon, header: nil, action: option.action)
|
||||
case let .peer(_, id, contact, count, selection, theme, strings, nameSortOrder, nameDisplayOrder):
|
||||
let status: ContactsPeerItemStatus
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -1010,10 +1010,8 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
var completedEffect = false
|
||||
var completedContentNode = false
|
||||
var completedActionsNode = false
|
||||
var targetNode: ASDisplayNode?
|
||||
|
||||
if let transitionInfo = transitionInfo, let (sourceNode, sourceNodeRect) = transitionInfo.sourceNode() {
|
||||
targetNode = sourceNode
|
||||
let projectedFrame = convertFrame(sourceNodeRect, from: sourceNode.view, to: self.view)
|
||||
self.originalProjectedContentViewFrame = (projectedFrame, projectedFrame)
|
||||
|
||||
@ -1090,18 +1088,10 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
animateOutToItem = false
|
||||
}
|
||||
|
||||
if animateOutToItem, let targetNode = targetNode, let originalProjectedContentViewFrame = self.originalProjectedContentViewFrame {
|
||||
let actionsSideInset: CGFloat = (validLayout?.safeInsets.left ?? 0.0) + 11.0
|
||||
if animateOutToItem, let originalProjectedContentViewFrame = self.originalProjectedContentViewFrame {
|
||||
|
||||
let localSourceFrame = self.view.convert(CGRect(origin: CGPoint(x: originalProjectedContentViewFrame.1.minX, y: originalProjectedContentViewFrame.1.minY), size: CGSize(width: originalProjectedContentViewFrame.1.width, height: originalProjectedContentViewFrame.1.height)), to: self.scrollNode.view)
|
||||
|
||||
if let snapshotView = targetNode.view.snapshotContentTree(unhide: true, keepTransform: true), false {
|
||||
self.view.addSubview(snapshotView)
|
||||
snapshotView.layer.animatePosition(from: CGPoint(x: self.contentContainerNode.frame.midX, y: self.contentContainerNode.frame.minY + localSourceFrame.height / 2.0), to: localSourceFrame.center, duration: transitionDuration * animationDurationFactor, timingFunction: transitionCurve.timingFunction, removeOnCompletion: false)
|
||||
snapshotView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2 * animationDurationFactor, removeOnCompletion: false, completion: { _ in
|
||||
})
|
||||
}
|
||||
|
||||
self.actionsContainerNode.layer.animatePosition(from: CGPoint(), to: CGPoint(x: localSourceFrame.center.x - self.actionsContainerNode.position.x, y: localSourceFrame.center.y - self.actionsContainerNode.position.y), duration: transitionDuration * animationDurationFactor, timingFunction: transitionCurve.timingFunction, removeOnCompletion: false, additive: true)
|
||||
let contentContainerOffset = CGPoint(x: localSourceFrame.center.x - self.contentContainerNode.frame.center.x, y: localSourceFrame.center.y - self.contentContainerNode.frame.center.y)
|
||||
self.contentContainerNode.layer.animatePosition(from: CGPoint(), to: contentContainerOffset, duration: transitionDuration * animationDurationFactor, timingFunction: transitionCurve.timingFunction, removeOnCompletion: false, additive: true, completion: { [weak self] _ in
|
||||
@ -1724,7 +1714,7 @@ public final class ContextControllerReferenceViewInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol ContextReferenceContentSource: class {
|
||||
public protocol ContextReferenceContentSource: AnyObject {
|
||||
func transitionInfo() -> ContextControllerReferenceViewInfo?
|
||||
}
|
||||
|
||||
@ -1750,7 +1740,7 @@ public final class ContextControllerPutBackViewInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol ContextExtractedContentSource: class {
|
||||
public protocol ContextExtractedContentSource: AnyObject {
|
||||
var centerVertically: Bool { get }
|
||||
var keepInPlace: Bool { get }
|
||||
var ignoreContentTouches: Bool { get }
|
||||
@ -1781,7 +1771,7 @@ public final class ContextControllerTakeControllerInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol ContextControllerContentSource: class {
|
||||
public protocol ContextControllerContentSource: AnyObject {
|
||||
var controller: ViewController { get }
|
||||
var navigationController: NavigationController? { get }
|
||||
var passthroughTouches: Bool { get }
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
|
@ -4,7 +4,7 @@ import Display
|
||||
import AsyncDisplayKit
|
||||
import AudioToolbox
|
||||
|
||||
@objc public protocol PickerViewDelegate: class {
|
||||
@objc public protocol PickerViewDelegate: AnyObject {
|
||||
func pickerViewHeightForRows(_ pickerView: TapeNode) -> CGFloat
|
||||
@objc optional func pickerView(_ pickerView: TapeNode, didSelectRow row: Int)
|
||||
@objc optional func pickerView(_ pickerView: TapeNode, didTapRow row: Int)
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/Display:Display",
|
||||
|
@ -75,11 +75,11 @@ private enum DebugAccountsControllerEntry: ItemListNodeEntry {
|
||||
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
|
||||
let arguments = arguments as! DebugAccountsControllerArguments
|
||||
switch self {
|
||||
case let .record(theme, record, current):
|
||||
case let .record(_, record, current):
|
||||
return ItemListCheckboxItem(presentationData: presentationData, title: "\(UInt64(bitPattern: record.id.int64))", style: .left, checked: current, zeroSeparatorInsets: false, sectionId: self.section, action: {
|
||||
arguments.switchAccount(record.id)
|
||||
})
|
||||
case let .loginNewAccount(theme):
|
||||
case .loginNewAccount:
|
||||
return ItemListActionItem(presentationData: presentationData, title: "Login to another account", kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.loginNewAccount()
|
||||
})
|
||||
|
@ -617,7 +617,6 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
let databasePath = context.account.basePath + "/postbox/db"
|
||||
let _ = try? FileManager.default.removeItem(atPath: databasePath)
|
||||
exit(0)
|
||||
preconditionFailure()
|
||||
}),
|
||||
]), ActionSheetItemGroup(items: [
|
||||
ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
||||
@ -640,7 +639,6 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
let databasePath = context.account.basePath + "/postbox"
|
||||
let _ = try? FileManager.default.removeItem(atPath: databasePath)
|
||||
exit(0)
|
||||
preconditionFailure()
|
||||
}),
|
||||
]), ActionSheetItemGroup(items: [
|
||||
ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
],
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
|
@ -6,6 +6,9 @@ swift_library(
|
||||
srcs = glob([
|
||||
"Source/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/ObjCRuntimeUtils:ObjCRuntimeUtils",
|
||||
"//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils",
|
||||
|
@ -2,11 +2,11 @@ import UIKit
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
|
||||
public protocol PresentableController: class {
|
||||
public protocol PresentableController: AnyObject {
|
||||
func viewDidAppear(completion: @escaping () -> Void)
|
||||
}
|
||||
|
||||
public protocol ContainableController: class {
|
||||
public protocol ContainableController: AnyObject {
|
||||
var view: UIView! { get }
|
||||
var displayNode: ASDisplayNode { get }
|
||||
var isViewLoaded: Bool { get }
|
||||
|
@ -799,8 +799,6 @@ public extension ContainedViewLayoutTransition {
|
||||
}
|
||||
|
||||
func animateTransformScale(node: ASDisplayNode, from fromScale: CGPoint, completion: ((Bool) -> Void)? = nil) {
|
||||
let t = node.layer.transform
|
||||
|
||||
switch self {
|
||||
case .immediate:
|
||||
if let completion = completion {
|
||||
|
@ -553,7 +553,6 @@ public class DrawingContext {
|
||||
}
|
||||
if self.hasGeneratedImage {
|
||||
preconditionFailure()
|
||||
return nil
|
||||
}
|
||||
self.hasGeneratedImage = true
|
||||
|
||||
|
@ -2661,24 +2661,6 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
}
|
||||
}
|
||||
|
||||
if !offset.isZero {
|
||||
let scrollToItemTransition: ContainedViewLayoutTransition
|
||||
if !scrollToItem.animated {
|
||||
scrollToItemTransition = .immediate
|
||||
} else {
|
||||
switch scrollToItem.curve {
|
||||
case let .Spring(duration):
|
||||
scrollToItemTransition = .animated(duration: duration, curve: .spring)
|
||||
case let .Default(duration):
|
||||
scrollToItemTransition = .animated(duration: duration ?? 0.3, curve: .easeInOut)
|
||||
case let .Custom(duration, cp1x, cp1y, cp2x, cp2y):
|
||||
scrollToItemTransition = .animated(duration: duration, curve: .custom(cp1x, cp1y, cp2x, cp2y))
|
||||
}
|
||||
}
|
||||
|
||||
//self.didScrollWithOffset?(-offset, scrollToItemTransition, nil)
|
||||
}
|
||||
|
||||
for itemNode in self.itemNodes {
|
||||
var frame = itemNode.frame
|
||||
frame.origin.y += offset
|
||||
@ -2750,24 +2732,6 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
self.ensureTopInsetForOverlayHighlightedItems = updateSizeAndInsets.ensureTopInsetForOverlayHighlightedItems
|
||||
self.visibleSize = updateSizeAndInsets.size
|
||||
|
||||
let updateSizeAndInsetsTransition: ContainedViewLayoutTransition
|
||||
if updateSizeAndInsets.duration.isZero {
|
||||
updateSizeAndInsetsTransition = .immediate
|
||||
} else {
|
||||
switch updateSizeAndInsets.curve {
|
||||
case let .Spring(duration):
|
||||
updateSizeAndInsetsTransition = .animated(duration: duration, curve: .spring)
|
||||
case let .Default(duration):
|
||||
updateSizeAndInsetsTransition = .animated(duration: duration ?? 0.3, curve: .easeInOut)
|
||||
case let .Custom(duration, cp1x, cp1y, cp2x, cp2y):
|
||||
updateSizeAndInsetsTransition = .animated(duration: duration, curve: .custom(cp1x, cp1y, cp2x, cp2y))
|
||||
}
|
||||
}
|
||||
|
||||
if !offsetFix.isZero {
|
||||
//self.didScrollWithOffset?(-offsetFix, updateSizeAndInsetsTransition, nil)
|
||||
}
|
||||
|
||||
for itemNode in self.itemNodes {
|
||||
itemNode.updateFrame(itemNode.frame.offsetBy(dx: 0.0, dy: offsetFix), within: self.visibleSize)
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user