Fix more warnings

This commit is contained in:
Ali 2021-08-05 01:42:59 +02:00
parent 194f25d4e4
commit 31bc746984
253 changed files with 914 additions and 1063 deletions

View File

@ -7,7 +7,7 @@ swift_library(
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [ copts = [
#"-warnings-as-errors", "-warnings-as-errors",
], ],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",

View File

@ -102,11 +102,15 @@ public func legacyMediaEditor(context: AccountContext, peer: Peer, media: AnyMed
present(legacyController, nil) present(legacyController, nil)
TGPhotoVideoEditor.present(with: legacyController.context, controller: emptyController, caption: initialCaption, entities: [], withItem: item, paint: true, recipientName: recipientName, stickersContext: paintStickersContext, snapshots: snapshots as? [Any], immediate: transitionCompletion != nil, appeared: { TGPhotoVideoEditor.present(with: legacyController.context, controller: emptyController, caption: initialCaption, entities: [], withItem: item, paint: true, recipientName: recipientName, stickersContext: paintStickersContext, snapshots: snapshots as [Any], immediate: transitionCompletion != nil, appeared: {
transitionCompletion?() transitionCompletion?()
}, completion: { result, editingContext in }, completion: { result, editingContext in
let nativeGenerator = legacyAssetPickerItemGenerator() let nativeGenerator = legacyAssetPickerItemGenerator()
let signals = TGCameraController.resultSignals(for: nil, editingContext: editingContext, currentItem: result as! TGMediaSelectableItem, storeAssets: false, saveEditedPhotos: false, descriptionGenerator: { _1, _2, _3, _4 in var selectableResult: TGMediaSelectableItem?
if let result = result {
selectableResult = unsafeDowncast(result, to: TGMediaSelectableItem.self)
}
let signals = TGCameraController.resultSignals(for: nil, editingContext: editingContext, currentItem: selectableResult, storeAssets: false, saveEditedPhotos: false, descriptionGenerator: { _1, _2, _3, _4 in
nativeGenerator(_1, _2, _3, _4, nil) nativeGenerator(_1, _2, _3, _4, nil)
}) })
sendMessagesWithSignals(signals, false, 0) sendMessagesWithSignals(signals, false, 0)
@ -319,7 +323,11 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, chatLocati
TGPhotoVideoEditor.present(with: legacyController.context, controller: emptyController, caption: "", entities: [], withItem: item, paint: false, recipientName: recipientName, stickersContext: paintStickersContext, snapshots: [], immediate: false, appeared: { TGPhotoVideoEditor.present(with: legacyController.context, controller: emptyController, caption: "", entities: [], withItem: item, paint: false, recipientName: recipientName, stickersContext: paintStickersContext, snapshots: [], immediate: false, appeared: {
}, completion: { result, editingContext in }, completion: { result, editingContext in
let nativeGenerator = legacyAssetPickerItemGenerator() let nativeGenerator = legacyAssetPickerItemGenerator()
let signals = TGCameraController.resultSignals(for: nil, editingContext: editingContext, currentItem: result as! TGMediaSelectableItem, storeAssets: false, saveEditedPhotos: false, descriptionGenerator: { _1, _2, _3, _4 in var selectableResult: TGMediaSelectableItem?
if let result = result {
selectableResult = unsafeDowncast(result, to: TGMediaSelectableItem.self)
}
let signals = TGCameraController.resultSignals(for: nil, editingContext: editingContext, currentItem: selectableResult, storeAssets: false, saveEditedPhotos: false, descriptionGenerator: { _1, _2, _3, _4 in
nativeGenerator(_1, _2, _3, _4, nil) nativeGenerator(_1, _2, _3, _4, nil)
}) })
sendMessagesWithSignals(signals, false, 0, { _ in nil}, {}) sendMessagesWithSignals(signals, false, 0, { _ in nil}, {})

View File

@ -504,7 +504,7 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) -
finalDuration = adjustments.trimEndValue - adjustments.trimStartValue finalDuration = adjustments.trimEndValue - adjustments.trimStartValue
} }
let adjustmentsData = MemoryBuffer(data: NSKeyedArchiver.archivedData(withRootObject: adjustments.dictionary())) let adjustmentsData = MemoryBuffer(data: NSKeyedArchiver.archivedData(withRootObject: adjustments.dictionary()!))
let digest = MemoryBuffer(data: adjustmentsData.md5Digest()) let digest = MemoryBuffer(data: adjustmentsData.md5Digest())
resourceAdjustments = VideoMediaResourceAdjustments(data: adjustmentsData, digest: digest) resourceAdjustments = VideoMediaResourceAdjustments(data: adjustmentsData, digest: digest)
} }

View File

@ -26,11 +26,17 @@ private func render(width: Int, height: Int, bytesPerRow: Int, data: Data, type:
let image = generateImagePixel(CGSize(width: CGFloat(width), height: CGFloat(height)), scale: 1.0, pixelGenerator: { _, pixelData, bytesPerRow in let image = generateImagePixel(CGSize(width: CGFloat(width), height: CGFloat(height)), scale: 1.0, pixelGenerator: { _, pixelData, bytesPerRow in
switch type { switch type {
case .yuva: case .yuva:
data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Void in data.withUnsafeBytes { buffer -> Void in
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
return
}
decodeYUVAToRGBA(bytes, pixelData, Int32(width), Int32(height), Int32(bytesPerRow)) decodeYUVAToRGBA(bytes, pixelData, Int32(width), Int32(height), Int32(bytesPerRow))
} }
case .argb: case .argb:
data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Void in data.withUnsafeBytes { buffer -> Void in
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
return
}
memcpy(pixelData, bytes, data.count) memcpy(pixelData, bytes, data.count)
} }
} }

View File

@ -29,16 +29,16 @@ public func legacySuggestionContext(context: AccountContext, peerId: PeerId, cha
} }
} }
subscriber?.putNext(users) subscriber.putNext(users)
subscriber?.putCompletion() subscriber.putCompletion()
}) })
return SBlockDisposable { return SBlockDisposable {
disposable.dispose() disposable.dispose()
} }
} else { } else {
subscriber?.putNext(NSArray()) subscriber.putNext(NSArray())
subscriber?.putCompletion() subscriber.putCompletion()
return nil return nil
} }
} }
@ -59,8 +59,8 @@ public func legacySuggestionContext(context: AccountContext, peerId: PeerId, cha
} }
|> take(1) |> take(1)
|> deliverOnMainQueue).start(next: { hashtags in |> deliverOnMainQueue).start(next: { hashtags in
subscriber?.putNext(hashtags) subscriber.putNext(hashtags)
subscriber?.putCompletion() subscriber.putCompletion()
}) })
return SBlockDisposable { return SBlockDisposable {
@ -83,10 +83,10 @@ public func legacySuggestionContext(context: AccountContext, peerId: PeerId, cha
} }
return result return result
}).start(next: { result in }).start(next: { result in
subscriber?.putNext(result) subscriber.putNext(result)
subscriber?.putCompletion() subscriber.putCompletion()
}, error: nil, completed: { }, error: nil, completed: {
subscriber?.putCompletion() subscriber.putCompletion()
}) })
return SBlockDisposable { return SBlockDisposable {

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/Postbox:Postbox", "//submodules/Postbox:Postbox",

View File

@ -332,7 +332,7 @@ open class LegacyController: ViewController, PresentableController {
private let sizeClass: SVariable = SVariable() private let sizeClass: SVariable = SVariable()
public var enableSizeClassSignal: Bool = false public var enableSizeClassSignal: Bool = false
public var sizeClassSignal: SSignal { public var sizeClassSignal: SSignal {
return self.sizeClass.signal()! return self.sizeClass.signal()
} }
private var enableContainerLayoutUpdates = false private var enableContainerLayoutUpdates = false

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",
], ],

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",
"//submodules/Display:Display", "//submodules/Display:Display",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/TelegramCore:TelegramCore", "//submodules/TelegramCore:TelegramCore",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",
"//submodules/Display:Display", "//submodules/Display:Display",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",
"//submodules/Display:Display", "//submodules/Display:Display",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
], ],

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/Postbox:Postbox", "//submodules/Postbox:Postbox",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/TelegramCore:TelegramCore", "//submodules/TelegramCore:TelegramCore",
"//submodules/Postbox:Postbox", "//submodules/Postbox:Postbox",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/TelegramCore:TelegramCore", "//submodules/TelegramCore:TelegramCore",
"//submodules/Postbox:Postbox", "//submodules/Postbox:Postbox",

View File

@ -160,7 +160,6 @@ public func chatMapSnapshotImage(account: Account, resource: MapSnapshotMediaRes
let context = DrawingContext(size: arguments.drawingSize, clear: true) let context = DrawingContext(size: arguments.drawingSize, clear: true)
var fullSizeImage: CGImage? var fullSizeImage: CGImage?
var imageOrientation: UIImage.Orientation = .up
if let fullSizeData = fullSizeData { if let fullSizeData = fullSizeData {
let options = NSMutableDictionary() let options = NSMutableDictionary()
options[kCGImageSourceShouldCache as NSString] = false as NSNumber options[kCGImageSourceShouldCache as NSString] = false as NSNumber

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",

View File

@ -90,7 +90,7 @@ final class LocationDistancePickerScreen: ViewController {
self?.dismiss() self?.dismiss()
} }
self.controllerNode.update() let _ = self.controllerNode.update()
} }
override public func loadView() { override public func loadView() {
@ -463,7 +463,7 @@ class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewD
pickerView.selectRow(1, inComponent: 1, animated: true) pickerView.selectRow(1, inComponent: 1, animated: true)
} }
self.updateDoneButtonTitle() self.updateDoneButtonTitle()
self.update() let _ = self.update()
} }
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
@ -601,7 +601,7 @@ class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewD
} }
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) { func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
var hadValidLayout = self.containerLayout != nil let hadValidLayout = self.containerLayout != nil
self.containerLayout = (layout, navigationBarHeight) self.containerLayout = (layout, navigationBarHeight)
var insets = layout.insets(options: [.statusBar, .input]) var insets = layout.insets(options: [.statusBar, .input])

View File

@ -231,8 +231,6 @@ final class LocationInfoListItemNode: ListViewItemNode {
let subtitleFrame = CGRect(origin: CGPoint(x: leftInset, y: verticalInset + titleLayout.size.height + titleSpacing), size: subtitleLayout.size) let subtitleFrame = CGRect(origin: CGPoint(x: leftInset, y: verticalInset + titleLayout.size.height + titleSpacing), size: subtitleLayout.size)
subtitleNode.frame = subtitleFrame subtitleNode.frame = subtitleFrame
let separatorHeight = UIScreenPixel
let iconNodeFrame = CGRect(origin: CGPoint(x: params.leftInset + inset, y: 10.0), size: CGSize(width: iconSize, height: iconSize)) let iconNodeFrame = CGRect(origin: CGPoint(x: params.leftInset + inset, y: 10.0), size: CGSize(width: iconSize, height: iconSize))
strongSelf.venueIconNode.frame = iconNodeFrame strongSelf.venueIconNode.frame = iconNodeFrame

View File

@ -178,7 +178,7 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
var proximityDimView = UIImageView() var proximityDimView = UIImageView()
var proximityIndicatorRadius: Double? { var proximityIndicatorRadius: Double? {
didSet { didSet {
if let radius = self.proximityIndicatorRadius, let mapView = self.mapView { if let _ = self.proximityIndicatorRadius, let mapView = self.mapView {
if self.proximityDimView.image == nil { if self.proximityDimView.image == nil {
proximityDimView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) proximityDimView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
} }

View File

@ -119,7 +119,7 @@ public final class LocationPickerController: ViewController {
strongSelf.present(c, in: .window(.root), with: a) strongSelf.present(c, in: .window(.root), with: a)
}, openSettings: { }, openSettings: {
strongSelf.context.sharedContext.applicationBindings.openSettings() strongSelf.context.sharedContext.applicationBindings.openSettings()
}) { [weak self] authorized in }, { [weak self] authorized in
guard let strongSelf = self, authorized else { guard let strongSelf = self, authorized else {
return return
} }
@ -160,7 +160,7 @@ public final class LocationPickerController: ViewController {
]) ])
]) ])
strongSelf.present(controller, in: .window(.root)) strongSelf.present(controller, in: .window(.root))
} })
}, sendVenue: { [weak self] venue in }, sendVenue: { [weak self] venue in
guard let strongSelf = self else { guard let strongSelf = self else {
return return

View File

@ -514,7 +514,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
entries.append(.attribution(presentationData.theme, attribution)) entries.append(.attribution(presentationData.theme, attribution))
} }
} else { } else {
for i in 0 ..< 8 { for _ in 0 ..< 8 {
entries.append(.venue(presentationData.theme, nil, index)) entries.append(.venue(presentationData.theme, nil, index))
index += 1 index += 1
} }

View File

@ -226,7 +226,7 @@ public final class LocationViewController: ViewController {
strongSelf.present(c, in: .window(.root), with: a) strongSelf.present(c, in: .window(.root), with: a)
}, openSettings: { }, openSettings: {
context.sharedContext.applicationBindings.openSettings() context.sharedContext.applicationBindings.openSettings()
}) { [weak self] authorized in }, { [weak self] authorized in
guard let strongSelf = self, authorized else { guard let strongSelf = self, authorized else {
return return
} }
@ -311,7 +311,7 @@ public final class LocationViewController: ViewController {
}) })
strongSelf.present(controller, in: .window(.root)) strongSelf.present(controller, in: .window(.root))
}) })
} })
} }
}, updateSendActionHighlight: { [weak self] highlighted in }, updateSendActionHighlight: { [weak self] highlighted in
guard let strongSelf = self else { guard let strongSelf = self else {
@ -326,7 +326,7 @@ public final class LocationViewController: ViewController {
strongSelf.present(c, in: .window(.root), with: a) strongSelf.present(c, in: .window(.root), with: a)
}, openSettings: { }, openSettings: {
context.sharedContext.applicationBindings.openSettings() context.sharedContext.applicationBindings.openSettings()
}) { [weak self] authorized in }, { [weak self] authorized in
guard let strongSelf = self, authorized else { guard let strongSelf = self, authorized else {
return return
} }
@ -415,7 +415,7 @@ public final class LocationViewController: ViewController {
strongSelf.present(controller, in: .window(.root)) strongSelf.present(controller, in: .window(.root))
}) })
} }
} })
}, stopLiveLocation: { [weak self] in }, stopLiveLocation: { [weak self] in
params.stopLiveLocation(nil) params.stopLiveLocation(nil)
self?.dismiss() self?.dismiss()

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/Display:Display", "//submodules/Display:Display",
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/Postbox:Postbox", "//submodules/Postbox:Postbox",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Source/**/*.swift", "Source/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",
], ],

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/TelegramCore:TelegramCore", "//submodules/TelegramCore:TelegramCore",
"//submodules/Postbox:Postbox", "//submodules/Postbox:Postbox",

View File

@ -336,13 +336,6 @@ final class FFMpegMediaFrameSourceContext: NSObject {
self.fetchAutomatically = fetchAutomatically self.fetchAutomatically = fetchAutomatically
self.maximumFetchSize = maximumFetchSize self.maximumFetchSize = maximumFetchSize
var preferSoftwareAudioDecoding = false
if case let .media(media, _) = resourceReference, let file = media.media as? TelegramMediaFile {
if file.isInstantVideo {
preferSoftwareAudioDecoding = true
}
}
if self.tempFilePath == nil { if self.tempFilePath == nil {
self.keepDataDisposable.set(postbox.mediaBox.keepResource(id: resourceReference.resource.id).start()) self.keepDataDisposable.set(postbox.mediaBox.keepResource(id: resourceReference.resource.id).start())
} }

View File

@ -690,7 +690,10 @@ private final class AudioPlayerRendererContext {
strongSelf.bufferContext.with { context in strongSelf.bufferContext.with { context in
let copyOffset = context.overflowData.count let copyOffset = context.overflowData.count
context.overflowData.count += dataLength - takeLength context.overflowData.count += dataLength - takeLength
context.overflowData.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Void in context.overflowData.withUnsafeMutableBytes { buffer -> Void in
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
return
}
CMBlockBufferCopyDataBytes(dataBuffer, atOffset: takeLength, dataLength: dataLength - takeLength, destination: bytes.advanced(by: copyOffset)) CMBlockBufferCopyDataBytes(dataBuffer, atOffset: takeLength, dataLength: dataLength - takeLength, destination: bytes.advanced(by: copyOffset))
} }
} }
@ -727,7 +730,10 @@ private final class AudioPlayerRendererContext {
self.bufferContext.with { context in self.bufferContext.with { context in
let bytesToCopy = min(context.buffer.size - context.buffer.availableBytes, data.count) let bytesToCopy = min(context.buffer.size - context.buffer.availableBytes, data.count)
data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Void in data.withUnsafeBytes { buffer -> Void in
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
return
}
let _ = context.buffer.enqueue(UnsafeRawPointer(bytes), count: bytesToCopy) let _ = context.buffer.enqueue(UnsafeRawPointer(bytes), count: bytesToCopy)
context.bufferMaxChannelSampleIndex = sampleIndex + Int64(data.count / (2 * 2)) context.bufferMaxChannelSampleIndex = sampleIndex + Int64(data.count / (2 * 2))
} }

View File

@ -147,9 +147,8 @@ public final class MediaPlayerNode: ASDisplayNode {
} }
private func poll(completion: @escaping (PollStatus) -> Void) { private func poll(completion: @escaping (PollStatus) -> Void) {
if let (takeFrameQueue, takeFrame) = self.takeFrameAndQueue, let videoLayer = self.videoLayer, let (timebase, _, _, _) = self.state { if let (takeFrameQueue, takeFrame) = self.takeFrameAndQueue, let _ = self.videoLayer, let (timebase, _, _, _) = self.state {
let layerTime = CMTimeGetSeconds(CMTimebaseGetTime(timebase)) let layerTime = CMTimeGetSeconds(CMTimebaseGetTime(timebase))
let rate = CMTimebaseGetRate(timebase)
struct PollState { struct PollState {
var numFrames: Int var numFrames: Int
@ -403,7 +402,7 @@ public final class MediaPlayerNode: ASDisplayNode {
assert(Queue.mainQueue().isCurrent()) assert(Queue.mainQueue().isCurrent())
self.videoLayer?.removeFromSuperlayer() self.videoLayer?.removeFromSuperlayer()
if let (takeFrameQueue, _) = self.takeFrameAndQueue { if let _ = self.takeFrameAndQueue {
if let videoLayer = self.videoLayer { if let videoLayer = self.videoLayer {
videoLayer.flushAndRemoveImage() videoLayer.flushAndRemoveImage()

View File

@ -53,7 +53,7 @@ private final class MediaPlayerScrubbingNodeButton: ASDisplayNode, UIGestureReco
} }
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
guard let gestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer else { guard let _ = gestureRecognizer as? UIPanGestureRecognizer else {
return !self.verticalPanEnabled return !self.verticalPanEnabled
} }
return true return true
@ -570,7 +570,7 @@ public final class MediaPlayerScrubbingNode: ASDisplayNode {
} }
handleNodeContainer.updateMultiplier = { [weak self] multiplier in handleNodeContainer.updateMultiplier = { [weak self] multiplier in
if let strongSelf = self { if let strongSelf = self {
if let statusValue = strongSelf.statusValue, let scrubbingBeginTimestamp = strongSelf.scrubbingBeginTimestamp, Double(0.0).isLess(than: statusValue.duration) { if let statusValue = strongSelf.statusValue, let _ = strongSelf.scrubbingBeginTimestamp, Double(0.0).isLess(than: statusValue.duration) {
strongSelf.scrubbingBeginTimestamp = strongSelf.scrubbingTimestampValue strongSelf.scrubbingBeginTimestamp = strongSelf.scrubbingTimestampValue
} }
} }

View File

@ -17,7 +17,10 @@ public final class RingByteBuffer {
} }
public func enqueue(data: Data) -> Bool { public func enqueue(data: Data) -> Bool {
return data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Bool in return data.withUnsafeBytes { buffer -> Bool in
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
return false
}
return TPCircularBufferProduceBytes(&self.buffer, UnsafeRawPointer(bytes), Int32(data.count)) return TPCircularBufferProduceBytes(&self.buffer, UnsafeRawPointer(bytes), Int32(data.count))
} }
} }

View File

@ -48,7 +48,10 @@ private func readPacketCallback(userData: UnsafeMutableRawPointer?, buffer: Unsa
fetchDisposable.dispose() fetchDisposable.dispose()
if let fetchedData = fetchedData { if let fetchedData = fetchedData {
fetchedData.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Void in fetchedData.withUnsafeBytes { byteBuffer -> Void in
guard let bytes = byteBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
return
}
memcpy(buffer, bytes, fetchedData.count) memcpy(buffer, bytes, fetchedData.count)
} }
let fetchedCount = Int32(fetchedData.count) let fetchedCount = Int32(fetchedData.count)

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/TelegramCore:TelegramCore", "//submodules/TelegramCore:TelegramCore",
"//submodules/Postbox:Postbox", "//submodules/Postbox:Postbox",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",
], ],

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",
], ],

View File

@ -8,7 +8,6 @@ public struct MosaicItemPosition: OptionSet {
self.rawValue = rawValue self.rawValue = rawValue
} }
public static let none = MosaicItemPosition(rawValue: 0)
public static let top = MosaicItemPosition(rawValue: 1) public static let top = MosaicItemPosition(rawValue: 1)
public static let bottom = MosaicItemPosition(rawValue: 2) public static let bottom = MosaicItemPosition(rawValue: 2)
public static let left = MosaicItemPosition(rawValue: 4) public static let left = MosaicItemPosition(rawValue: 4)

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/TelegramCore:TelegramCore", "//submodules/TelegramCore:TelegramCore",
"//submodules/Postbox:Postbox", "//submodules/Postbox:Postbox",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/Display:Display", "//submodules/Display:Display",
"//submodules/Postbox:Postbox", "//submodules/Postbox:Postbox",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/Display:Display", "//submodules/Display:Display",

View File

@ -127,19 +127,19 @@ private enum NotificationSoundSelectionEntry: ItemListNodeEntry {
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem { func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
let arguments = arguments as! NotificationSoundSelectionArguments let arguments = arguments as! NotificationSoundSelectionArguments
switch self { switch self {
case let.modernHeader(theme, text): case let.modernHeader(_, text):
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section) return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .classicHeader(theme, text): case let .classicHeader(_, text):
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section) return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .none(_, theme, text, selected): case let .none(_, _, text, selected):
return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: selected, zeroSeparatorInsets: true, sectionId: self.section, action: { return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: selected, zeroSeparatorInsets: true, sectionId: self.section, action: {
arguments.selectSound(.none) arguments.selectSound(.none)
}) })
case let .default(_, theme, text, selected): case let .default(_, _, text, selected):
return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: selected, zeroSeparatorInsets: false, sectionId: self.section, action: { return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: selected, zeroSeparatorInsets: false, sectionId: self.section, action: {
arguments.selectSound(.default) arguments.selectSound(.default)
}) })
case let .sound(_, _, theme, text, sound, selected): case let .sound(_, _, _, text, sound, selected):
return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: selected, zeroSeparatorInsets: false, sectionId: self.section, action: { return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: selected, zeroSeparatorInsets: false, sectionId: self.section, action: {
arguments.selectSound(sound) arguments.selectSound(sound)
}) })

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",
], ],

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",

View File

@ -136,7 +136,6 @@ private final class OpenInActionSheetItemNode: ActionSheetItemNode {
self.strings = strings self.strings = strings
let titleFont = Font.medium(floor(theme.baseFontSize * 20.0 / 17.0)) let titleFont = Font.medium(floor(theme.baseFontSize * 20.0 / 17.0))
let textFont = Font.regular(floor(theme.baseFontSize * 11.0 / 17.0))
self.titleNode = ASTextNode() self.titleNode = ASTextNode()
self.titleNode.isUserInteractionEnabled = false self.titleNode.isUserInteractionEnabled = false

View File

@ -14,6 +14,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/Display:Display", "//submodules/Display:Display",
"//submodules/OverlayStatusController/Impl:OverlayStatusControllerImpl" "//submodules/OverlayStatusController/Impl:OverlayStatusControllerImpl"

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",

View File

@ -234,8 +234,8 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
if let image = chatControllerBackgroundImage(theme: self.theme, wallpaper: self.wallpaper, mediaBox: self.accountManager.mediaBox, composed: false, knockoutMode: false) { if let image = chatControllerBackgroundImage(theme: self.theme, wallpaper: self.wallpaper, mediaBox: self.accountManager.mediaBox, composed: false, knockoutMode: false) {
self.background = ImageBasedPasscodeBackground(image: image, size: size) self.background = ImageBasedPasscodeBackground(image: image, size: size)
} else { } else {
if case let .file(file) = self.wallpaper, !file.settings.colors.isEmpty { if case let .file(_, _, _, _, _, _, _, _, settings) = self.wallpaper, !settings.colors.isEmpty {
self.background = CustomPasscodeBackground(size: size, colors: file.settings.colors.compactMap { UIColor(rgb: $0) }, inverted: (file.settings.intensity ?? 0) < 0) self.background = CustomPasscodeBackground(size: size, colors: settings.colors.compactMap { UIColor(rgb: $0) }, inverted: (settings.intensity ?? 0) < 0)
} else { } else {
self.background = GradientPasscodeBackground(size: size, backgroundColors: self.theme.passcode.backgroundColors.colors, buttonColor: self.theme.passcode.buttonColor) self.background = GradientPasscodeBackground(size: size, backgroundColors: self.theme.passcode.backgroundColors.colors, buttonColor: self.theme.passcode.buttonColor)
} }

View File

@ -124,14 +124,9 @@ final class PasscodeEntryButtonNode: HighlightTrackingButtonNode {
self.subtitle = subtitle self.subtitle = subtitle
if let background = background as? CustomPasscodeBackground { if let background = background as? CustomPasscodeBackground {
if false, background.inverted { let blurredBackgroundColor = (background.inverted ? UIColor(rgb: 0xffffff, alpha: 0.1) : UIColor(rgb: 0x000000, alpha: 0.2), dateFillNeedsBlur(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper))
let gradientBackgroundNode = background.makeForegroundNode(backgroundNode: background.makeBackgroundNode()) let blurredBackgroundNode = NavigationBackgroundNode(color: blurredBackgroundColor.0, enableBlur: blurredBackgroundColor.1)
self.gradientBackgroundNode = gradientBackgroundNode as? GradientBackgroundNode.CloneNode self.blurredBackgroundNode = blurredBackgroundNode
} else {
let blurredBackgroundColor = (background.inverted ? UIColor(rgb: 0xffffff, alpha: 0.1) : UIColor(rgb: 0x000000, alpha: 0.2), dateFillNeedsBlur(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper))
let blurredBackgroundNode = NavigationBackgroundNode(color: blurredBackgroundColor.0, enableBlur: blurredBackgroundColor.1)
self.blurredBackgroundNode = blurredBackgroundNode
}
} }
self.backgroundNode = ASImageNode() self.backgroundNode = ASImageNode()

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",

View File

@ -224,7 +224,7 @@ public final class SecureIdAuthController: ViewController, StandalonePresentable
let primaryLanguageByCountry = configuration.nativeLanguageByCountry let primaryLanguageByCountry = configuration.nativeLanguageByCountry
return .single(SecureIdEncryptedFormData(form: form, primaryLanguageByCountry: primaryLanguageByCountry, accountPeer: accountPeer, servicePeer: servicePeer)) return .single(SecureIdEncryptedFormData(form: form, primaryLanguageByCountry: primaryLanguageByCountry, accountPeer: accountPeer, servicePeer: servicePeer))
} }
|> mapError { _ in return RequestSecureIdFormError.generic } |> castError(RequestSecureIdFormError.self)
|> switchToLatest |> switchToLatest
} }
|> deliverOnMainQueue).start(next: { [weak self] formData in |> deliverOnMainQueue).start(next: { [weak self] formData in
@ -252,7 +252,7 @@ public final class SecureIdAuthController: ViewController, StandalonePresentable
return .single(accountPeer) return .single(accountPeer)
} }
|> mapError { _ in return GetAllSecureIdValuesError.generic } |> castError(GetAllSecureIdValuesError.self)
|> switchToLatest) |> switchToLatest)
|> deliverOnMainQueue).start(next: { [weak self] values, configuration, accountPeer in |> deliverOnMainQueue).start(next: { [weak self] values, configuration, accountPeer in
if let strongSelf = self { if let strongSelf = self {
@ -496,17 +496,17 @@ public final class SecureIdAuthController: ViewController, StandalonePresentable
} }
private func openPasswordHelp() { private func openPasswordHelp() {
guard let verificationState = self.state.verificationState, case let .passwordChallenge(passwordChallenge) = verificationState else { guard let verificationState = self.state.verificationState, case let .passwordChallenge(_, state, hasRecoveryEmail) = verificationState else {
return return
} }
switch passwordChallenge.state { switch state {
case .checking: case .checking:
return return
case .none, .invalid: case .none, .invalid:
break break
} }
if passwordChallenge.hasRecoveryEmail { if hasRecoveryEmail {
self.present(textAlertController(context: self.context, title: self.presentationData.strings.Passport_ForgottenPassword, text: self.presentationData.strings.Passport_PasswordReset, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Login_ResetAccountProtected_Reset, action: { [weak self] in self.present(textAlertController(context: self.context, title: self.presentationData.strings.Passport_ForgottenPassword, text: self.presentationData.strings.Passport_PasswordReset, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Login_ResetAccountProtected_Reset, action: { [weak self] in
guard let strongSelf = self else { guard let strongSelf = self else {
return return

View File

@ -2683,7 +2683,7 @@ final class SecureIdDocumentFormControllerNode: FormControllerNode<SecureIdDocum
} }
func hasUnsavedData() -> Bool { func hasUnsavedData() -> Bool {
guard var innerState = self.innerState else { guard let innerState = self.innerState else {
return false return false
} }
guard let values = innerState.makeValues(), !values.isEmpty else { guard let values = innerState.makeValues(), !values.isEmpty else {

View File

@ -83,7 +83,6 @@ final class SecureIdDocumentTypeSelectionController: ActionSheetController {
init(context: AccountContext, field: SecureIdParsedRequestedFormField, currentValues: [SecureIdValueWithContext], completion: @escaping (SecureIdDocumentFormRequestedData) -> Void) { init(context: AccountContext, field: SecureIdParsedRequestedFormField, currentValues: [SecureIdValueWithContext], completion: @escaping (SecureIdDocumentFormRequestedData) -> Void) {
let presentationData = context.sharedContext.currentPresentationData.with { $0 } let presentationData = context.sharedContext.currentPresentationData.with { $0 }
let theme = presentationData.theme
let strings = presentationData.strings let strings = presentationData.strings
self.completion = completion self.completion = completion

View File

@ -110,7 +110,10 @@ public func fetchSecureIdLocalImageResource(postbox: Postbox, resource: SecureId
if buffer.data.count < range.count { if buffer.data.count < range.count {
buffer.data.count = range.count buffer.data.count = range.count
} }
buffer.data.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Void in buffer.data.withUnsafeMutableBytes { buffer -> Void in
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
return
}
data.copyBytes(to: bytes, from: range) data.copyBytes(to: bytes, from: range)
} }
} }
@ -119,7 +122,10 @@ public func fetchSecureIdLocalImageResource(postbox: Postbox, resource: SecureId
if buffer.data.count < resourceOffset + range.count { if buffer.data.count < resourceOffset + range.count {
buffer.data.count = resourceOffset + range.count buffer.data.count = resourceOffset + range.count
} }
buffer.data.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Void in buffer.data.withUnsafeMutableBytes { buffer -> Void in
guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
return
}
data.copyBytes(to: bytes.advanced(by: resourceOffset), from: range) data.copyBytes(to: bytes.advanced(by: resourceOffset), from: range)
} }
} }

View File

@ -55,10 +55,7 @@ final class SecureIdVerificationDocumentsContext {
} }
} }
} }
}, error: { [weak self] _ in }, error: { _ in
if let strongSelf = self {
}
})) }))
} }
case .remote: case .remote:

View File

@ -20,6 +20,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",

View File

@ -111,7 +111,7 @@ final class ManagedMonkeyAnimationNode: ManagedAnimationNode {
} }
switch previousState { switch previousState {
case let .idle(previousIdle): case .idle:
switch monkeyState { switch monkeyState {
case let .idle(idle): case let .idle(idle):
self.enqueueIdle(idle) self.enqueueIdle(idle)

View File

@ -146,7 +146,7 @@ public func resetPasswordController(context: AccountContext, emailPattern: Strin
completion(false) completion(false)
case .declined: case .declined:
break break
case let .error(reason): case .error:
break break
} }
}) })

View File

@ -428,7 +428,7 @@ final class SetupTwoStepVerificationControllerNode: ViewControllerTracingNode {
return return
} }
var inplicitelyActivateNextAction = false var inplicitelyActivateNextAction = false
if case let .confirmEmail(confirmEmail)? = strongSelf.innerState.data.state, let codeLength = confirmEmail.codeLength, confirmEmail.code.count != codeLength, text.count == codeLength { if case let .confirmEmail(_, _, codeLength?, code)? = strongSelf.innerState.data.state, code.count != codeLength, text.count == codeLength {
inplicitelyActivateNextAction = true inplicitelyActivateNextAction = true
} }
strongSelf.updateState({ state in strongSelf.updateState({ state in

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/Display:Display", "//submodules/Display:Display",
], ],

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",

View File

@ -227,8 +227,8 @@ public func fetchedAvatarGalleryEntries(engine: TelegramEngine, account: Account
if [Namespaces.Peer.CloudGroup, Namespaces.Peer.CloudChannel].contains(peer.id.namespace) { if [Namespaces.Peer.CloudGroup, Namespaces.Peer.CloudChannel].contains(peer.id.namespace) {
var initialMediaIds = Set<MediaId>() var initialMediaIds = Set<MediaId>()
for entry in initialEntries { for entry in initialEntries {
if case let .image(image) = entry { if case let .image(mediaId, _, _, _, _, _, _, _, _, _) = entry {
initialMediaIds.insert(image.0) initialMediaIds.insert(mediaId)
} }
} }
@ -239,8 +239,8 @@ public func fetchedAvatarGalleryEntries(engine: TelegramEngine, account: Account
photosCount += 1 photosCount += 1
for entry in initialEntries { for entry in initialEntries {
let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photosCount)) let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photosCount))
if case let .image(image) = entry { if case let .image(mediaId, imageReference, representations, videoRepresentations, peer, _, _, _, thumbnailData, _) = entry {
result.append(.image(image.0, image.1, image.2, image.3, image.4, nil, indexData, nil, image.8, nil)) result.append(.image(mediaId, imageReference, representations, videoRepresentations, peer, nil, indexData, nil, thumbnailData, nil))
index += 1 index += 1
} }
} }
@ -284,8 +284,8 @@ public func fetchedAvatarGalleryEntries(engine: TelegramEngine, account: Account
if [Namespaces.Peer.CloudGroup, Namespaces.Peer.CloudChannel].contains(peer.id.namespace) { if [Namespaces.Peer.CloudGroup, Namespaces.Peer.CloudChannel].contains(peer.id.namespace) {
var initialMediaIds = Set<MediaId>() var initialMediaIds = Set<MediaId>()
for entry in initialEntries { for entry in initialEntries {
if case let .image(image) = entry { if case let .image(mediaId, _, _, _, _, _, _, _, _, _) = entry {
initialMediaIds.insert(image.0) initialMediaIds.insert(mediaId)
} }
} }
@ -298,8 +298,8 @@ public func fetchedAvatarGalleryEntries(engine: TelegramEngine, account: Account
photosCount += 1 photosCount += 1
for entry in initialEntries { for entry in initialEntries {
let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photosCount)) let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photosCount))
if case let .image(image) = entry { if case let .image(mediaId, imageReference, representations, videoRepresentations, peer, _, _, _, thumbnailData, _) = entry {
result.append(.image(image.0, image.1, image.2, image.3, image.4, nil, indexData, nil, image.8, nil)) result.append(.image(mediaId, imageReference, representations, videoRepresentations, peer, nil, indexData, nil, thumbnailData, nil))
index += 1 index += 1
} }
} }
@ -429,8 +429,8 @@ public class AvatarGalleryController: ViewController, StandalonePresentableContr
let isFirstTime = strongSelf.entries.isEmpty let isFirstTime = strongSelf.entries.isEmpty
var entries = entries var entries = entries
if !isFirstTime, let updated = entries.first, case let .image(image) = updated, !image.3.isEmpty, let previous = strongSelf.entries.first, case let .topImage(topImage) = previous { if !isFirstTime, let updated = entries.first, case let .image(mediaId, imageReference, _, videoRepresentations, peer, index, indexData, messageId, thumbnailData, caption) = updated, !videoRepresentations.isEmpty, let previous = strongSelf.entries.first, case let .topImage(representations, _, _, _, _, _) = previous {
let firstEntry = AvatarGalleryEntry.image(image.0, image.1, topImage.0, image.3, image.4, image.5, image.6, image.7, image.8, image.9) let firstEntry = AvatarGalleryEntry.image(mediaId, imageReference, representations, videoRepresentations, peer, index, indexData, messageId, thumbnailData, caption)
entries.remove(at: 0) entries.remove(at: 0)
entries.insert(firstEntry, at: 0) entries.insert(firstEntry, at: 0)
} }
@ -749,8 +749,8 @@ public class AvatarGalleryController: ViewController, StandalonePresentableContr
if let reference = reference { if let reference = reference {
let _ = (self.context.engine.accountData.updatePeerPhotoExisting(reference: reference) let _ = (self.context.engine.accountData.updatePeerPhotoExisting(reference: reference)
|> deliverOnMainQueue).start(next: { [weak self] photo in |> deliverOnMainQueue).start(next: { [weak self] photo in
if let strongSelf = self, let photo = photo, let firstEntry = strongSelf.entries.first, case let .image(image) = firstEntry { if let strongSelf = self, let photo = photo, let firstEntry = strongSelf.entries.first, case let .image(_, _, _, _, _, index, indexData, messageId, _, caption) = firstEntry {
let updatedEntry = AvatarGalleryEntry.image(photo.imageId, photo.reference, photo.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatar(peer: peerReference, resource: $0.resource)) }), photo.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), strongSelf.peer, image.5, image.6, image.7, photo.immediateThumbnailData, image.9) let updatedEntry = AvatarGalleryEntry.image(photo.imageId, photo.reference, photo.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatar(peer: peerReference, resource: $0.resource)) }), photo.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), strongSelf.peer, index, indexData, messageId, photo.immediateThumbnailData, caption)
for (lhs, rhs) in zip(firstEntry.representations, updatedEntry.representations) { for (lhs, rhs) in zip(firstEntry.representations, updatedEntry.representations) {
if lhs.representation.dimensions == rhs.representation.dimensions { if lhs.representation.dimensions == rhs.representation.dimensions {

View File

@ -252,9 +252,9 @@ final class PeerAvatarImageGalleryItemNode: ZoomableContentGalleryItemNode {
var id: Int64 var id: Int64
var category: String? var category: String?
if case let .image(image) = entry { if case let .image(mediaId, _, _, _, _, _, _, _, _, categoryValue) = entry {
id = image.0.id id = mediaId.id
category = image.9 category = categoryValue
} else { } else {
id = Int64(entry.peer?.id.id._internalGetInt32Value() ?? 0) id = Int64(entry.peer?.id.id._internalGetInt32Value() ?? 0)
if let resource = entry.videoRepresentations.first?.representation.resource as? CloudPhotoSizeMediaResource { if let resource = entry.videoRepresentations.first?.representation.resource as? CloudPhotoSizeMediaResource {
@ -462,7 +462,6 @@ final class PeerAvatarImageGalleryItemNode: ZoomableContentGalleryItemNode {
var positionCompleted = false var positionCompleted = false
var boundsCompleted = false var boundsCompleted = false
var copyCompleted = false var copyCompleted = false
var surfaceCopyCompleted = false
let (maybeCopyView, copyViewBackground) = node.2() let (maybeCopyView, copyViewBackground) = node.2()
copyViewBackground?.alpha = 1.0 copyViewBackground?.alpha = 1.0
@ -508,11 +507,8 @@ final class PeerAvatarImageGalleryItemNode: ZoomableContentGalleryItemNode {
surfaceCopyView.layer.animatePosition(from: CGPoint(x: transformedSurfaceCopyViewInitialFrame.midX, y: transformedSurfaceCopyViewInitialFrame.midY), to: CGPoint(x: transformedSurfaceFrame.midX, y: transformedSurfaceFrame.midY), duration: 0.25 * durationFactor, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false) surfaceCopyView.layer.animatePosition(from: CGPoint(x: transformedSurfaceCopyViewInitialFrame.midX, y: transformedSurfaceCopyViewInitialFrame.midY), to: CGPoint(x: transformedSurfaceFrame.midX, y: transformedSurfaceFrame.midY), duration: 0.25 * durationFactor, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false)
let scale = CGSize(width: transformedSurfaceCopyViewInitialFrame.size.width / transformedSurfaceFrame.size.width, height: transformedSurfaceCopyViewInitialFrame.size.height / transformedSurfaceFrame.size.height) let scale = CGSize(width: transformedSurfaceCopyViewInitialFrame.size.width / transformedSurfaceFrame.size.width, height: transformedSurfaceCopyViewInitialFrame.size.height / transformedSurfaceFrame.size.height)
surfaceCopyView.layer.animate(from: NSValue(caTransform3D: CATransform3DMakeScale(scale.width, scale.height, 1.0)), to: NSValue(caTransform3D: CATransform3DIdentity), keyPath: "transform", timingFunction: kCAMediaTimingFunctionSpring, duration: 0.25 * durationFactor, removeOnCompletion: false, completion: { _ in surfaceCopyView.layer.animate(from: NSValue(caTransform3D: CATransform3DMakeScale(scale.width, scale.height, 1.0)), to: NSValue(caTransform3D: CATransform3DIdentity), keyPath: "transform", timingFunction: kCAMediaTimingFunctionSpring, duration: 0.25 * durationFactor, removeOnCompletion: false, completion: { _ in
surfaceCopyCompleted = true
intermediateCompletion() intermediateCompletion()
}) })
} else {
surfaceCopyCompleted = true
} }
copyView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.1 * durationFactor, removeOnCompletion: false) copyView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.1 * durationFactor, removeOnCompletion: false)

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",

View File

@ -846,7 +846,6 @@ public final class PeerInfoAvatarListContainerNode: ASDisplayNode {
self.updateItems(size: size, transition: .animated(duration: 0.3, curve: .spring), stripTransition: .animated(duration: 0.3, curve: .spring)) self.updateItems(size: size, transition: .animated(duration: 0.3, curve: .spring), stripTransition: .animated(duration: 0.3, curve: .spring))
} }
case .cancelled, .ended: case .cancelled, .ended:
let translation = recognizer.translation(in: self.view)
let velocity = recognizer.velocity(in: self.view) let velocity = recognizer.velocity(in: self.view)
var directionIsToRight: Bool? var directionIsToRight: Bool?
if abs(velocity.x) > 10.0 { if abs(velocity.x) > 10.0 {
@ -879,7 +878,7 @@ public final class PeerInfoAvatarListContainerNode: ASDisplayNode {
} }
func setMainItem(_ item: PeerInfoAvatarListItem) { func setMainItem(_ item: PeerInfoAvatarListItem) {
guard case let .image(image) = item else { guard case let .image(imageReference, _, _, _) = item else {
return return
} }
var items: [PeerInfoAvatarListItem] = [] var items: [PeerInfoAvatarListItem] = []
@ -893,7 +892,7 @@ public final class PeerInfoAvatarListContainerNode: ASDisplayNode {
if representations.isEmpty { if representations.isEmpty {
continue continue
} }
if image.0 == reference { if imageReference == reference {
entries.insert(entry, at: 0) entries.insert(entry, at: 0)
items.insert(.image(reference, representations, videoRepresentations, immediateThumbnailData), at: 0) items.insert(.image(reference, representations, videoRepresentations, immediateThumbnailData), at: 0)
} else { } else {
@ -917,7 +916,7 @@ public final class PeerInfoAvatarListContainerNode: ASDisplayNode {
} }
public func deleteItem(_ item: PeerInfoAvatarListItem) -> Bool { public func deleteItem(_ item: PeerInfoAvatarListItem) -> Bool {
guard case let .image(image) = item else { guard case let .image(imageReference, _, _, _) = item else {
return false return false
} }
@ -936,7 +935,7 @@ public final class PeerInfoAvatarListContainerNode: ASDisplayNode {
if representations.isEmpty { if representations.isEmpty {
continue continue
} }
if image.0 != reference { if imageReference != reference {
entries.append(entry) entries.append(entry)
items.append(.image(reference, representations, videoRepresentations, immediateThumbnailData)) items.append(.image(reference, representations, videoRepresentations, immediateThumbnailData))
} else { } else {
@ -1004,8 +1003,8 @@ public final class PeerInfoAvatarListContainerNode: ASDisplayNode {
} }
var synchronous = false var synchronous = false
if !strongSelf.galleryEntries.isEmpty, let updated = entries.first, case let .image(image) = updated, !image.3.isEmpty, let previous = strongSelf.galleryEntries.first, case let .topImage(topImage) = previous { if !strongSelf.galleryEntries.isEmpty, let updated = entries.first, case let .image(mediaId, reference, _, videoRepresentations, peer, index, indexData, messageId, thumbnailData, caption) = updated, !videoRepresentations.isEmpty, let previous = strongSelf.galleryEntries.first, case let .topImage(representations, _, _, _, _, _) = previous {
let firstEntry = AvatarGalleryEntry.image(image.0, image.1, topImage.0, image.3, image.4, image.5, image.6, image.7, image.8, image.9) let firstEntry = AvatarGalleryEntry.image(mediaId, reference, representations, videoRepresentations, peer, index, indexData, messageId, thumbnailData, caption)
entries.remove(at: 0) entries.remove(at: 0)
entries.insert(firstEntry, at: 0) entries.insert(firstEntry, at: 0)
synchronous = true synchronous = true

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",

View File

@ -70,88 +70,6 @@ private enum ChannelAdminEntryStableId: Hashable {
case addAdminsInfo case addAdminsInfo
case transfer case transfer
case dismiss case dismiss
var hashValue: Int {
switch self {
case .info:
return 0
case .rankTitle:
return 1
case .rank:
return 2
case .rankInfo:
return 3
case .rightsTitle:
return 4
case .addAdminsInfo:
return 5
case .dismiss:
return 6
case .transfer:
return 7
case let .right(flags):
return flags.rawValue.hashValue
}
}
static func ==(lhs: ChannelAdminEntryStableId, rhs: ChannelAdminEntryStableId) -> Bool {
switch lhs {
case .info:
if case .info = rhs {
return true
} else {
return false
}
case .rankTitle:
if case .rankTitle = rhs {
return true
} else {
return false
}
case .rank:
if case .rank = rhs {
return true
} else {
return false
}
case .rankInfo:
if case .rankInfo = rhs {
return true
} else {
return false
}
case .rightsTitle:
if case .rightsTitle = rhs {
return true
} else {
return false
}
case let right(flags):
if case .right(flags) = rhs {
return true
} else {
return false
}
case .addAdminsInfo:
if case .addAdminsInfo = rhs {
return true
} else {
return false
}
case .transfer:
if case .transfer = rhs {
return true
} else {
return false
}
case .dismiss:
if case .dismiss = rhs {
return true
} else {
return false
}
}
}
} }
private enum ChannelAdminEntry: ItemListNodeEntry { private enum ChannelAdminEntry: ItemListNodeEntry {
@ -691,7 +609,7 @@ private func channelAdminControllerEntries(presentationData: PresentationData, s
canTransfer = true canTransfer = true
} }
if let initialParticipant = initialParticipant, case let .member(_, _, adminInfoValue, _, _) = initialParticipant, let adminInfo = adminInfoValue, admin.id != accountPeerId { if let initialParticipant = initialParticipant, case .member = initialParticipant, admin.id != accountPeerId {
if channel.flags.contains(.isCreator) { if channel.flags.contains(.isCreator) {
canDismiss = true canDismiss = true
} else { } else {
@ -812,7 +730,7 @@ private func channelAdminControllerEntries(presentationData: PresentationData, s
entries.append(.rankTitle(presentationData.theme, presentationData.strings.Group_EditAdmin_RankTitle.uppercased(), rankEnabled && state.focusedOnRank ? Int32(currentRank?.count ?? 0) : nil, rankMaxLength)) entries.append(.rankTitle(presentationData.theme, presentationData.strings.Group_EditAdmin_RankTitle.uppercased(), rankEnabled && state.focusedOnRank ? Int32(currentRank?.count ?? 0) : nil, rankMaxLength))
entries.append(.rank(presentationData.theme, presentationData.strings, isCreator ? presentationData.strings.Group_EditAdmin_RankOwnerPlaceholder : presentationData.strings.Group_EditAdmin_RankAdminPlaceholder, currentRank ?? "", rankEnabled)) entries.append(.rank(presentationData.theme, presentationData.strings, isCreator ? presentationData.strings.Group_EditAdmin_RankOwnerPlaceholder : presentationData.strings.Group_EditAdmin_RankAdminPlaceholder, currentRank ?? "", rankEnabled))
if let initialParticipant = initialParticipant, case let .member(participant) = initialParticipant, let adminInfo = participant.adminInfo, admin.id != accountPeerId { if let initialParticipant = initialParticipant, case .member = initialParticipant, admin.id != accountPeerId {
entries.append(.dismiss(presentationData.theme, presentationData.strings.Channel_Moderator_AccessLevelRevoke)) entries.append(.dismiss(presentationData.theme, presentationData.strings.Channel_Moderator_AccessLevelRevoke))
} }
} }

View File

@ -43,32 +43,6 @@ private enum ChannelAdminsSection: Int32 {
private enum ChannelAdminsEntryStableId: Hashable { private enum ChannelAdminsEntryStableId: Hashable {
case index(Int32) case index(Int32)
case peer(PeerId) case peer(PeerId)
var hashValue: Int {
switch self {
case let .index(index):
return index.hashValue
case let .peer(peerId):
return peerId.hashValue
}
}
static func ==(lhs: ChannelAdminsEntryStableId, rhs: ChannelAdminsEntryStableId) -> Bool {
switch lhs {
case let .index(index):
if case .index(index) = rhs {
return true
} else {
return false
}
case let .peer(peerId):
if case .peer(peerId) = rhs {
return true
} else {
return false
}
}
}
} }
private enum ChannelAdminsEntry: ItemListNodeEntry { private enum ChannelAdminsEntry: ItemListNodeEntry {
@ -203,13 +177,13 @@ private enum ChannelAdminsEntry: ItemListNodeEntry {
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem { func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
let arguments = arguments as! ChannelAdminsControllerArguments let arguments = arguments as! ChannelAdminsControllerArguments
switch self { switch self {
case let .recentActions(theme, text): case let .recentActions(_, text):
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: "", sectionId: self.section, style: .blocks, action: { return ItemListDisclosureItem(presentationData: presentationData, title: text, label: "", sectionId: self.section, style: .blocks, action: {
arguments.openRecentActions() arguments.openRecentActions()
}) })
case let .adminsHeader(theme, title): case let .adminsHeader(_, title):
return ItemListSectionHeaderItem(presentationData: presentationData, text: title, sectionId: self.section) return ItemListSectionHeaderItem(presentationData: presentationData, text: title, sectionId: self.section)
case let .adminPeerItem(theme, strings, dateTimeFormat, nameDisplayOrder, _, _, participant, editing, enabled, hasAction): case let .adminPeerItem(_, strings, dateTimeFormat, nameDisplayOrder, _, _, participant, editing, enabled, hasAction):
let peerText: String let peerText: String
var action: (() -> Void)? var action: (() -> Void)?
switch participant.participant { switch participant.participant {
@ -244,7 +218,7 @@ private enum ChannelAdminsEntry: ItemListNodeEntry {
return ItemListPeerActionItem(presentationData: presentationData, icon: PresentationResourcesItemList.addPersonIcon(theme), title: text, sectionId: self.section, editing: editing, action: { return ItemListPeerActionItem(presentationData: presentationData, icon: PresentationResourcesItemList.addPersonIcon(theme), title: text, sectionId: self.section, editing: editing, action: {
arguments.addAdmin() arguments.addAdmin()
}) })
case let .adminsInfo(theme, text): case let .adminsInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section) return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
} }
} }
@ -827,10 +801,8 @@ public func channelAdminsController(context: AccountContext, peerId initialPeerI
return return
} }
var replacedSelf = false
rebuildControllerStackAfterSupergroupUpgrade(controller: controller, navigationController: navigationController, replace: { c in rebuildControllerStackAfterSupergroupUpgrade(controller: controller, navigationController: navigationController, replace: { c in
if c === controller { if c === controller {
replacedSelf = true
return channelAdminsController(context: context, peerId: upgradedPeerId, loadCompleted: { return channelAdminsController(context: context, peerId: upgradedPeerId, loadCompleted: {
}) })
} else { } else {

View File

@ -44,23 +44,6 @@ private enum ChannelBannedMemberEntryStableId: Hashable {
case timeout case timeout
case exceptionInfo case exceptionInfo
case delete case delete
var hashValue: Int {
switch self {
case .info:
return 0
case .rightsHeader:
return 1
case .timeout:
return 2
case .exceptionInfo:
return 3
case .delete:
return 4
case let .right(flags):
return flags.rawValue.hashValue
}
}
} }
private enum ChannelBannedMemberEntry: ItemListNodeEntry { private enum ChannelBannedMemberEntry: ItemListNodeEntry {
@ -223,25 +206,25 @@ private enum ChannelBannedMemberEntry: ItemListNodeEntry {
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem { func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
let arguments = arguments as! ChannelBannedMemberControllerArguments let arguments = arguments as! ChannelBannedMemberControllerArguments
switch self { switch self {
case let .info(theme, strings, dateTimeFormat, peer, presence): case let .info(_, _, dateTimeFormat, peer, presence):
return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .generic, peer: peer, presence: presence, cachedData: nil, state: ItemListAvatarAndNameInfoItemState(), sectionId: self.section, style: .blocks(withTopInset: true, withExtendedBottomInset: false), editingNameUpdated: { _ in return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .generic, peer: peer, presence: presence, cachedData: nil, state: ItemListAvatarAndNameInfoItemState(), sectionId: self.section, style: .blocks(withTopInset: true, withExtendedBottomInset: false), editingNameUpdated: { _ in
}, avatarTapped: { }, avatarTapped: {
}) })
case let .rightsHeader(theme, text): case let .rightsHeader(_, text):
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section) return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .rightItem(theme, _, text, right, value, enabled): case let .rightItem(_, _, text, right, value, enabled):
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, type: .icon, enableInteractiveChanges: enabled, enabled: enabled, sectionId: self.section, style: .blocks, updated: { value in return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, type: .icon, enableInteractiveChanges: enabled, enabled: enabled, sectionId: self.section, style: .blocks, updated: { value in
arguments.toggleRight(right, value) arguments.toggleRight(right, value)
}, activatedWhileDisabled: { }, activatedWhileDisabled: {
arguments.toggleRightWhileDisabled(right) arguments.toggleRightWhileDisabled(right)
}) })
case let .timeout(theme, text, value): case let .timeout(_, text, value):
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .blocks, action: { return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .blocks, action: {
arguments.openTimeout() arguments.openTimeout()
}) })
case let .exceptionInfo(theme, text): case let .exceptionInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section) return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
case let .delete(theme, text): case let .delete(_, text):
return ItemListActionItem(presentationData: presentationData, title: text, kind: .destructive, alignment: .center, sectionId: self.section, style: .blocks, action: { return ItemListActionItem(presentationData: presentationData, title: text, kind: .destructive, alignment: .center, sectionId: self.section, style: .blocks, action: {
arguments.delete() arguments.delete()
}) })
@ -316,7 +299,7 @@ private func channelBannedMemberControllerEntries(presentationData: Presentation
entries.append(.timeout(presentationData.theme, presentationData.strings.GroupPermission_Duration, currentTimeoutString)) entries.append(.timeout(presentationData.theme, presentationData.strings.GroupPermission_Duration, currentTimeoutString))
if let initialParticipant = initialParticipant, case let .member(member) = initialParticipant, let banInfo = member.banInfo, let initialBannedBy = initialBannedBy { if let initialParticipant = initialParticipant, case let .member(_, _, _, banInfo?, _) = initialParticipant, let initialBannedBy = initialBannedBy {
entries.append(.exceptionInfo(presentationData.theme, presentationData.strings.GroupPermission_AddedInfo(initialBannedBy.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), stringForRelativeSymbolicTimestamp(strings: presentationData.strings, relativeTimestamp: banInfo.timestamp, relativeTo: state.referenceTimestamp, dateTimeFormat: presentationData.dateTimeFormat)).string)) entries.append(.exceptionInfo(presentationData.theme, presentationData.strings.GroupPermission_AddedInfo(initialBannedBy.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), stringForRelativeSymbolicTimestamp(strings: presentationData.strings, relativeTimestamp: banInfo.timestamp, relativeTo: state.referenceTimestamp, dateTimeFormat: presentationData.dateTimeFormat)).string))
entries.append(.delete(presentationData.theme, presentationData.strings.GroupPermission_Delete)) entries.append(.delete(presentationData.theme, presentationData.strings.GroupPermission_Delete))
} }
@ -362,7 +345,7 @@ private func channelBannedMemberControllerEntries(presentationData: Presentation
entries.append(.timeout(presentationData.theme, presentationData.strings.GroupPermission_Duration, currentTimeoutString)) entries.append(.timeout(presentationData.theme, presentationData.strings.GroupPermission_Duration, currentTimeoutString))
if let initialParticipant = initialParticipant, case let .member(member) = initialParticipant, let banInfo = member.banInfo, let initialBannedBy = initialBannedBy { if let initialParticipant = initialParticipant, case let .member(_, _, _, banInfo?, _) = initialParticipant, let initialBannedBy = initialBannedBy {
entries.append(.exceptionInfo(presentationData.theme, presentationData.strings.GroupPermission_AddedInfo(initialBannedBy.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), stringForRelativeSymbolicTimestamp(strings: presentationData.strings, relativeTimestamp: banInfo.timestamp, relativeTo: state.referenceTimestamp, dateTimeFormat: presentationData.dateTimeFormat)).string)) entries.append(.exceptionInfo(presentationData.theme, presentationData.strings.GroupPermission_AddedInfo(initialBannedBy.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), stringForRelativeSymbolicTimestamp(strings: presentationData.strings, relativeTimestamp: banInfo.timestamp, relativeTo: state.referenceTimestamp, dateTimeFormat: presentationData.dateTimeFormat)).string))
entries.append(.delete(presentationData.theme, presentationData.strings.GroupPermission_Delete)) entries.append(.delete(presentationData.theme, presentationData.strings.GroupPermission_Delete))
} }
@ -413,7 +396,7 @@ public func channelBannedMemberController(context: AccountContext, peerId: PeerI
var effectiveRightsFlags: TelegramChatBannedRightsFlags var effectiveRightsFlags: TelegramChatBannedRightsFlags
if let updatedFlags = state.updatedFlags { if let updatedFlags = state.updatedFlags {
effectiveRightsFlags = updatedFlags effectiveRightsFlags = updatedFlags
} else if let initialParticipant = initialParticipant, case let .member(member) = initialParticipant, let banInfo = member.banInfo { } else if let initialParticipant = initialParticipant, case let .member(_, _, _, banInfo?, _) = initialParticipant {
effectiveRightsFlags = banInfo.rights.flags effectiveRightsFlags = banInfo.rights.flags
} else { } else {
effectiveRightsFlags = defaultBannedRightsFlags effectiveRightsFlags = defaultBannedRightsFlags
@ -630,8 +613,8 @@ public func channelBannedMemberController(context: AccountContext, peerId: PeerI
} }
var previousRights: TelegramChatBannedRights? var previousRights: TelegramChatBannedRights?
if let initialParticipant = initialParticipant, case let .member(member) = initialParticipant, member.banInfo != nil { if let initialParticipant = initialParticipant, case let .member(_, _, _, banInfo, _) = initialParticipant, banInfo != nil {
previousRights = member.banInfo?.rights previousRights = banInfo?.rights
} }
if let resolvedRights = resolvedRights, previousRights != resolvedRights { if let resolvedRights = resolvedRights, previousRights != resolvedRights {
@ -692,11 +675,6 @@ public func channelBannedMemberController(context: AccountContext, peerId: PeerI
} }
} }
}, error: { _ in }, error: { _ in
updateState { current in
var current = current
current.updating = false
return current
}
})) }))
} else { } else {
updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: context.engine, peerId: peerId, memberId: memberId, bannedRights: cleanResolvedRights) updateRightsDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: context.engine, peerId: peerId, memberId: memberId, bannedRights: cleanResolvedRights)
@ -736,7 +714,7 @@ public func channelBannedMemberController(context: AccountContext, peerId: PeerI
} }
let title: String let title: String
if let initialParticipant = initialParticipant, case let .member(member) = initialParticipant, member.banInfo != nil { if let initialParticipant = initialParticipant, case let .member(_, _, _, banInfo, _) = initialParticipant, banInfo != nil {
title = presentationData.strings.GroupPermission_Title title = presentationData.strings.GroupPermission_Title
} else { } else {
title = presentationData.strings.GroupPermission_NewTitle title = presentationData.strings.GroupPermission_NewTitle

View File

@ -324,9 +324,7 @@ public func channelBlacklistController(context: AccountContext, peerId: PeerId)
let progress = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil)) let progress = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
presentControllerImpl?(progress, nil) presentControllerImpl?(progress, nil)
removePeerDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: context.engine, peerId: peerId, memberId: peer.id, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: Int32.max)) removePeerDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: context.engine, peerId: peerId, memberId: peer.id, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: Int32.max))
|> deliverOnMainQueue).start(error: { [weak progress] _ in |> deliverOnMainQueue).start(error: { _ in
progress?.dismiss()
dismissController?()
}, completed: { [weak progress] in }, completed: { [weak progress] in
progress?.dismiss() progress?.dismiss()
dismissController?() dismissController?()
@ -343,9 +341,6 @@ public func channelBlacklistController(context: AccountContext, peerId: PeerId)
} }
removePeerDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: context.engine, peerId: peerId, memberId: memberId, bannedRights: nil) |> deliverOnMainQueue).start(error: { _ in removePeerDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: context.engine, peerId: peerId, memberId: memberId, bannedRights: nil) |> deliverOnMainQueue).start(error: { _ in
updateState {
return $0.withUpdatedRemovingPeerId(nil)
}
}, completed: { }, completed: {
updateState { updateState {
return $0.withUpdatedRemovingPeerId(nil) return $0.withUpdatedRemovingPeerId(nil)
@ -392,7 +387,6 @@ public func channelBlacklistController(context: AccountContext, peerId: PeerId)
|> then( |> then(
context.peerChannelMemberCategoriesContextsManager.addMember(engine: context.engine, peerId: peerId, memberId: memberId) context.peerChannelMemberCategoriesContextsManager.addMember(engine: context.engine, peerId: peerId, memberId: memberId)
|> map { _ -> Void in |> map { _ -> Void in
return Void()
} }
|> `catch` { _ -> Signal<Void, NoError> in |> `catch` { _ -> Signal<Void, NoError> in
return .complete() return .complete()
@ -400,9 +394,6 @@ public func channelBlacklistController(context: AccountContext, peerId: PeerId)
|> ignoreValues |> ignoreValues
) )
removePeerDisposable.set((signal |> deliverOnMainQueue).start(error: { _ in removePeerDisposable.set((signal |> deliverOnMainQueue).start(error: { _ in
updateState {
return $0.withUpdatedRemovingPeerId(nil)
}
}, completed: { }, completed: {
updateState { updateState {
return $0.withUpdatedRemovingPeerId(nil) return $0.withUpdatedRemovingPeerId(nil)
@ -418,9 +409,6 @@ public func channelBlacklistController(context: AccountContext, peerId: PeerId)
} }
removePeerDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: context.engine, peerId: peerId, memberId: memberId, bannedRights: nil) |> deliverOnMainQueue).start(error: { _ in removePeerDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: context.engine, peerId: peerId, memberId: memberId, bannedRights: nil) |> deliverOnMainQueue).start(error: { _ in
updateState {
return $0.withUpdatedRemovingPeerId(nil)
}
}, completed: { }, completed: {
updateState { updateState {
return $0.withUpdatedRemovingPeerId(nil) return $0.withUpdatedRemovingPeerId(nil)

View File

@ -406,9 +406,6 @@ public func channelDiscussionGroupSetupController(context: AccountContext, peerI
state.searching = false state.searching = false
return state return state
} }
case .hasNotPermissions:
//TODO process error
break
case .groupHistoryIsCurrentlyPrivate: case .groupHistoryIsCurrentlyPrivate:
let presentationData = context.sharedContext.currentPresentationData.with { $0 } let presentationData = context.sharedContext.currentPresentationData.with { $0 }
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Channel_DiscussionGroup_MakeHistoryPublic, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Channel_DiscussionGroup_MakeHistoryPublicProceed, action: { presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Channel_DiscussionGroup_MakeHistoryPublic, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Channel_DiscussionGroup_MakeHistoryPublicProceed, action: {

View File

@ -40,32 +40,6 @@ private enum ChannelMembersSection: Int32 {
private enum ChannelMembersEntryStableId: Hashable { private enum ChannelMembersEntryStableId: Hashable {
case index(Int32) case index(Int32)
case peer(PeerId) case peer(PeerId)
var hashValue: Int {
switch self {
case let .index(index):
return index.hashValue
case let .peer(peerId):
return peerId.hashValue
}
}
static func ==(lhs: ChannelMembersEntryStableId, rhs: ChannelMembersEntryStableId) -> Bool {
switch lhs {
case let .index(index):
if case .index(index) = rhs {
return true
} else {
return false
}
case let .peer(peerId):
if case .peer(peerId) = rhs {
return true
} else {
return false
}
}
}
} }
private enum ChannelMembersEntry: ItemListNodeEntry { private enum ChannelMembersEntry: ItemListNodeEntry {

View File

@ -779,8 +779,8 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
switch participant.participant { switch participant.participant {
case .creator: case .creator:
label = presentationData.strings.Channel_Management_LabelOwner label = presentationData.strings.Channel_Management_LabelOwner
case let .member(member): case let .member(_, _, adminInfo, _, _):
if member.adminInfo != nil { if adminInfo != nil {
label = presentationData.strings.Channel_Management_LabelEditor label = presentationData.strings.Channel_Management_LabelEditor
} }
} }
@ -930,7 +930,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
return entries return entries
} }
} else if let group = peerView.peers[peerId] as? TelegramGroup, let cachedData = peerView.cachedData as? CachedGroupData { } else if let _ = peerView.peers[peerId] as? TelegramGroup, let cachedData = peerView.cachedData as? CachedGroupData {
updateActivity(true) updateActivity(true)
let foundGroupMembers: Signal<[RenderedChannelParticipant], NoError> let foundGroupMembers: Signal<[RenderedChannelParticipant], NoError>
let foundMembers: Signal<[RenderedChannelParticipant], NoError> let foundMembers: Signal<[RenderedChannelParticipant], NoError>
@ -1043,39 +1043,6 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
section = .none section = .none
} }
var canPromote: Bool = false
var canRestrict: Bool = false
/*switch participant.participant {
case .creator:
canPromote = false
canRestrict = false
case let .member(_, _, adminRights, bannedRights):
if channel.hasPermission(.addAdmins) {
canPromote = true
} else {
canPromote = false
}
if channel.hasPermission(.banMembers) {
canRestrict = true
} else {
canRestrict = false
}
if canPromote {
if let bannedRights = bannedRights {
if bannedRights.restrictedBy != account.peerId && !channel.flags.contains(.isCreator) {
canPromote = false
}
}
}
if canRestrict {
if let adminRights = adminRights {
if adminRights.promotedBy != account.peerId && !channel.flags.contains(.isCreator) {
canRestrict = false
}
}
}
}*/
var label: String? var label: String?
var enabled = true var enabled = true
if case .banAndPromoteActions = mode { if case .banAndPromoteActions = mode {
@ -1087,8 +1054,8 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
switch participant.participant { switch participant.participant {
case .creator: case .creator:
label = presentationData.strings.Channel_Management_LabelOwner label = presentationData.strings.Channel_Management_LabelOwner
case let .member(member): case let .member(_, _, adminInfo, _, _):
if member.adminInfo != nil { if adminInfo != nil {
label = presentationData.strings.Channel_Management_LabelEditor label = presentationData.strings.Channel_Management_LabelEditor
} }
} }
@ -1098,17 +1065,6 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
enabled = false enabled = false
} }
var peerActions: [ParticipantRevealAction] = []
/*if case .searchMembers = mode {
if canPromote {
peerActions.append(ParticipantRevealAction(type: .neutral, title: presentationData.strings.GroupInfo_ActionPromote, action: .promote))
}
if canRestrict {
peerActions.append(ParticipantRevealAction(type: .warning, title: presentationData.strings.GroupInfo_ActionRestrict, action: .restrict))
peerActions.append(ParticipantRevealAction(type: .destructive, title: presentationData.strings.Common_Delete, action: .remove))
}
}*/
switch mode { switch mode {
case .searchAdmins: case .searchAdmins:
switch participant.participant { switch participant.participant {
@ -1155,7 +1111,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
default: default:
break break
} }
entries.append(ChannelMembersSearchEntry(index: index, content: .participant(participant: participant, label: label, revealActions: peerActions, revealed: state.revealedPeerId == RevealedPeerId(peerId: participant.peer.id, section: section), enabled: enabled), section: section, dateTimeFormat: presentationData.dateTimeFormat)) entries.append(ChannelMembersSearchEntry(index: index, content: .participant(participant: participant, label: label, revealActions: [], revealed: state.revealedPeerId == RevealedPeerId(peerId: participant.peer.id, section: section), enabled: enabled), section: section, dateTimeFormat: presentationData.dateTimeFormat))
index += 1 index += 1
} }
} }

View File

@ -680,11 +680,6 @@ public func channelPermissionsController(context: AccountContext, peerId origina
removePeerDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: context.engine, peerId: peerId, memberId: memberId, bannedRights: nil) removePeerDisposable.set((context.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: context.engine, peerId: peerId, memberId: memberId, bannedRights: nil)
|> deliverOnMainQueue).start(error: { _ in |> deliverOnMainQueue).start(error: { _ in
updateState { state in
var state = state
state.removingPeerId = nil
return state
}
}, completed: { }, completed: {
updateState { state in updateState { state in
var state = state var state = state

View File

@ -251,7 +251,7 @@ class ChatSlowmodeItemNode: ListViewItemNode {
let _ = apply() let _ = apply()
} }
var textNodes: [(TextNode, CGSize)] = textLayoutAndApply.map { layout, apply -> (TextNode, CGSize) in let textNodes: [(TextNode, CGSize)] = textLayoutAndApply.map { layout, apply -> (TextNode, CGSize) in
let node = apply() let node = apply()
return (node, layout.size) return (node, layout.size)
} }

View File

@ -79,13 +79,13 @@ private enum ConvertToSupergroupEntry: ItemListNodeEntry {
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem { func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
let arguments = arguments as! ConvertToSupergroupArguments let arguments = arguments as! ConvertToSupergroupArguments
switch self { switch self {
case let .info(theme, text): case let .info(_, text):
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section) return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
case let .action(theme, title): case let .action(_, title):
return ItemListActionItem(presentationData: presentationData, title: title, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: { return ItemListActionItem(presentationData: presentationData, title: title, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
arguments.convert() arguments.convert()
}) })
case let .actionInfo(theme, text): case let .actionInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section) return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
} }
} }

View File

@ -312,8 +312,8 @@ private enum DeviceContactInfoEntry: ItemListNodeEntry {
} else { } else {
return false return false
} }
case let .address(lhsIndex, lhsCatIndex, lhsTheme, lhsTitle, lhsValue, lhsImageSignal, lhsSelected): case let .address(lhsIndex, lhsCatIndex, lhsTheme, lhsTitle, lhsValue, _, lhsSelected):
if case let .address(rhsIndex, rhsCatIndex, rhsTheme, rhsTitle, rhsValue, rhsImageSignal, rhsSelected) = rhs, lhsIndex == rhsIndex, lhsCatIndex == rhsCatIndex, lhsTheme === rhsTheme, lhsTitle == rhsTitle, lhsValue == rhsValue, lhsSelected == rhsSelected { if case let .address(rhsIndex, rhsCatIndex, rhsTheme, rhsTitle, rhsValue, _, rhsSelected) = rhs, lhsIndex == rhsIndex, lhsCatIndex == rhsCatIndex, lhsTheme === rhsTheme, lhsTitle == rhsTitle, lhsValue == rhsValue, lhsSelected == rhsSelected {
return true return true
} else { } else {
return false return false
@ -439,7 +439,7 @@ private enum DeviceContactInfoEntry: ItemListNodeEntry {
}) })
case let .phoneNumberShareViaExceptionInfo(_, _, text): case let .phoneNumberShareViaExceptionInfo(_, _, text):
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section) return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
case let .editingPhoneNumber(_, _, strings, id, title, label, value, hasActiveRevealControls): case let .editingPhoneNumber(_, _, _, id, title, label, value, hasActiveRevealControls):
return UserInfoEditingPhoneItem(presentationData: presentationData, id: id, label: title, value: value, editing: UserInfoEditingPhoneItemEditing(editable: true, hasActiveRevealControls: hasActiveRevealControls), sectionId: self.section, setPhoneIdWithRevealedOptions: { lhs, rhs in return UserInfoEditingPhoneItem(presentationData: presentationData, id: id, label: title, value: value, editing: UserInfoEditingPhoneItemEditing(editable: true, hasActiveRevealControls: hasActiveRevealControls), sectionId: self.section, setPhoneIdWithRevealedOptions: { lhs, rhs in
arguments.setPhoneIdWithRevealedOptions(lhs, rhs) arguments.setPhoneIdWithRevealedOptions(lhs, rhs)
}, updated: { value in }, updated: { value in
@ -1002,11 +1002,6 @@ public func deviceContactInfoController(context: AccountContext, subject: Device
case .createContact: case .createContact:
pushControllerImpl?(deviceContactInfoController(context: context, subject: .create(peer: subject.peer, contactData: subject.contactData, isSharing: false, shareViaException: false, completion: { peer, stableId, contactData in pushControllerImpl?(deviceContactInfoController(context: context, subject: .create(peer: subject.peer, contactData: subject.contactData, isSharing: false, shareViaException: false, completion: { peer, stableId, contactData in
dismissImpl?(false) dismissImpl?(false)
if let peer = peer {
} else {
}
}), completed: nil, cancelled: nil)) }), completed: nil, cancelled: nil))
case .addToExisting: case .addToExisting:
addToExistingImpl?() addToExistingImpl?()
@ -1139,7 +1134,6 @@ public func deviceContactInfoController(context: AccountContext, subject: Device
if share, let peer = peer { if share, let peer = peer {
return context.engine.contacts.addContactInteractively(peerId: peer.id, firstName: composedContactData.basicData.firstName, lastName: composedContactData.basicData.lastName, phoneNumber: filteredPhoneNumbers.first?.value ?? "", addToPrivacyExceptions: shareViaException && addToPrivacyExceptions) return context.engine.contacts.addContactInteractively(peerId: peer.id, firstName: composedContactData.basicData.firstName, lastName: composedContactData.basicData.lastName, phoneNumber: filteredPhoneNumbers.first?.value ?? "", addToPrivacyExceptions: shareViaException && addToPrivacyExceptions)
|> mapToSignal { _ -> Signal<(DeviceContactStableId, DeviceContactExtendedData, Peer?)?, AddContactError> in |> mapToSignal { _ -> Signal<(DeviceContactStableId, DeviceContactExtendedData, Peer?)?, AddContactError> in
return .complete()
} }
|> then( |> then(
context.account.postbox.transaction { transaction -> (DeviceContactStableId, DeviceContactExtendedData, Peer?)? in context.account.postbox.transaction { transaction -> (DeviceContactStableId, DeviceContactExtendedData, Peer?)? in
@ -1401,12 +1395,7 @@ func addContactOptionsController(context: AccountContext, peer: Peer?, contactDa
controller.setItemGroups([ controller.setItemGroups([
ActionSheetItemGroup(items: [ ActionSheetItemGroup(items: [
ActionSheetButtonItem(title: presentationData.strings.Profile_CreateNewContact, action: { [weak controller] in ActionSheetButtonItem(title: presentationData.strings.Profile_CreateNewContact, action: { [weak controller] in
controller?.present(context.sharedContext.makeDeviceContactInfoController(context: context, subject: .create(peer: peer, contactData: contactData, isSharing: peer != nil, shareViaException: false, completion: { peer, stableId, contactData in controller?.present(context.sharedContext.makeDeviceContactInfoController(context: context, subject: .create(peer: peer, contactData: contactData, isSharing: peer != nil, shareViaException: false, completion: { _, _, _ in
if let peer = peer {
} else {
}
}), completed: nil, cancelled: nil), in: .window(.root), with: ViewControllerPresentationArguments(presentationAnimation: .modalSheet)) }), completed: nil, cancelled: nil), in: .window(.root), with: ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
dismissAction() dismissAction()
}), }),

View File

@ -80,17 +80,17 @@ private enum GroupPreHistorySetupEntry: ItemListNodeEntry {
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem { func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
let arguments = arguments as! GroupPreHistorySetupArguments let arguments = arguments as! GroupPreHistorySetupArguments
switch self { switch self {
case let .header(theme, text): case let .header(_, text):
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section) return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .visible(theme, text, value): case let .visible(_, text, value):
return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: value, zeroSeparatorInsets: false, sectionId: self.section, action: { return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: value, zeroSeparatorInsets: false, sectionId: self.section, action: {
arguments.toggle(true) arguments.toggle(true)
}) })
case let .hidden(theme, text, value): case let .hidden(_, text, value):
return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: value, zeroSeparatorInsets: false, sectionId: self.section, action: { return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: value, zeroSeparatorInsets: false, sectionId: self.section, action: {
arguments.toggle(false) arguments.toggle(false)
}) })
case let .info(theme, text): case let .info(_, text):
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section) return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
} }
} }

View File

@ -182,8 +182,8 @@ class GroupStickerPackCurrentItemNode: ItemListRevealOptionsItemNode {
var file: TelegramMediaFile? var file: TelegramMediaFile?
var previousFile: TelegramMediaFile? var previousFile: TelegramMediaFile?
if let currentItem = currentItem, case let .found(found) = currentItem.content { if let currentItem = currentItem, case let .found(_, topItem, _) = currentItem.content {
previousFile = found.topItem?.file previousFile = topItem?.file
} }
switch item.content { switch item.content {

View File

@ -38,15 +38,6 @@ private enum GroupStickerPackEntryId: Hashable {
case index(Int32) case index(Int32)
case pack(ItemCollectionId) case pack(ItemCollectionId)
var hashValue: Int {
switch self {
case let .index(index):
return index.hashValue
case let .pack(id):
return id.hashValue
}
}
static func ==(lhs: GroupStickerPackEntryId, rhs: GroupStickerPackEntryId) -> Bool { static func ==(lhs: GroupStickerPackEntryId, rhs: GroupStickerPackEntryId) -> Bool {
switch lhs { switch lhs {
case let .index(index): case let .index(index):
@ -240,8 +231,8 @@ private enum GroupStickerPackEntry: ItemListNodeEntry {
}) })
case let .currentPack(_, theme, strings, content): case let .currentPack(_, theme, strings, content):
return GroupStickerPackCurrentItem(theme: theme, strings: strings, account: arguments.account, content: content, sectionId: self.section, action: { return GroupStickerPackCurrentItem(theme: theme, strings: strings, account: arguments.account, content: content, sectionId: self.section, action: {
if case let .found(found) = content { if case let .found(packInfo, _, _) = content {
arguments.openStickerPack(found.packInfo) arguments.openStickerPack(packInfo)
} }
}) })
} }

View File

@ -244,7 +244,7 @@ private final class OldChannelsActionPanelNode: ASDisplayNode {
transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(), size: CGSize(width: layout.size.width, height: UIScreenPixel))) transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(), size: CGSize(width: layout.size.width, height: UIScreenPixel)))
self.buttonNode.updateLayout(width: layout.size.width - sideInset * 2.0, transition: transition) let _ = self.buttonNode.updateLayout(width: layout.size.width - sideInset * 2.0, transition: transition)
transition.updateFrame(node: self.buttonNode, frame: CGRect(origin: CGPoint(x: sideInset, y: verticalInset), size: CGSize(width: layout.size.width, height: buttonHeight))) transition.updateFrame(node: self.buttonNode, frame: CGRect(origin: CGPoint(x: sideInset, y: verticalInset), size: CGSize(width: layout.size.width, height: buttonHeight)))
return buttonHeight + verticalInset * 2.0 + insets.bottom return buttonHeight + verticalInset * 2.0 + insets.bottom

View File

@ -20,7 +20,6 @@ final class PeerBanTimeoutController: ActionSheetController {
init(context: AccountContext, currentValue: Int32, applyValue: @escaping (Int32?) -> Void) { init(context: AccountContext, currentValue: Int32, applyValue: @escaping (Int32?) -> Void) {
let presentationData = context.sharedContext.currentPresentationData.with { $0 } let presentationData = context.sharedContext.currentPresentationData.with { $0 }
let theme = presentationData.theme
let strings = presentationData.strings let strings = presentationData.strings
super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) super.init(theme: ActionSheetControllerTheme(presentationData: presentationData))

View File

@ -117,7 +117,7 @@ public func presentPeerReportOptions(context: AccountContext, parent: ViewContro
displaySuccess() displaySuccess()
completion(nil, false) completion(nil, false)
}) })
case let .profilePhoto(peerId, photoId): case let .profilePhoto(peerId, _):
let _ = (context.engine.peers.reportPeerPhoto(peerId: peerId, reason: reportReason, message: "") let _ = (context.engine.peers.reportPeerPhoto(peerId: peerId, reason: reportReason, message: "")
|> deliverOnMainQueue).start(completed: { |> deliverOnMainQueue).start(completed: {
displaySuccess() displaySuccess()
@ -243,7 +243,7 @@ public func peerReportOptionsController(context: AccountContext, subject: PeerRe
displaySuccess() displaySuccess()
completion(nil, true) completion(nil, true)
}) })
case let .profilePhoto(peerId, photoId): case let .profilePhoto(peerId, _):
let _ = (context.engine.peers.reportPeerPhoto(peerId: peerId, reason: reportReason, message: message) let _ = (context.engine.peers.reportPeerPhoto(peerId: peerId, reason: reportReason, message: message)
|> deliverOnMainQueue).start(completed: { |> deliverOnMainQueue).start(completed: {
displaySuccess() displaySuccess()

View File

@ -59,7 +59,7 @@ private enum PhoneLabelEntry: ItemListNodeEntry {
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem { func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
let arguments = arguments as! PhoneLabelArguments let arguments = arguments as! PhoneLabelArguments
switch self { switch self {
case let .label(_, theme, value, text, selected): case let .label(_, _, value, text, selected):
return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: selected, zeroSeparatorInsets: false, sectionId: self.section, action: { return ItemListCheckboxItem(presentationData: presentationData, title: text, style: .left, checked: selected, zeroSeparatorInsets: false, sectionId: self.section, action: {
arguments.selectLabel(value) arguments.selectLabel(value)
}) })

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",
"//submodules/Display:Display", "//submodules/Display:Display",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/Postbox:Postbox", "//submodules/Postbox:Postbox",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",
"//submodules/Display:Display", "//submodules/Display:Display",

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",

View File

@ -387,52 +387,8 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
} }
private func peerNearbyContextMenuItems(context: AccountContext, peerId: PeerId, present: @escaping (ViewController) -> Void) -> Signal<[ContextMenuItem], NoError> { private func peerNearbyContextMenuItems(context: AccountContext, peerId: PeerId, present: @escaping (ViewController) -> Void) -> Signal<[ContextMenuItem], NoError> {
let presentationData = context.sharedContext.currentPresentationData.with({ $0 }) return context.account.postbox.transaction { _ -> [ContextMenuItem] in
return context.account.postbox.transaction { transaction -> [ContextMenuItem] in let items: [ContextMenuItem] = []
var items: [ContextMenuItem] = []
//
// let peer = transaction.getPeer(peerId)
//
// if let peer = peer as? TelegramUser {
// items.append(.action(ContextMenuActionItem(text: presentationData.strings.ChatList_Context_AddToContacts, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Add"), color: theme.contextMenu.primaryColor) }, action: { _, f in
// f(.default)
// })))
// } else {
// items.append(.action(ContextMenuActionItem(text: presentationData.strings.PeopleNearby_Context_JoinGroup, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Add"), color: theme.contextMenu.primaryColor) }, action: { _, f in
// let _ = (joinChannel(account: context.account, peerId: peerId) |> deliverOnMainQueue).start(next: { participant in
// f(.default)
// }, error: { error in
//// if let strongSelf = self {
//// if case .tooMuchJoined = error {
//// if let parentNavigationController = strongSelf.parentNavigationController {
//// let context = strongSelf.context
//// let link = strongSelf.link
//// let navigateToPeer = strongSelf.navigateToPeer
//// let resolvedState = strongSelf.resolvedState
//// parentNavigationController.pushViewController(oldChannelsController(context: strongSelf.context, intent: .join, completed: { [weak parentNavigationController] value in
//// if value {
//// (parentNavigationController?.viewControllers.last as? ViewController)?.present(JoinLinkPreviewController(context: context, link: link, navigateToPeer: navigateToPeer, parentNavigationController: parentNavigationController, resolvedState: resolvedState), in: .window(.root))
//// }
//// }))
//// } else {
//// strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.Join_ChannelsTooMuch, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
//// }
//// strongSelf.dismiss()
//// }
//// }
// })
// })))
//
// items.append(.action(ContextMenuActionItem(text: presentationData.strings.PeopleNearby_Context_UnrelatedLocation, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Report"), color: theme.contextMenu.primaryColor) }, action: { _, f in
// let _ = (TelegramCore.reportPeer(account: context.account, peerId: peerId, reason: .irrelevantLocation)
// |> deliverOnMainQueue).start(completed: {
// let _ = ApplicationSpecificNotice.setIrrelevantPeerGeoReport(postbox: context.account.postbox, peerId: peerId).start()
//
// present(textAlertController(context: context, title: nil, text: presentationData.strings.ReportPeer_AlertSuccess, actions: [TextAlertAction(type: TextAlertActionType.defaultAction, title: presentationData.strings.Common_OK, action: {})]))
// })
// f(.default)
// })))
// }
return items return items
} }

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",
], ],

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit",
"//submodules/Display:Display", "//submodules/Display:Display",

View File

@ -82,7 +82,7 @@ extension String {
var pureNumber = self.replacingOccurrences( of: "[^0-9]", with: "", options: .regularExpression) var pureNumber = self.replacingOccurrences( of: "[^0-9]", with: "", options: .regularExpression)
for index in 0 ..< pattern.count { for index in 0 ..< pattern.count {
guard index < pureNumber.count else { return pureNumber } guard index < pureNumber.count else { return pureNumber }
let stringIndex = String.Index(encodedOffset: index) let stringIndex = pattern.index(pattern.startIndex, offsetBy: index)
let patternCharacter = pattern[stringIndex] let patternCharacter = pattern[stringIndex]
guard patternCharacter != replacementCharacter else { continue } guard patternCharacter != replacementCharacter else { continue }
pureNumber.insert(patternCharacter, at: stringIndex) pureNumber.insert(patternCharacter, at: stringIndex)

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/libphonenumber:libphonenumber", "//submodules/libphonenumber:libphonenumber",
], ],

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/TelegramCore:TelegramCore", "//submodules/TelegramCore:TelegramCore",
"//submodules/Postbox:Postbox", "//submodules/Postbox:Postbox",

View File

@ -1745,8 +1745,7 @@ public func chatWebpageSnippetFileData(account: Account, fileReference: FileMedi
let disposable = DisposableSet() let disposable = DisposableSet()
disposable.add(resourceData.start(next: { data in disposable.add(resourceData.start(next: { data in
subscriber.putNext(data) subscriber.putNext(data)
}, error: { error in }, error: { _ in
subscriber.putError(error)
}, completed: { }, completed: {
subscriber.putCompletion() subscriber.putCompletion()
})) }))
@ -1766,8 +1765,7 @@ public func chatWebpageSnippetPhotoData(account: Account, photoReference: ImageM
let disposable = DisposableSet() let disposable = DisposableSet()
disposable.add(resourceData.start(next: { data in disposable.add(resourceData.start(next: { data in
subscriber.putNext(data) subscriber.putNext(data)
}, error: { error in }, error: { _ in
subscriber.putError(error)
}, completed: { }, completed: {
subscriber.putCompletion() subscriber.putCompletion()
})) }))
@ -2186,7 +2184,6 @@ public func chatMessageImageFile(account: Account, fileReference: FileMediaRefer
public func instantPageImageFile(account: Account, fileReference: FileMediaReference, fetched: Bool = false) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> { public func instantPageImageFile(account: Account, fileReference: FileMediaReference, fetched: Bool = false) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> {
return chatMessageFileDatas(account: account, fileReference: fileReference, progressive: false, fetched: fetched) return chatMessageFileDatas(account: account, fileReference: fileReference, progressive: false, fetched: fetched)
|> map { value in |> map { value in
let thumbnailData = value._0
let fullSizePath = value._1 let fullSizePath = value._1
let fullSizeComplete = value._2 let fullSizeComplete = value._2
return { arguments in return { arguments in

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/TelegramCore:TelegramCore", "//submodules/TelegramCore:TelegramCore",
], ],

View File

@ -6,6 +6,9 @@ swift_library(
srcs = glob([ srcs = glob([
"Sources/**/*.swift", "Sources/**/*.swift",
]), ]),
copts = [
"-warnings-as-errors",
],
deps = [ deps = [
"//submodules/Display:Display", "//submodules/Display:Display",
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",

View File

@ -4,7 +4,6 @@ import AlertUI
import AccountContext import AccountContext
import SwiftSignalKit import SwiftSignalKit
import ItemListUI import ItemListUI
import PresentationDataUtils
public extension ItemListController { public extension ItemListController {
convenience init<ItemGenerationArguments>(context: AccountContext, state: Signal<(ItemListControllerState, (ItemListNodeState, ItemGenerationArguments)), NoError>, tabBarItem: Signal<ItemListControllerTabBarItem, NoError>? = nil) { convenience init<ItemGenerationArguments>(context: AccountContext, state: Signal<(ItemListControllerState, (ItemListNodeState, ItemGenerationArguments)), NoError>, tabBarItem: Signal<ItemListControllerTabBarItem, NoError>? = nil) {

Some files were not shown because too many files have changed in this diff Show More