From 2d66131682fa9bd525658a694aca9235afb5b8af Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 4 Aug 2021 01:30:57 +0200 Subject: [PATCH] Refactoring --- submodules/AccountContext/BUILD | 3 + .../Sources/AccountContext.swift | 14 ++-- .../Sources/DeviceContactDataManager.swift | 2 +- .../Sources/DownloadedMediaStoreManager.swift | 2 +- .../Sources/IsMediaStreamable.swift | 8 +- .../AccountContext/Sources/MediaManager.swift | 10 +-- .../OverlayAudioPlayerController.swift | 2 +- .../Sources/OverlayMediaManager.swift | 2 +- .../Sources/PresentationCallManager.swift | 4 +- .../Sources/SharedMediaPlayer.swift | 2 +- .../Sources/ThemeUpdateManager.swift | 2 +- .../Sources/UniversalVideoNode.swift | 4 +- .../Sources/WallpaperUploadManager.swift | 2 +- .../AccountContext/Sources/WatchManager.swift | 2 +- submodules/AccountUtils/BUILD | 3 + submodules/ActionSheetPeerItem/BUILD | 3 + submodules/ActivityIndicator/BUILD | 3 + submodules/AlertUI/BUILD | 3 + submodules/AnimatedAvatarSetNode/BUILD | 3 + submodules/AnimatedCountLabelNode/BUILD | 3 + submodules/AnimatedNavigationStripeNode/BUILD | 3 + submodules/AnimatedStickerNode/BUILD | 3 + .../Sources/AnimatedStickerNode.swift | 84 +++++++++++++++---- submodules/AnimationUI/BUILD | 3 + submodules/AppLock/BUILD | 3 + submodules/AppLock/Sources/AppLock.swift | 10 +-- submodules/ArchivedStickerPacksNotice/BUILD | 3 + ...ArchivedStickerPacksNoticeController.swift | 10 +-- submodules/AudioBlob/BUILD | 3 + submodules/AuthTransferUI/BUILD | 3 + .../AuthTransferConfirmationScreen.swift | 8 +- .../Sources/AuthTransferScanScreen.swift | 6 +- submodules/AuthorizationUI/BUILD | 3 + submodules/AvatarNode/BUILD | 3 + .../AvatarNode/Sources/PeerAvatar.swift | 3 +- submodules/BotPaymentsUI/BUILD | 3 + .../Sources/BotCheckoutActionButton.swift | 2 +- .../BotCheckoutPaymentMethodSheet.swift | 1 - submodules/CallListUI/BUILD | 3 + .../Sources/CallListControllerNode.swift | 2 +- submodules/Camera/BUILD | 3 + submodules/ChatHistoryImportTasks/BUILD | 3 + submodules/ChatImportUI/BUILD | 3 + submodules/ChatInterfaceState/BUILD | 4 +- .../Sources/ChatInterfaceState.swift | 82 +++++++++--------- .../ChatListFilterSettingsHeaderItem/BUILD | 3 + submodules/ChatListSearchItemHeader/BUILD | 3 + submodules/ChatListSearchItemNode/BUILD | 4 +- .../Sources/ChatListSearchItem.swift | 1 - .../ChatListSearchRecentPeersNode/BUILD | 4 +- .../ChatListSearchRecentPeersNode.swift | 50 +++++------ submodules/ChatListUI/BUILD | 3 + .../ChatListUI/Sources/ChatContextMenus.swift | 9 +- .../Sources/ChatListController.swift | 11 ++- .../Sources/ChatListControllerNode.swift | 5 +- .../ChatListFilterPresetCategoryItem.swift | 11 +-- .../ChatListFilterPresetController.swift | 32 +++---- .../ChatListFilterPresetListController.swift | 36 ++++---- ...ChatListFilterTabInlineContainerNode.swift | 20 ++--- .../Sources/ChatListRecentPeersListItem.swift | 4 +- .../Sources/ChatListSearchContainerNode.swift | 16 +--- .../Sources/Node/ChatListItem.swift | 17 ++-- .../Sources/Node/ChatListNode.swift | 24 +++--- .../Sources/Node/ChatListNodeEntries.swift | 8 +- .../Sources/Node/ChatListNodeLocation.swift | 12 +-- .../ChatMessageInteractiveMediaBadge/BUILD | 3 + submodules/ChatTitleActivityNode/BUILD | 3 + submodules/CheckNode/BUILD | 3 + submodules/CloudData/BUILD | 3 + submodules/CloudData/Sources/CloudData.swift | 8 +- submodules/ComponentFlow/BUILD | 3 + .../Source/Host/RootHostView.swift | 2 +- submodules/ComposePollUI/BUILD | 4 + .../Sources/CreatePollController.swift | 23 +++-- .../Sources/CreatePollTextInputItem.swift | 5 +- submodules/ConfettiEffect/BUILD | 3 + .../ConfettiEffect/Sources/ConfettiView.swift | 10 +-- submodules/ContactListUI/BUILD | 3 + .../Sources/ContactListNode.swift | 4 +- .../InviteContactsControllerNode.swift | 2 +- submodules/ContactsPeerItem/BUILD | 3 + submodules/ContextUI/BUILD | 3 + .../ContextUI/Sources/ContextController.swift | 18 +--- submodules/CounterContollerTitleView/BUILD | 3 + submodules/CountrySelectionUI/BUILD | 3 + submodules/DatePickerNode/BUILD | 3 + .../DatePickerNode/Sources/TapeNode.swift | 2 +- submodules/DateSelectionUI/BUILD | 3 + submodules/DebugSettingsUI/BUILD | 3 + .../Sources/DebugAccountsController.swift | 4 +- .../Sources/DebugController.swift | 2 - .../DeleteChatPeerActionSheetItem/BUILD | 3 + submodules/DeviceAccess/BUILD | 3 + submodules/DeviceLocationManager/BUILD | 3 + submodules/DirectionalPanGesture/BUILD | 3 + submodules/Display/BUILD | 3 + .../Source/ContainableController.swift | 4 +- .../ContainedViewLayoutTransition.swift | 2 - submodules/Display/Source/GenerateImage.swift | 1 - submodules/Display/Source/ListView.swift | 36 -------- .../Navigation/NavigationController.swift | 4 +- .../WindowInputAccessoryHeightProvider.swift | 2 +- submodules/Emoji/BUILD | 3 + submodules/EncryptionKeyVisualization/BUILD | 3 + submodules/FileMediaResourceStatus/BUILD | 3 + submodules/GalleryData/BUILD | 3 + .../GalleryData/Sources/GalleryData.swift | 2 +- submodules/GalleryUI/BUILD | 3 + .../GalleryUI/Sources/GalleryController.swift | 17 +--- .../GalleryUI/Sources/GalleryFooterNode.swift | 4 - .../Sources/GalleryItemTransitionNode.swift | 2 +- .../GalleryThumbnailContainerNode.swift | 4 +- .../Items/ChatAnimationGalleryItem.swift | 4 +- .../Items/ChatDocumentGalleryItem.swift | 2 +- .../Items/ChatExternalFileGalleryItem.swift | 2 +- .../Sources/Items/ChatImageGalleryItem.swift | 4 +- .../SecretMediaPreviewController.swift | 9 -- submodules/GameUI/BUILD | 3 + submodules/Geocoding/BUILD | 3 + submodules/GlassButtonNode/BUILD | 3 + submodules/GradientBackground/BUILD | 1 + submodules/GraphCore/BUILD | 3 + .../BarsComponentController.swift | 1 - .../Charts/Renderes/BaseChartRenderer.swift | 2 +- .../Charts/Renderes/LinesChartRenderer.swift | 1 - .../Charts/Renderes/PecentChartRenderer.swift | 2 +- .../PercentPieAnimationRenderer.swift | 1 - .../Sources/Helpers/DisplayLinkService.swift | 2 +- submodules/GraphUI/BUILD | 3 + submodules/GridMessageSelectionNode/BUILD | 3 + submodules/HashtagSearchUI/BUILD | 3 + submodules/HexColor/BUILD | 3 + submodules/HorizontalPeerItem/BUILD | 4 +- .../Sources/HorizontalPeerItem.swift | 17 ++-- submodules/ImageBlur/BUILD | 3 + submodules/ImageCompression/BUILD | 3 + submodules/ImageTransparency/BUILD | 3 + .../Sources/ImageTransparency.swift | 2 +- submodules/ImportStickerPackUI/BUILD | 3 + .../ImportStickerPackControllerNode.swift | 5 +- .../ImportStickerPackTitleController.swift | 4 +- submodules/InstantPageCache/BUILD | 3 + submodules/InstantPageUI/BUILD | 3 + .../Sources/InstantPageContentNode.swift | 12 +-- .../Sources/InstantPageControllerNode.swift | 15 ++-- .../Sources/InstantPageLayout.swift | 8 +- .../Sources/InstantPageScrollableNode.swift | 2 +- .../InstantPageSlideshowItemNode.swift | 12 +-- .../Sources/InstantPageSubContentNode.swift | 12 +-- submodules/InviteLinksUI/BUILD | 3 + .../Sources/InviteLinkInviteController.swift | 1 - .../Sources/InviteLinkViewController.swift | 1 - .../Sources/ItemListDatePickerItem.swift | 1 - submodules/ItemListAddressItem/BUILD | 3 + .../ItemListAvatarAndNameInfoItem/BUILD | 3 + .../Sources/ItemListAvatarAndNameItem.swift | 12 +-- submodules/ItemListPeerActionItem/BUILD | 3 + submodules/ItemListPeerItem/BUILD | 3 + submodules/ItemListStickerPackItem/BUILD | 3 + .../Sources/ItemListStickerPackItem.swift | 2 +- submodules/ItemListUI/BUILD | 3 + .../Sources/ItemListControllerNode.swift | 2 +- submodules/ItemListVenueItem/BUILD | 3 + submodules/JoinLinkPreviewUI/BUILD | 3 + submodules/LanguageLinkPreviewUI/BUILD | 3 + submodules/LanguageSuggestionUI/BUILD | 3 + .../LanguageSuggestionController.swift | 1 - .../Sources/LegacyMediaPickers.swift | 2 +- .../Source/ObjCRuntimeUtils/RuntimeUtils.h | 2 + .../Source/ObjCRuntimeUtils/RuntimeUtils.m | 4 + submodules/Postbox/Sources/Message.swift | 54 ++++++++++++ .../Sources/ShareControllerPeerGridItem.swift | 2 +- .../ShareControllerRecentPeersGridItem.swift | 2 +- .../Sources/TelegramEngine/Peers/Peer.swift | 10 +++ .../TelegramCore/Sources/Utils/Coding.swift | 14 ++++ .../Sources/PresenceStrings.swift | 5 +- .../TelegramUI/Sources/ChatTitleView.swift | 2 +- .../Sources/PeerInfo/PeerInfoData.swift | 2 +- ...annelMemberCategoriesContextsManager.swift | 2 +- 179 files changed, 691 insertions(+), 467 deletions(-) create mode 100644 submodules/TelegramCore/Sources/Utils/Coding.swift diff --git a/submodules/AccountContext/BUILD b/submodules/AccountContext/BUILD index 280d5f0d5e..b5558e05f4 100644 --- a/submodules/AccountContext/BUILD +++ b/submodules/AccountContext/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/TelegramAudio:TelegramAudio", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index 345cf6a3a8..6367b713ef 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -536,7 +536,7 @@ public enum CreateGroupMode { case locatedGroup(latitude: Double, longitude: Double, address: String?) } -public protocol AppLockContext: class { +public protocol AppLockContext: AnyObject { var invalidAttempts: Signal { get } var autolockDeadline: Signal { get } @@ -545,10 +545,10 @@ public protocol AppLockContext: class { func failedUnlockAttempt() } -public protocol RecentSessionsController: class { +public protocol RecentSessionsController: AnyObject { } -public protocol SharedAccountContext: class { +public protocol SharedAccountContext: AnyObject { var sharedContainerPath: String { get } var basePath: String { get } var mainWindow: Window1? { get } @@ -703,16 +703,16 @@ public final class TonContext { public protocol ComposeController: ViewController { } -public protocol ChatLocationContextHolder: class { +public protocol ChatLocationContextHolder: AnyObject { } -public protocol AccountGroupCallContext: class { +public protocol AccountGroupCallContext: AnyObject { } -public protocol AccountGroupCallContextCache: class { +public protocol AccountGroupCallContextCache: AnyObject { } -public protocol AccountContext: class { +public protocol AccountContext: AnyObject { var sharedContext: SharedAccountContext { get } var account: Account { get } var engine: TelegramEngine { get } diff --git a/submodules/AccountContext/Sources/DeviceContactDataManager.swift b/submodules/AccountContext/Sources/DeviceContactDataManager.swift index 10db927b98..ed4d87ee3b 100644 --- a/submodules/AccountContext/Sources/DeviceContactDataManager.swift +++ b/submodules/AccountContext/Sources/DeviceContactDataManager.swift @@ -6,7 +6,7 @@ import SwiftSignalKit public typealias DeviceContactStableId = String -public protocol DeviceContactDataManager: class { +public protocol DeviceContactDataManager: AnyObject { func personNameDisplayOrder() -> Signal func basicData() -> Signal<[DeviceContactStableId: DeviceContactBasicData], NoError> func basicDataForNormalizedPhoneNumber(_ normalizedNumber: DeviceContactNormalizedPhoneNumber) -> Signal<[(DeviceContactStableId, DeviceContactBasicData)], NoError> diff --git a/submodules/AccountContext/Sources/DownloadedMediaStoreManager.swift b/submodules/AccountContext/Sources/DownloadedMediaStoreManager.swift index 05653f8d6d..1b2a9cce55 100644 --- a/submodules/AccountContext/Sources/DownloadedMediaStoreManager.swift +++ b/submodules/AccountContext/Sources/DownloadedMediaStoreManager.swift @@ -4,7 +4,7 @@ import Postbox import TelegramUIPreferences import SwiftSignalKit -public protocol DownloadedMediaStoreManager: class { +public protocol DownloadedMediaStoreManager: AnyObject { func store(_ media: AnyMediaReference, timestamp: Int32, peerType: MediaAutoDownloadPeerType) } diff --git a/submodules/AccountContext/Sources/IsMediaStreamable.swift b/submodules/AccountContext/Sources/IsMediaStreamable.swift index 548fa2f8d6..0c93c9ceb8 100644 --- a/submodules/AccountContext/Sources/IsMediaStreamable.swift +++ b/submodules/AccountContext/Sources/IsMediaStreamable.swift @@ -18,8 +18,8 @@ public func isMediaStreamable(message: Message, media: TelegramMediaFile) -> Boo return false } for attribute in media.attributes { - if case let .Video(video) = attribute { - if video.flags.contains(.supportsStreaming) { + if case let .Video(_, _, flags) = attribute { + if flags.contains(.supportsStreaming) { return true } break @@ -41,8 +41,8 @@ public func isMediaStreamable(media: TelegramMediaFile) -> Bool { return false } for attribute in media.attributes { - if case let .Video(video) = attribute { - if video.flags.contains(.supportsStreaming) { + if case let .Video(_, _, flags) = attribute { + if flags.contains(.supportsStreaming) { return true } break diff --git a/submodules/AccountContext/Sources/MediaManager.swift b/submodules/AccountContext/Sources/MediaManager.swift index e3ddeddff4..35d6a5bcda 100644 --- a/submodules/AccountContext/Sources/MediaManager.swift +++ b/submodules/AccountContext/Sources/MediaManager.swift @@ -132,7 +132,7 @@ public enum MediaManagerPlayerType { case file } -public protocol MediaManager: class { +public protocol MediaManager: AnyObject { var audioSession: ManagedAudioSession { get } var galleryHiddenMediaManager: GalleryHiddenMediaManager { get } var universalVideoManager: UniversalVideoManager { get } @@ -177,11 +177,11 @@ public enum GalleryHiddenMediaId: Hashable { } } -public protocol GalleryHiddenMediaTarget: class { +public protocol GalleryHiddenMediaTarget: AnyObject { func getTransitionInfo(messageId: MessageId, media: Media) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))? } -public protocol GalleryHiddenMediaManager: class { +public protocol GalleryHiddenMediaManager: AnyObject { func hiddenIds() -> Signal, NoError> func addSource(_ signal: Signal) -> Int func removeSource(_ index: Int) @@ -190,7 +190,7 @@ public protocol GalleryHiddenMediaManager: class { func findTarget(messageId: MessageId, media: Media) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))? } -public protocol UniversalVideoManager: class { +public protocol UniversalVideoManager: AnyObject { func attachUniversalVideoContent(content: UniversalVideoContent, priority: UniversalVideoPriority, create: () -> UniversalVideoContentNode & ASDisplayNode, update: @escaping (((UniversalVideoContentNode & ASDisplayNode), Bool)?) -> Void) -> (AnyHashable, Int32) func detachUniversalVideoContent(id: AnyHashable, index: Int32) func withUniversalVideoContent(id: AnyHashable, _ f: ((UniversalVideoContentNode & ASDisplayNode)?) -> Void) @@ -218,7 +218,7 @@ public struct RecordedAudioData { } } -public protocol ManagedAudioRecorder: class { +public protocol ManagedAudioRecorder: AnyObject { var beginWithTone: Bool { get } var micLevel: Signal { get } var recordingState: Signal { get } diff --git a/submodules/AccountContext/Sources/OverlayAudioPlayerController.swift b/submodules/AccountContext/Sources/OverlayAudioPlayerController.swift index a3257e0740..b08d747ca4 100644 --- a/submodules/AccountContext/Sources/OverlayAudioPlayerController.swift +++ b/submodules/AccountContext/Sources/OverlayAudioPlayerController.swift @@ -1,5 +1,5 @@ import Foundation -public protocol OverlayAudioPlayerController: class { +public protocol OverlayAudioPlayerController: AnyObject { } diff --git a/submodules/AccountContext/Sources/OverlayMediaManager.swift b/submodules/AccountContext/Sources/OverlayMediaManager.swift index 45d7eec061..e5f860c704 100644 --- a/submodules/AccountContext/Sources/OverlayMediaManager.swift +++ b/submodules/AccountContext/Sources/OverlayMediaManager.swift @@ -15,7 +15,7 @@ public final class OverlayMediaControllerEmbeddingItem { } } -public protocol OverlayMediaController: class { +public protocol OverlayMediaController: AnyObject { var updatePossibleEmbeddingItem: ((OverlayMediaControllerEmbeddingItem?) -> Void)? { get set } var embedPossibleEmbeddingItem: ((OverlayMediaControllerEmbeddingItem) -> Bool)? { get set } diff --git a/submodules/AccountContext/Sources/PresentationCallManager.swift b/submodules/AccountContext/Sources/PresentationCallManager.swift index 4e47725f2b..6eedded2b2 100644 --- a/submodules/AccountContext/Sources/PresentationCallManager.swift +++ b/submodules/AccountContext/Sources/PresentationCallManager.swift @@ -131,7 +131,7 @@ public final class PresentationCallVideoView { } } -public protocol PresentationCall: class { +public protocol PresentationCall: AnyObject { var context: AccountContext { get } var isIntegratedWithCallKit: Bool { get } var internalId: CallSessionInternalId { get } @@ -391,7 +391,7 @@ public extension GroupCallParticipantsContext.Participant { } } -public protocol PresentationGroupCall: class { +public protocol PresentationGroupCall: AnyObject { var account: Account { get } var accountContext: AccountContext { get } var internalId: CallSessionInternalId { get } diff --git a/submodules/AccountContext/Sources/SharedMediaPlayer.swift b/submodules/AccountContext/Sources/SharedMediaPlayer.swift index 55285fd463..fee597a187 100644 --- a/submodules/AccountContext/Sources/SharedMediaPlayer.swift +++ b/submodules/AccountContext/Sources/SharedMediaPlayer.swift @@ -156,7 +156,7 @@ public protocol SharedMediaPlaylistLocation { func isEqual(to: SharedMediaPlaylistLocation) -> Bool } -public protocol SharedMediaPlaylist: class { +public protocol SharedMediaPlaylist: AnyObject { var id: SharedMediaPlaylistId { get } var location: SharedMediaPlaylistLocation { get } var state: Signal { get } diff --git a/submodules/AccountContext/Sources/ThemeUpdateManager.swift b/submodules/AccountContext/Sources/ThemeUpdateManager.swift index 1e2f7bef56..093f5b8029 100644 --- a/submodules/AccountContext/Sources/ThemeUpdateManager.swift +++ b/submodules/AccountContext/Sources/ThemeUpdateManager.swift @@ -3,5 +3,5 @@ import SwiftSignalKit import TelegramCore import TelegramPresentationData -public protocol ThemeUpdateManager: class { +public protocol ThemeUpdateManager: AnyObject { } diff --git a/submodules/AccountContext/Sources/UniversalVideoNode.swift b/submodules/AccountContext/Sources/UniversalVideoNode.swift index 8c14428978..0c7e9aa193 100644 --- a/submodules/AccountContext/Sources/UniversalVideoNode.swift +++ b/submodules/AccountContext/Sources/UniversalVideoNode.swift @@ -8,7 +8,7 @@ import Display import TelegramAudio import UniversalMediaPlayer -public protocol UniversalVideoContentNode: class { +public protocol UniversalVideoContentNode: AnyObject { var ready: Signal { get } var status: Signal { get } var bufferingStatus: Signal<(IndexSet, Int)?, NoError> { get } @@ -47,7 +47,7 @@ public extension UniversalVideoContent { } } -public protocol UniversalVideoDecoration: class { +public protocol UniversalVideoDecoration: AnyObject { var backgroundNode: ASDisplayNode? { get } var contentContainerNode: ASDisplayNode { get } var foregroundNode: ASDisplayNode? { get } diff --git a/submodules/AccountContext/Sources/WallpaperUploadManager.swift b/submodules/AccountContext/Sources/WallpaperUploadManager.swift index 5c3a67f351..3787b2fe55 100644 --- a/submodules/AccountContext/Sources/WallpaperUploadManager.swift +++ b/submodules/AccountContext/Sources/WallpaperUploadManager.swift @@ -18,7 +18,7 @@ public enum WallpaperUploadManagerStatus { } } -public protocol WallpaperUploadManager: class { +public protocol WallpaperUploadManager: AnyObject { func stateSignal() -> Signal func presentationDataUpdated(_ presentationData: PresentationData) } diff --git a/submodules/AccountContext/Sources/WatchManager.swift b/submodules/AccountContext/Sources/WatchManager.swift index b7574c28f8..bf9b931d94 100644 --- a/submodules/AccountContext/Sources/WatchManager.swift +++ b/submodules/AccountContext/Sources/WatchManager.swift @@ -16,7 +16,7 @@ public struct WatchRunningTasks: Equatable { } } -public protocol WatchManager: class { +public protocol WatchManager: AnyObject { var watchAppInstalled: Signal { get } var navigateToMessageRequested: Signal { get } var runningTasks: Signal { get } diff --git a/submodules/AccountUtils/BUILD b/submodules/AccountUtils/BUILD index 0d89e02324..56991b2885 100644 --- a/submodules/AccountUtils/BUILD +++ b/submodules/AccountUtils/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/Postbox:Postbox", diff --git a/submodules/ActionSheetPeerItem/BUILD b/submodules/ActionSheetPeerItem/BUILD index df81383f16..cacfba4843 100644 --- a/submodules/ActionSheetPeerItem/BUILD +++ b/submodules/ActionSheetPeerItem/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/TelegramCore:TelegramCore", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ActivityIndicator/BUILD b/submodules/ActivityIndicator/BUILD index 08c019b637..38c3fb9888 100644 --- a/submodules/ActivityIndicator/BUILD +++ b/submodules/ActivityIndicator/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/Display:Display", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/AlertUI/BUILD b/submodules/AlertUI/BUILD index f9b4dacc69..9f7f33fd96 100644 --- a/submodules/AlertUI/BUILD +++ b/submodules/AlertUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/Display:Display", ], diff --git a/submodules/AnimatedAvatarSetNode/BUILD b/submodules/AnimatedAvatarSetNode/BUILD index 95d1481e21..21321e8fc3 100644 --- a/submodules/AnimatedAvatarSetNode/BUILD +++ b/submodules/AnimatedAvatarSetNode/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/Display:Display", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/AnimatedCountLabelNode/BUILD b/submodules/AnimatedCountLabelNode/BUILD index 27cdd1b3f8..55f7c774f7 100644 --- a/submodules/AnimatedCountLabelNode/BUILD +++ b/submodules/AnimatedCountLabelNode/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/Display:Display", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/AnimatedNavigationStripeNode/BUILD b/submodules/AnimatedNavigationStripeNode/BUILD index b0de90d445..74d6a6c970 100644 --- a/submodules/AnimatedNavigationStripeNode/BUILD +++ b/submodules/AnimatedNavigationStripeNode/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/Display:Display", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/AnimatedStickerNode/BUILD b/submodules/AnimatedStickerNode/BUILD index 655f34543c..f983796f85 100644 --- a/submodules/AnimatedStickerNode/BUILD +++ b/submodules/AnimatedStickerNode/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/AnimatedStickerNode/Sources/AnimatedStickerNode.swift b/submodules/AnimatedStickerNode/Sources/AnimatedStickerNode.swift index 9606e718e1..2dda65089b 100644 --- a/submodules/AnimatedStickerNode/Sources/AnimatedStickerNode.swift +++ b/submodules/AnimatedStickerNode/Sources/AnimatedStickerNode.swift @@ -88,7 +88,7 @@ public final class AnimatedStickerFrame { } } -public protocol AnimatedStickerFrameSource: class { +public protocol AnimatedStickerFrameSource: AnyObject { var frameRate: Int { get } var frameCount: Int { get } var frameIndex: Int { get } @@ -139,7 +139,10 @@ public final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource var frameRate = 0 var frameCount = 0 - if !self.data.withUnsafeBytes({ (bytes: UnsafePointer) -> Bool in + if !self.data.withUnsafeBytes({ buffer -> Bool in + guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return false + } var frameRateValue: Int32 = 0 var frameCountValue: Int32 = 0 var widthValue: Int32 = 0 @@ -180,7 +183,10 @@ public final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource self.decodeBuffer = Data(count: self.bytesPerRow * height) self.frameBuffer = Data(count: self.bytesPerRow * height) let frameBufferLength = self.frameBuffer.count - self.frameBuffer.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer) -> Void in + self.frameBuffer.withUnsafeMutableBytes { buffer -> Void in + guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } memset(bytes, 0, frameBufferLength) } } @@ -199,12 +205,19 @@ public final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource let frameIndex = self.frameIndex - self.data.withUnsafeBytes { (bytes: UnsafePointer) -> Void in + self.data.withUnsafeBytes { buffer -> Void in + guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } + if self.offset + 4 > dataLength { if self.dataComplete { self.frameIndex = 0 self.offset = self.initialOffset - self.frameBuffer.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer) -> Void in + self.frameBuffer.withUnsafeMutableBytes { buffer -> Void in + guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } memset(bytes, 0, frameBufferLength) } } @@ -221,9 +234,21 @@ public final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource self.offset += 4 if draw { - self.scratchBuffer.withUnsafeMutableBytes { (scratchBytes: UnsafeMutablePointer) -> Void in - self.decodeBuffer.withUnsafeMutableBytes { (decodeBytes: UnsafeMutablePointer) -> Void in - self.frameBuffer.withUnsafeMutableBytes { (frameBytes: UnsafeMutablePointer) -> Void in + self.scratchBuffer.withUnsafeMutableBytes { scratchBuffer -> Void in + guard let scratchBytes = scratchBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } + + self.decodeBuffer.withUnsafeMutableBytes { decodeBuffer -> Void in + guard let decodeBytes = decodeBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } + + self.frameBuffer.withUnsafeMutableBytes { frameBuffer -> Void in + guard let frameBytes = frameBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } + compression_decode_buffer(decodeBytes, decodeBufferLength, bytes.advanced(by: self.offset), Int(frameLength), UnsafeMutableRawPointer(scratchBytes), COMPRESSION_LZFSE) var lhs = UnsafeMutableRawPointer(frameBytes).assumingMemoryBound(to: UInt64.self) @@ -253,7 +278,10 @@ public final class AnimatedStickerCachedFrameSource: AnimatedStickerFrameSource isLastFrame = true self.frameIndex = 0 self.offset = self.initialOffset - self.frameBuffer.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer) -> Void in + self.frameBuffer.withUnsafeMutableBytes { buffer -> Void in + guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } memset(bytes, 0, frameBufferLength) } } @@ -351,7 +379,10 @@ private final class ManagedFileImpl { assert(queue.isCurrent()) } var result = Data(count: count) - result.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer) -> Void in + result.withUnsafeMutableBytes { buffer -> Void in + guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } let readCount = self.read(bytes, count) assert(readCount == count) } @@ -399,7 +430,7 @@ private func compressFrame(width: Int, height: Int, rgbData: Data) -> Data? { assert(yuvaPixelsPerAlphaRow % 2 == 0) let yuvaLength = Int(width) * Int(height) * 2 + yuvaPixelsPerAlphaRow * Int(height) / 2 - var yuvaFrameData = malloc(yuvaLength)! + let yuvaFrameData = malloc(yuvaLength)! defer { free(yuvaFrameData) } @@ -422,7 +453,10 @@ private func compressFrame(width: Int, height: Int, rgbData: Data) -> Data? { var maybeResultSize: Int? - compressedFrameData.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer) -> Void in + compressedFrameData.withUnsafeMutableBytes { buffer -> Void in + guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } let length = compression_encode_buffer(bytes, compressedFrameDataLength, yuvaFrameData.assumingMemoryBound(to: UInt8.self), yuvaLength, scratchData, COMPRESSION_LZFSE) maybeResultSize = length } @@ -579,9 +613,21 @@ private final class AnimatedStickerDirectFrameSourceCache { let decodeBufferLength = self.decodeBuffer.count - compressedData.withUnsafeBytes { (bytes: UnsafePointer) -> Void in - self.scratchBuffer.withUnsafeMutableBytes { (scratchBytes: UnsafeMutablePointer) -> Void in - self.decodeBuffer.withUnsafeMutableBytes { (decodeBytes: UnsafeMutablePointer) -> Void in + compressedData.withUnsafeBytes { buffer -> Void in + guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } + + self.scratchBuffer.withUnsafeMutableBytes { scratchBuffer -> Void in + guard let scratchBytes = scratchBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } + + self.decodeBuffer.withUnsafeMutableBytes { decodeBuffer -> Void in + guard let decodeBytes = decodeBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } + let resultLength = compression_decode_buffer(decodeBytes, decodeBufferLength, bytes, length, UnsafeMutableRawPointer(scratchBytes), COMPRESSION_LZFSE) frameData = Data(bytes: decodeBytes, count: resultLength) @@ -644,7 +690,11 @@ private final class AnimatedStickerDirectFrameSource: AnimatedStickerFrameSource return AnimatedStickerFrame(data: yuvData, type: .yuva, width: self.width, height: self.height, bytesPerRow: 0, index: frameIndex, isLastFrame: frameIndex == self.frameCount - 1, totalFrames: self.frameCount) } else { var frameData = Data(count: self.bytesPerRow * self.height) - frameData.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer) -> Void in + frameData.withUnsafeMutableBytes { buffer -> Void in + guard let bytes = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return + } + memset(bytes, 0, self.bytesPerRow * self.height) self.animation.renderFrame(with: Int32(frameIndex), into: bytes, width: Int32(self.width), height: Int32(self.height), bytesPerRow: Int32(self.bytesPerRow)) } @@ -853,7 +903,7 @@ public final class AnimatedStickerNode: ASDisplayNode { strongSelf.isSetUpForPlayback = false strongSelf.isPlaying = true } - var fromIndex = strongSelf.playFromIndex + let fromIndex = strongSelf.playFromIndex strongSelf.playFromIndex = nil strongSelf.play(fromIndex: fromIndex) } else if strongSelf.canDisplayFirstFrame { diff --git a/submodules/AnimationUI/BUILD b/submodules/AnimationUI/BUILD index 8bac875566..296930b006 100644 --- a/submodules/AnimationUI/BUILD +++ b/submodules/AnimationUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/rlottie:RLottieBinding", diff --git a/submodules/AppLock/BUILD b/submodules/AppLock/BUILD index ae89bbf200..ff6e8e8147 100644 --- a/submodules/AppLock/BUILD +++ b/submodules/AppLock/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/AppLock/Sources/AppLock.swift b/submodules/AppLock/Sources/AppLock.swift index 993663bce7..6fe5ddef16 100644 --- a/submodules/AppLock/Sources/AppLock.swift +++ b/submodules/AppLock/Sources/AppLock.swift @@ -150,7 +150,7 @@ public final class AppLockContextImpl: AppLockContext { strongSelf.autolockTimeout.set(nil) strongSelf.autolockReportTimeout.set(nil) } else { - if let autolockTimeout = passcodeSettings.autolockTimeout, !appInForeground { + if let _ = passcodeSettings.autolockTimeout, !appInForeground { shouldDisplayCoveringView = true } @@ -184,7 +184,7 @@ public final class AppLockContextImpl: AppLockContext { } passcodeController.ensureInputFocused() } else { - let passcodeController = PasscodeEntryController(applicationBindings: strongSelf.applicationBindings, accountManager: strongSelf.accountManager, appLockContext: strongSelf, presentationData: presentationData, presentationDataSignal: strongSelf.presentationDataSignal, statusBarHost: window?.statusBarHost, challengeData: accessChallengeData.data, biometrics: biometrics, arguments: PasscodeEntryControllerPresentationArguments(animated: !becameActiveRecently, lockIconInitialFrame: { [weak self] in + let passcodeController = PasscodeEntryController(applicationBindings: strongSelf.applicationBindings, accountManager: strongSelf.accountManager, appLockContext: strongSelf, presentationData: presentationData, presentationDataSignal: strongSelf.presentationDataSignal, statusBarHost: window?.statusBarHost, challengeData: accessChallengeData.data, biometrics: biometrics, arguments: PasscodeEntryControllerPresentationArguments(animated: !becameActiveRecently, lockIconInitialFrame: { if let lockViewFrame = lockIconInitialFrame() { return lockViewFrame } else { @@ -203,7 +203,7 @@ public final class AppLockContextImpl: AppLockContext { passcodeController.isOpaqueWhenInOverlay = true strongSelf.passcodeController = passcodeController if let rootViewController = strongSelf.rootController { - if let presentedViewController = rootViewController.presentedViewController as? UIActivityViewController { + if let _ = rootViewController.presentedViewController as? UIActivityViewController { } else { rootViewController.dismiss(animated: false, completion: nil) } @@ -227,14 +227,14 @@ public final class AppLockContextImpl: AppLockContext { window.coveringView = coveringView if let rootViewController = strongSelf.rootController { - if let presentedViewController = rootViewController.presentedViewController as? UIActivityViewController { + if let _ = rootViewController.presentedViewController as? UIActivityViewController { } else { rootViewController.dismiss(animated: false, completion: nil) } } } } else { - if let coveringView = strongSelf.coveringView { + if let _ = strongSelf.coveringView { strongSelf.coveringView = nil strongSelf.window?.coveringView = nil } diff --git a/submodules/ArchivedStickerPacksNotice/BUILD b/submodules/ArchivedStickerPacksNotice/BUILD index 8d54e521f8..cf24e9bda3 100644 --- a/submodules/ArchivedStickerPacksNotice/BUILD +++ b/submodules/ArchivedStickerPacksNotice/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ArchivedStickerPacksNotice/Sources/ArchivedStickerPacksNoticeController.swift b/submodules/ArchivedStickerPacksNotice/Sources/ArchivedStickerPacksNoticeController.swift index cb43c40d4a..13a56523d3 100644 --- a/submodules/ArchivedStickerPacksNotice/Sources/ArchivedStickerPacksNoticeController.swift +++ b/submodules/ArchivedStickerPacksNotice/Sources/ArchivedStickerPacksNoticeController.swift @@ -151,14 +151,14 @@ private final class ArchivedStickersNoticeAlertContentNode: AlertContentNode { } private func dequeueTransition() { - guard let layout = self.validLayout, let transition = self.enqueuedTransitions.first else { + guard let _ = self.validLayout, let transition = self.enqueuedTransitions.first else { return } self.enqueuedTransitions.remove(at: 0) - var options = ListViewDeleteAndInsertOptions() + let options = ListViewDeleteAndInsertOptions() - self.listView.transaction(deleteIndices: transition.deletions, insertIndicesAndItems: transition.insertions, updateIndicesAndItems: transition.updates, options: options, updateSizeAndInsets: nil, updateOpaqueState: nil, completion: { [weak self] _ in + self.listView.transaction(deleteIndices: transition.deletions, insertIndicesAndItems: transition.insertions, updateIndicesAndItems: transition.updates, options: options, updateSizeAndInsets: nil, updateOpaqueState: nil, completion: { _ in }) } @@ -302,14 +302,14 @@ public func archivedStickerPacksNoticeController(context: AccountContext, archiv })]) let controller = AlertController(theme: AlertControllerTheme(presentationData: presentationData), contentNode: contentNode) - let presentationDataDisposable = context.sharedContext.presentationData.start(next: { [weak controller, weak contentNode] presentationData in + let presentationDataDisposable = context.sharedContext.presentationData.start(next: { [weak controller] presentationData in controller?.theme = AlertControllerTheme(presentationData: presentationData) }) controller.dismissed = { presentationDataDisposable.dispose() disposable.dispose() } - dismissImpl = { [weak controller, weak contentNode] in + dismissImpl = { [weak controller] in controller?.dismissAnimated() } return controller diff --git a/submodules/AudioBlob/BUILD b/submodules/AudioBlob/BUILD index 4e0c55ac05..72c69fa1aa 100644 --- a/submodules/AudioBlob/BUILD +++ b/submodules/AudioBlob/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/AuthTransferUI/BUILD b/submodules/AuthTransferUI/BUILD index 82321614ec..dbadbfe3f1 100644 --- a/submodules/AuthTransferUI/BUILD +++ b/submodules/AuthTransferUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/TelegramCore:TelegramCore", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", diff --git a/submodules/AuthTransferUI/Sources/AuthTransferConfirmationScreen.swift b/submodules/AuthTransferUI/Sources/AuthTransferConfirmationScreen.swift index d5b76addce..ccb27eaeeb 100644 --- a/submodules/AuthTransferUI/Sources/AuthTransferConfirmationScreen.swift +++ b/submodules/AuthTransferUI/Sources/AuthTransferConfirmationScreen.swift @@ -253,12 +253,10 @@ private final class AuthDataTransferSplashScreenNode: ViewControllerTracingNode let animationFitSize = CGSize(width: min(500.0, layout.size.width - sideInset + 20.0), height: 500.0) let animationSize = self.animationNode?.preferredSize()?.fitted(animationFitSize) ?? animationFitSize let iconSize: CGSize = animationSize - var iconOffset = CGPoint() + let iconOffset = CGPoint() let titleSize = self.titleNode.updateLayout(CGSize(width: layout.size.width - sideInset * 2.0, height: layout.size.height)) - let hasRTL = self.badgeTextNodes.first?.cachedLayout?.hasRTL ?? false - var badgeTextSizes: [CGSize] = [] var textSizes: [CGSize] = [] var textContentHeight: CGFloat = 0.0 @@ -290,9 +288,9 @@ private final class AuthDataTransferSplashScreenNode: ViewControllerTracingNode let buttonFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - buttonWidth) / 2.0), y: layout.size.height - bottomInset - buttonHeight), size: CGSize(width: buttonWidth, height: buttonHeight)) transition.updateFrame(node: self.buttonNode, frame: buttonFrame) - self.buttonNode.updateLayout(width: buttonFrame.width, transition: transition) + let _ = self.buttonNode.updateLayout(width: buttonFrame.width, transition: transition) - var maxContentVerticalOrigin = buttonFrame.minY - 12.0 - contentHeight + let maxContentVerticalOrigin = buttonFrame.minY - 12.0 - contentHeight contentVerticalOrigin = min(contentVerticalOrigin, maxContentVerticalOrigin) diff --git a/submodules/AuthTransferUI/Sources/AuthTransferScanScreen.swift b/submodules/AuthTransferUI/Sources/AuthTransferScanScreen.swift index 5fbd877788..4b3d87832f 100644 --- a/submodules/AuthTransferUI/Sources/AuthTransferScanScreen.swift +++ b/submodules/AuthTransferUI/Sources/AuthTransferScanScreen.swift @@ -44,7 +44,7 @@ private func generateFrameImage() -> UIImage? { context.setLineWidth(4.0) context.setLineCap(.round) - var path = CGMutablePath(); + let path = CGMutablePath() path.move(to: CGPoint(x: 2.0, y: 2.0 + 26.0)) path.addArc(tangent1End: CGPoint(x: 2.0, y: 2.0), tangent2End: CGPoint(x: 2.0 + 26.0, y: 2.0), radius: 6.0) path.addLine(to: CGPoint(x: 2.0 + 26.0, y: 2.0)) @@ -412,8 +412,8 @@ private final class AuthTransferScanScreenNode: ViewControllerTracingNode, UIScr let dimAlpha: CGFloat let dimRect: CGRect let controlsAlpha: CGFloat - var centerDimAlpha: CGFloat = 0.0 - var frameAlpha: CGFloat = 1.0 + let centerDimAlpha: CGFloat = 0.0 + let frameAlpha: CGFloat = 1.0 if let focusedRect = self.focusedRect { controlsAlpha = 0.0 dimAlpha = 1.0 diff --git a/submodules/AuthorizationUI/BUILD b/submodules/AuthorizationUI/BUILD index 968bcdf9eb..c3c89a9c0a 100644 --- a/submodules/AuthorizationUI/BUILD +++ b/submodules/AuthorizationUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/TelegramCore:TelegramCore", diff --git a/submodules/AvatarNode/BUILD b/submodules/AvatarNode/BUILD index 7e52852b6b..b2b1a33bdf 100644 --- a/submodules/AvatarNode/BUILD +++ b/submodules/AvatarNode/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/AvatarNode/Sources/PeerAvatar.swift b/submodules/AvatarNode/Sources/PeerAvatar.swift index 711af8dd55..ca5cb90297 100644 --- a/submodules/AvatarNode/Sources/PeerAvatar.swift +++ b/submodules/AvatarNode/Sources/PeerAvatar.swift @@ -60,8 +60,7 @@ public func peerAvatarImageData(account: Account, peerReference: PeerReference?, subscriber.putNext(nil) } } - }, error: { error in - subscriber.putError(error) + }, error: { _ in }, completed: { subscriber.putCompletion() }) diff --git a/submodules/BotPaymentsUI/BUILD b/submodules/BotPaymentsUI/BUILD index b8672e7958..30ad6de487 100644 --- a/submodules/BotPaymentsUI/BUILD +++ b/submodules/BotPaymentsUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/TelegramCore:TelegramCore", diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutActionButton.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutActionButton.swift index e784f933b6..b7aa1ea18d 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutActionButton.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutActionButton.swift @@ -55,7 +55,7 @@ final class BotCheckoutActionButton: HighlightableButtonNode { let previousState = self.state self.state = state - if let (absoluteRect, containerSize) = self.validLayout, let previousState = previousState { + if let (absoluteRect, containerSize) = self.validLayout, let _ = previousState { self.updateLayout(absoluteRect: absoluteRect, containerSize: containerSize, transition: .immediate) } } diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentMethodSheet.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentMethodSheet.swift index 2d77d7d1ad..c3f64e00d4 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentMethodSheet.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentMethodSheet.swift @@ -38,7 +38,6 @@ final class BotCheckoutPaymentMethodSheetController: ActionSheetController { init(context: AccountContext, currentMethod: BotCheckoutPaymentMethod?, methods: [BotCheckoutPaymentMethod], applyValue: @escaping (BotCheckoutPaymentMethod) -> Void, newCard: @escaping () -> Void) { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let theme = presentationData.theme let strings = presentationData.strings super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) diff --git a/submodules/CallListUI/BUILD b/submodules/CallListUI/BUILD index 1a2c6bb541..6f02400710 100644 --- a/submodules/CallListUI/BUILD +++ b/submodules/CallListUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/CallListUI/Sources/CallListControllerNode.swift b/submodules/CallListUI/Sources/CallListControllerNode.swift index 06dcda5d71..bd995283c0 100644 --- a/submodules/CallListUI/Sources/CallListControllerNode.swift +++ b/submodules/CallListUI/Sources/CallListControllerNode.swift @@ -321,7 +321,7 @@ final class CallListControllerNode: ASDisplayNode { }, openInfo: { [weak self] peerId, messages in self?.openInfo(peerId, messages) }, delete: { [weak self] messageIds in - guard let strongSelf = self, let peerId = messageIds.first?.peerId else { + guard let peerId = messageIds.first?.peerId else { return } let _ = (context.engine.data.get( diff --git a/submodules/Camera/BUILD b/submodules/Camera/BUILD index 6cced36441..4cb5ed826e 100644 --- a/submodules/Camera/BUILD +++ b/submodules/Camera/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ChatHistoryImportTasks/BUILD b/submodules/ChatHistoryImportTasks/BUILD index 0bb2b8f3b6..b7be33ae9a 100644 --- a/submodules/ChatHistoryImportTasks/BUILD +++ b/submodules/ChatHistoryImportTasks/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ ], visibility = [ diff --git a/submodules/ChatImportUI/BUILD b/submodules/ChatImportUI/BUILD index 63889b0ae2..4a4235c56a 100644 --- a/submodules/ChatImportUI/BUILD +++ b/submodules/ChatImportUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ChatInterfaceState/BUILD b/submodules/ChatInterfaceState/BUILD index 3ed561edb1..c1850fcdaa 100644 --- a/submodules/ChatInterfaceState/BUILD +++ b/submodules/ChatInterfaceState/BUILD @@ -6,11 +6,13 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", - "//submodules/Postbox:Postbox", "//submodules/TelegramCore:TelegramCore", "//submodules/TextFormat:TextFormat", "//submodules/AccountContext:AccountContext", diff --git a/submodules/ChatInterfaceState/Sources/ChatInterfaceState.swift b/submodules/ChatInterfaceState/Sources/ChatInterfaceState.swift index 3a7e8845e0..ff8496c42d 100644 --- a/submodules/ChatInterfaceState/Sources/ChatInterfaceState.swift +++ b/submodules/ChatInterfaceState/Sources/ChatInterfaceState.swift @@ -1,6 +1,5 @@ import Foundation import UIKit -import Postbox import TelegramCore import TextFormat import AccountContext @@ -12,13 +11,13 @@ public enum ChatTextInputMediaRecordingButtonMode: Int32 { } public struct ChatInterfaceSelectionState: Codable, Equatable { - public let selectedIds: Set + public let selectedIds: Set public static func ==(lhs: ChatInterfaceSelectionState, rhs: ChatInterfaceSelectionState) -> Bool { return lhs.selectedIds == rhs.selectedIds } - public init(selectedIds: Set) { + public init(selectedIds: Set) { self.selectedIds = selectedIds } @@ -26,7 +25,7 @@ public struct ChatInterfaceSelectionState: Codable, Equatable { let container = try decoder.container(keyedBy: StringCodingKey.self) if let data = try? container.decodeIfPresent(Data.self, forKey: "i") { - self.selectedIds = Set(MessageId.decodeArrayFromBuffer(ReadBuffer(data: data))) + self.selectedIds = Set(EngineMessage.Id.decodeArrayFromData(data)) } else { self.selectedIds = Set() } @@ -35,20 +34,19 @@ public struct ChatInterfaceSelectionState: Codable, Equatable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: StringCodingKey.self) - let buffer = WriteBuffer() - MessageId.encodeArrayToBuffer(Array(selectedIds), buffer: buffer) + let data = EngineMessage.Id.encodeArrayToData(Array(selectedIds)) - try container.encode(buffer.makeData(), forKey: "i") + try container.encode(data, forKey: "i") } } public struct ChatEditMessageState: Codable, Equatable { - public let messageId: MessageId + public let messageId: EngineMessage.Id public let inputState: ChatTextInputState public let disableUrlPreview: String? public let inputTextMaxLength: Int32? - public init(messageId: MessageId, inputState: ChatTextInputState, disableUrlPreview: String?, inputTextMaxLength: Int32?) { + public init(messageId: EngineMessage.Id, inputState: ChatTextInputState, disableUrlPreview: String?, inputTextMaxLength: Int32?) { self.messageId = messageId self.inputState = inputState self.disableUrlPreview = disableUrlPreview @@ -58,8 +56,8 @@ public struct ChatEditMessageState: Codable, Equatable { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: StringCodingKey.self) - self.messageId = MessageId( - peerId: PeerId((try? container.decode(Int64.self, forKey: "mp")) ?? 0), + self.messageId = EngineMessage.Id( + peerId: EnginePeer.Id((try? container.decode(Int64.self, forKey: "mp")) ?? 0), namespace: (try? container.decode(Int32.self, forKey: "mn")) ?? 0, id: (try? container.decode(Int32.self, forKey: "mi")) ?? 0 ) @@ -102,10 +100,10 @@ public struct ChatEditMessageState: Codable, Equatable { } public struct ChatInterfaceMessageActionsState: Codable, Equatable { - public var closedButtonKeyboardMessageId: MessageId? - public var dismissedButtonKeyboardMessageId: MessageId? - public var processedSetupReplyMessageId: MessageId? - public var closedPinnedMessageId: MessageId? + public var closedButtonKeyboardMessageId: EngineMessage.Id? + public var dismissedButtonKeyboardMessageId: EngineMessage.Id? + public var processedSetupReplyMessageId: EngineMessage.Id? + public var closedPinnedMessageId: EngineMessage.Id? public var closedPeerSpecificPackSetup: Bool = false public var dismissedAddContactPhoneNumber: String? @@ -122,7 +120,7 @@ public struct ChatInterfaceMessageActionsState: Codable, Equatable { self.dismissedAddContactPhoneNumber = nil } - public init(closedButtonKeyboardMessageId: MessageId?, dismissedButtonKeyboardMessageId: MessageId?, processedSetupReplyMessageId: MessageId?, closedPinnedMessageId: MessageId?, closedPeerSpecificPackSetup: Bool, dismissedAddContactPhoneNumber: String?) { + public init(closedButtonKeyboardMessageId: EngineMessage.Id?, dismissedButtonKeyboardMessageId: EngineMessage.Id?, processedSetupReplyMessageId: EngineMessage.Id?, closedPinnedMessageId: EngineMessage.Id?, closedPeerSpecificPackSetup: Bool, dismissedAddContactPhoneNumber: String?) { self.closedButtonKeyboardMessageId = closedButtonKeyboardMessageId self.dismissedButtonKeyboardMessageId = dismissedButtonKeyboardMessageId self.processedSetupReplyMessageId = processedSetupReplyMessageId @@ -135,25 +133,25 @@ public struct ChatInterfaceMessageActionsState: Codable, Equatable { let container = try decoder.container(keyedBy: StringCodingKey.self) if let closedMessageIdPeerId = try? container.decodeIfPresent(Int64.self, forKey: "cb.p"), let closedMessageIdNamespace = try? container.decodeIfPresent(Int32.self, forKey: "cb.n"), let closedMessageIdId = try? container.decodeIfPresent(Int32.self, forKey: "cb.i") { - self.closedButtonKeyboardMessageId = MessageId(peerId: PeerId(closedMessageIdPeerId), namespace: closedMessageIdNamespace, id: closedMessageIdId) + self.closedButtonKeyboardMessageId = EngineMessage.Id(peerId: EnginePeer.Id(closedMessageIdPeerId), namespace: closedMessageIdNamespace, id: closedMessageIdId) } else { self.closedButtonKeyboardMessageId = nil } if let messageIdPeerId = try? container.decodeIfPresent(Int64.self, forKey: "dismissedbuttons.p"), let messageIdNamespace = try? container.decodeIfPresent(Int32.self, forKey: "dismissedbuttons.n"), let messageIdId = try? container.decodeIfPresent(Int32.self, forKey: "dismissedbuttons.i") { - self.dismissedButtonKeyboardMessageId = MessageId(peerId: PeerId(messageIdPeerId), namespace: messageIdNamespace, id: messageIdId) + self.dismissedButtonKeyboardMessageId = EngineMessage.Id(peerId: EnginePeer.Id(messageIdPeerId), namespace: messageIdNamespace, id: messageIdId) } else { self.dismissedButtonKeyboardMessageId = nil } if let processedMessageIdPeerId = try? container.decodeIfPresent(Int64.self, forKey: "pb.p"), let processedMessageIdNamespace = try? container.decodeIfPresent(Int32.self, forKey: "pb.n"), let processedMessageIdId = try? container.decodeIfPresent(Int32.self, forKey: "pb.i") { - self.processedSetupReplyMessageId = MessageId(peerId: PeerId(processedMessageIdPeerId), namespace: processedMessageIdNamespace, id: processedMessageIdId) + self.processedSetupReplyMessageId = EngineMessage.Id(peerId: EnginePeer.Id(processedMessageIdPeerId), namespace: processedMessageIdNamespace, id: processedMessageIdId) } else { self.processedSetupReplyMessageId = nil } if let closedPinnedMessageIdPeerId = try? container.decodeIfPresent(Int64.self, forKey: "cp.p"), let closedPinnedMessageIdNamespace = try? container.decodeIfPresent(Int32.self, forKey: "cp.n"), let closedPinnedMessageIdId = try? container.decodeIfPresent(Int32.self, forKey: "cp.i") { - self.closedPinnedMessageId = MessageId(peerId: PeerId(closedPinnedMessageIdPeerId), namespace: closedPinnedMessageIdNamespace, id: closedPinnedMessageIdId) + self.closedPinnedMessageId = EngineMessage.Id(peerId: EnginePeer.Id(closedPinnedMessageIdPeerId), namespace: closedPinnedMessageIdNamespace, id: closedPinnedMessageIdId) } else { self.closedPinnedMessageId = nil } @@ -217,10 +215,10 @@ public struct ChatInterfaceMessageActionsState: Codable, Equatable { } public struct ChatInterfaceHistoryScrollState: Codable, Equatable { - public let messageIndex: MessageIndex + public let messageIndex: EngineMessage.Index public let relativeOffset: Double - public init(messageIndex: MessageIndex, relativeOffset: Double) { + public init(messageIndex: EngineMessage.Index, relativeOffset: Double) { self.messageIndex = messageIndex self.relativeOffset = relativeOffset } @@ -228,9 +226,9 @@ public struct ChatInterfaceHistoryScrollState: Codable, Equatable { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: StringCodingKey.self) - self.messageIndex = MessageIndex( - id: MessageId( - peerId: PeerId((try? container.decode(Int64.self, forKey: "m.p")) ?? 0), + self.messageIndex = EngineMessage.Index( + id: EngineMessage.Id( + peerId: EnginePeer.Id((try? container.decode(Int64.self, forKey: "m.p")) ?? 0), namespace: (try? container.decode(Int32.self, forKey: "m.n")) ?? 0, id: (try? container.decode(Int32.self, forKey: "m.i")) ?? 0 ), @@ -264,8 +262,8 @@ public final class ChatInterfaceState: Codable, Equatable { public let timestamp: Int32 public let composeInputState: ChatTextInputState public let composeDisableUrlPreview: String? - public let replyMessageId: MessageId? - public let forwardMessageIds: [MessageId]? + public let replyMessageId: EngineMessage.Id? + public let forwardMessageIds: [EngineMessage.Id]? public let editMessage: ChatEditMessageState? public let selectionState: ChatInterfaceSelectionState? public let messageActionsState: ChatInterfaceMessageActionsState @@ -290,7 +288,7 @@ public final class ChatInterfaceState: Codable, Equatable { return result } - public var historyScrollMessageIndex: MessageIndex? { + public var historyScrollMessageIndex: EngineMessage.Index? { return self.historyScrollState?.messageIndex } @@ -317,7 +315,7 @@ public final class ChatInterfaceState: Codable, Equatable { self.inputLanguage = nil } - public init(timestamp: Int32, composeInputState: ChatTextInputState, composeDisableUrlPreview: String?, replyMessageId: MessageId?, forwardMessageIds: [MessageId]?, editMessage: ChatEditMessageState?, selectionState: ChatInterfaceSelectionState?, messageActionsState: ChatInterfaceMessageActionsState, historyScrollState: ChatInterfaceHistoryScrollState?, mediaRecordingMode: ChatTextInputMediaRecordingButtonMode, silentPosting: Bool, inputLanguage: String?) { + public init(timestamp: Int32, composeInputState: ChatTextInputState, composeDisableUrlPreview: String?, replyMessageId: EngineMessage.Id?, forwardMessageIds: [EngineMessage.Id]?, editMessage: ChatEditMessageState?, selectionState: ChatInterfaceSelectionState?, messageActionsState: ChatInterfaceMessageActionsState, historyScrollState: ChatInterfaceHistoryScrollState?, mediaRecordingMode: ChatTextInputMediaRecordingButtonMode, silentPosting: Bool, inputLanguage: String?) { self.timestamp = timestamp self.composeInputState = composeInputState self.composeDisableUrlPreview = composeDisableUrlPreview @@ -350,12 +348,12 @@ public final class ChatInterfaceState: Codable, Equatable { let replyMessageIdNamespace: Int32? = try? container.decodeIfPresent(Int32.self, forKey: "r.n") let replyMessageIdId: Int32? = try? container.decodeIfPresent(Int32.self, forKey: "r.i") if let replyMessageIdPeerId = replyMessageIdPeerId, let replyMessageIdNamespace = replyMessageIdNamespace, let replyMessageIdId = replyMessageIdId { - self.replyMessageId = MessageId(peerId: PeerId(replyMessageIdPeerId), namespace: replyMessageIdNamespace, id: replyMessageIdId) + self.replyMessageId = EngineMessage.Id(peerId: EnginePeer.Id(replyMessageIdPeerId), namespace: replyMessageIdNamespace, id: replyMessageIdId) } else { self.replyMessageId = nil } if let forwardMessageIdsData = try? container.decodeIfPresent(Data.self, forKey: "fm") { - self.forwardMessageIds = MessageId.decodeArrayFromBuffer(ReadBuffer(data: forwardMessageIdsData)) + self.forwardMessageIds = EngineMessage.Id.decodeArrayFromData(forwardMessageIdsData) } else { self.forwardMessageIds = nil } @@ -404,9 +402,7 @@ public final class ChatInterfaceState: Codable, Equatable { try container.encodeNil(forKey: "r.i") } if let forwardMessageIds = self.forwardMessageIds { - let buffer = WriteBuffer() - MessageId.encodeArrayToBuffer(forwardMessageIds, buffer: buffer) - try container.encode(buffer.makeData(), forKey: "fm") + try container.encode(EngineMessage.Id.encodeArrayToData(forwardMessageIds), forKey: "fm") } else { try container.encodeNil(forKey: "fm") } @@ -490,16 +486,16 @@ public final class ChatInterfaceState: Codable, Equatable { return ChatInterfaceState(timestamp: self.timestamp, composeInputState: updatedComposeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: updatedEditMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage) } - public func withUpdatedReplyMessageId(_ replyMessageId: MessageId?) -> ChatInterfaceState { + public func withUpdatedReplyMessageId(_ replyMessageId: EngineMessage.Id?) -> ChatInterfaceState { return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage) } - public func withUpdatedForwardMessageIds(_ forwardMessageIds: [MessageId]?) -> ChatInterfaceState { + public func withUpdatedForwardMessageIds(_ forwardMessageIds: [EngineMessage.Id]?) -> ChatInterfaceState { return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage) } - public func withUpdatedSelectedMessages(_ messageIds: [MessageId]) -> ChatInterfaceState { - var selectedIds = Set() + public func withUpdatedSelectedMessages(_ messageIds: [EngineMessage.Id]) -> ChatInterfaceState { + var selectedIds = Set() if let selectionState = self.selectionState { selectedIds.formUnion(selectionState.selectedIds) } @@ -509,8 +505,8 @@ public final class ChatInterfaceState: Codable, Equatable { return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: ChatInterfaceSelectionState(selectedIds: selectedIds), messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage) } - public func withToggledSelectedMessages(_ messageIds: [MessageId], value: Bool) -> ChatInterfaceState { - var selectedIds = Set() + public func withToggledSelectedMessages(_ messageIds: [EngineMessage.Id], value: Bool) -> ChatInterfaceState { + var selectedIds = Set() if let selectionState = self.selectionState { selectedIds.formUnion(selectionState.selectedIds) } @@ -560,20 +556,20 @@ public final class ChatInterfaceState: Codable, Equatable { guard let opaqueData = state.opaqueData else { return ChatInterfaceState().withUpdatedSynchronizeableInputState(state.synchronizeableInputState) } - guard var decodedState = try? AdaptedPostboxDecoder().decode(ChatInterfaceState.self, from: opaqueData) else { + guard var decodedState = try? EngineDecoder.decode(ChatInterfaceState.self, from: opaqueData) else { return ChatInterfaceState().withUpdatedSynchronizeableInputState(state.synchronizeableInputState) } decodedState = decodedState.withUpdatedSynchronizeableInputState(state.synchronizeableInputState) return decodedState } - public static func update(engine: TelegramEngine, peerId: PeerId, threadId: Int64?, _ f: @escaping (ChatInterfaceState) -> ChatInterfaceState) -> Signal { + public static func update(engine: TelegramEngine, peerId: EnginePeer.Id, threadId: Int64?, _ f: @escaping (ChatInterfaceState) -> ChatInterfaceState) -> Signal { return engine.peers.getOpaqueChatInterfaceState(peerId: peerId, threadId: threadId) |> mapToSignal { previousOpaqueState -> Signal in let previousState = previousOpaqueState.flatMap(ChatInterfaceState.parse) let updatedState = f(previousState ?? ChatInterfaceState()) - let updatedOpaqueData = try? AdaptedPostboxEncoder().encode(updatedState) + let updatedOpaqueData = try? EngineEncoder.encode(updatedState) return engine.peers.setOpaqueChatInterfaceState( peerId: peerId, diff --git a/submodules/ChatListFilterSettingsHeaderItem/BUILD b/submodules/ChatListFilterSettingsHeaderItem/BUILD index d3d38bff2d..9fc2439438 100644 --- a/submodules/ChatListFilterSettingsHeaderItem/BUILD +++ b/submodules/ChatListFilterSettingsHeaderItem/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ChatListSearchItemHeader/BUILD b/submodules/ChatListSearchItemHeader/BUILD index edfacc2082..8154e629b4 100644 --- a/submodules/ChatListSearchItemHeader/BUILD +++ b/submodules/ChatListSearchItemHeader/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/Display:Display", "//submodules/TelegramPresentationData:TelegramPresentationData", diff --git a/submodules/ChatListSearchItemNode/BUILD b/submodules/ChatListSearchItemNode/BUILD index c57793411e..173234c78e 100644 --- a/submodules/ChatListSearchItemNode/BUILD +++ b/submodules/ChatListSearchItemNode/BUILD @@ -6,11 +6,13 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", - "//submodules/Postbox:Postbox", "//submodules/TelegramPresentationData:TelegramPresentationData", "//submodules/SearchBarNode:SearchBarNode", ], diff --git a/submodules/ChatListSearchItemNode/Sources/ChatListSearchItem.swift b/submodules/ChatListSearchItemNode/Sources/ChatListSearchItem.swift index b3a6df7f8b..bb4472f5a6 100644 --- a/submodules/ChatListSearchItemNode/Sources/ChatListSearchItem.swift +++ b/submodules/ChatListSearchItemNode/Sources/ChatListSearchItem.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import AsyncDisplayKit -import Postbox import Display import SwiftSignalKit import TelegramPresentationData diff --git a/submodules/ChatListSearchRecentPeersNode/BUILD b/submodules/ChatListSearchRecentPeersNode/BUILD index 1010ab4162..6b9a159477 100644 --- a/submodules/ChatListSearchRecentPeersNode/BUILD +++ b/submodules/ChatListSearchRecentPeersNode/BUILD @@ -6,11 +6,13 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", - "//submodules/Postbox:Postbox", "//submodules/TelegramCore:TelegramCore", "//submodules/ListSectionHeaderNode:ListSectionHeaderNode", "//submodules/HorizontalPeerItem:HorizontalPeerItem", diff --git a/submodules/ChatListSearchRecentPeersNode/Sources/ChatListSearchRecentPeersNode.swift b/submodules/ChatListSearchRecentPeersNode/Sources/ChatListSearchRecentPeersNode.swift index b1bf7c83b6..e6e160558c 100644 --- a/submodules/ChatListSearchRecentPeersNode/Sources/ChatListSearchRecentPeersNode.swift +++ b/submodules/ChatListSearchRecentPeersNode/Sources/ChatListSearchRecentPeersNode.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import MergeLists @@ -32,13 +31,13 @@ private func calculateItemCustomWidth(width: CGFloat) -> CGFloat { private struct ChatListSearchRecentPeersEntry: Comparable, Identifiable { let index: Int - let peer: Peer - let presence: PeerPresence? + let peer: EnginePeer + let presence: EnginePeer.Presence? let unreadBadge: (Int32, Bool)? let theme: PresentationTheme let strings: PresentationStrings let itemCustomWidth: CGFloat? - var stableId: PeerId { + var stableId: EnginePeer.Id { return self.peer.id } @@ -49,14 +48,10 @@ private struct ChatListSearchRecentPeersEntry: Comparable, Identifiable { if lhs.itemCustomWidth != rhs.itemCustomWidth { return false } - if !lhs.peer.isEqual(rhs.peer) { + if lhs.peer != rhs.peer { return false } - if let lhsPresence = lhs.presence, let rhsPresence = rhs.presence { - if !lhsPresence.isEqual(to: rhsPresence) { - return false - } - } else if (lhs.presence != nil) != (rhs.presence != nil) { + if lhs.presence != rhs.presence { return false } if lhs.unreadBadge?.0 != rhs.unreadBadge?.0 { @@ -78,7 +73,7 @@ private struct ChatListSearchRecentPeersEntry: Comparable, Identifiable { return lhs.index < rhs.index } - func item(context: AccountContext, mode: HorizontalPeerItemMode, peerSelected: @escaping (Peer) -> Void, peerContextAction: @escaping (Peer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (PeerId) -> Bool) -> ListViewItem { + func item(context: AccountContext, mode: HorizontalPeerItemMode, peerSelected: @escaping (EnginePeer) -> Void, peerContextAction: @escaping (EnginePeer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (EnginePeer.Id) -> Bool) -> ListViewItem { return HorizontalPeerItem(theme: self.theme, strings: self.strings, mode: mode, context: context, peer: self.peer, presence: self.presence, unreadBadge: self.unreadBadge, action: peerSelected, contextAction: { peer, node, gesture in peerContextAction(peer, node, gesture) }, isPeerSelected: isPeerSelected, customWidth: self.itemCustomWidth) @@ -93,7 +88,7 @@ private struct ChatListSearchRecentNodeTransition { let animated: Bool } -private func preparedRecentPeersTransition(context: AccountContext, mode: HorizontalPeerItemMode, peerSelected: @escaping (Peer) -> Void, peerContextAction: @escaping (Peer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (PeerId) -> Bool, share: Bool = false, from fromEntries: [ChatListSearchRecentPeersEntry], to toEntries: [ChatListSearchRecentPeersEntry], firstTime: Bool, animated: Bool) -> ChatListSearchRecentNodeTransition { +private func preparedRecentPeersTransition(context: AccountContext, mode: HorizontalPeerItemMode, peerSelected: @escaping (EnginePeer) -> Void, peerContextAction: @escaping (EnginePeer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (EnginePeer.Id) -> Bool, share: Bool = false, from fromEntries: [ChatListSearchRecentPeersEntry], to toEntries: [ChatListSearchRecentPeersEntry], firstTime: Bool, animated: Bool) -> ChatListSearchRecentNodeTransition { let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromEntries, rightList: toEntries) let deletions = deleteIndices.map { ListViewDeleteItem(index: $0, directionHint: nil) } @@ -111,9 +106,9 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode { private let listView: ListView private let share: Bool - private let peerSelected: (Peer) -> Void - private let peerContextAction: (Peer, ASDisplayNode, ContextGesture?) -> Void - private let isPeerSelected: (PeerId) -> Bool + private let peerSelected: (EnginePeer) -> Void + private let peerContextAction: (EnginePeer, ASDisplayNode, ContextGesture?) -> Void + private let isPeerSelected: (EnginePeer.Id) -> Bool private let disposable = MetaDisposable() private let itemCustomWidthValuePromise: ValuePromise = ValuePromise(nil, ignoreRepeated: true) @@ -127,7 +122,7 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode { return self.ready.get() } - public init(context: AccountContext, theme: PresentationTheme, mode: HorizontalPeerItemMode, strings: PresentationStrings, peerSelected: @escaping (Peer) -> Void, peerContextAction: @escaping (Peer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (PeerId) -> Bool, share: Bool = false) { + public init(context: AccountContext, theme: PresentationTheme, mode: HorizontalPeerItemMode, strings: PresentationStrings, peerSelected: @escaping (EnginePeer) -> Void, peerContextAction: @escaping (EnginePeer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (EnginePeer.Id) -> Bool, share: Bool = false) { self.theme = theme self.strings = strings self.themeAndStringsPromise = Promise((self.theme, self.strings)) @@ -149,7 +144,7 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode { let peersDisposable = DisposableSet() - let recent: Signal<([Peer], [PeerId: (Int32, Bool)], [PeerId : PeerPresence]), NoError> = context.engine.peers.recentPeers() + let recent: Signal<([EnginePeer], [EnginePeer.Id: (Int32, Bool)], [EnginePeer.Id : EnginePeer.Presence]), NoError> = context.engine.peers.recentPeers() |> filter { value -> Bool in switch value { case .disabled: @@ -163,14 +158,21 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode { case .disabled: return .single(([], [:], [:])) case let .peers(peers): - return combineLatest(queue: .mainQueue(), peers.filter { !$0.isDeleted }.map {context.account.postbox.peerView(id: $0.id)}) |> mapToSignal { peerViews -> Signal<([Peer], [PeerId: (Int32, Bool)], [PeerId: PeerPresence]), NoError> in + return combineLatest(queue: .mainQueue(), + peers.filter { + !$0.isDeleted + }.map { + context.account.postbox.peerView(id: $0.id) + } + ) + |> mapToSignal { peerViews -> Signal<([EnginePeer], [EnginePeer.Id: (Int32, Bool)], [EnginePeer.Id: EnginePeer.Presence]), NoError> in return context.account.postbox.unreadMessageCountsView(items: peerViews.map { .peer($0.peerId) }) |> map { values in - var peers: [Peer] = [] - var unread: [PeerId: (Int32, Bool)] = [:] - var presences: [PeerId: PeerPresence] = [:] + var peers: [EnginePeer] = [] + var unread: [EnginePeer.Id: (Int32, Bool)] = [:] + var presences: [EnginePeer.Id: EnginePeer.Presence] = [:] for peerView in peerViews { if let peer = peerViewMainPeer(peerView) { var isMuted: Bool = false @@ -189,10 +191,10 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode { } if let presence = peerView.peerPresences[peer.id] { - presences[peer.id] = presence + presences[peer.id] = EnginePeer.Presence(presence) } - peers.append(peer) + peers.append(EnginePeer(peer)) } } return (peers, unread, presences) @@ -286,7 +288,7 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode { self.itemCustomWidthValuePromise.set(itemCustomWidth) } - public func viewAndPeerAtPoint(_ point: CGPoint) -> (UIView, PeerId)? { + public func viewAndPeerAtPoint(_ point: CGPoint) -> (UIView, EnginePeer.Id)? { let adjustedPoint = self.view.convert(point, to: self.listView.view) var selectedItemNode: ASDisplayNode? self.listView.forEachItemNode { itemNode in diff --git a/submodules/ChatListUI/BUILD b/submodules/ChatListUI/BUILD index f404887b30..5123ae2fd3 100644 --- a/submodules/ChatListUI/BUILD +++ b/submodules/ChatListUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ChatListUI/Sources/ChatContextMenus.swift b/submodules/ChatListUI/Sources/ChatContextMenus.swift index ee9f7cedcb..7fb0f8adc7 100644 --- a/submodules/ChatListUI/Sources/ChatContextMenus.swift +++ b/submodules/ChatListUI/Sources/ChatContextMenus.swift @@ -272,7 +272,7 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch } let archiveEnabled = !isSavedMessages && peerId != PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000)) && peerId == context.account.peerId - if let (group, index) = groupAndIndex { + if let (group, _) = groupAndIndex { if archiveEnabled { let isArchived = group == Namespaces.PeerGroup.archive items.append(.action(ContextMenuActionItem(text: isArchived ? strings.ChatList_Context_Unarchive : strings.ChatList_Context_Archive, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: isArchived ? "Chat/Context Menu/Unarchive" : "Chat/Context Menu/Archive"), color: theme.contextMenu.primaryColor) }, action: { _, f in @@ -361,14 +361,15 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch joinChannelDisposable.set((createSignal |> deliverOnMainQueue).start(next: { _ in - if let navigationController = (chatListController?.navigationController as? NavigationController) { - context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId))) - } }, error: { _ in if let chatListController = chatListController { let presentationData = context.sharedContext.currentPresentationData.with { $0 } chatListController.present(textAlertController(context: context, title: nil, text: presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), in: .window(.root)) } + }, completed: { + if let navigationController = (chatListController?.navigationController as? NavigationController) { + context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId))) + } })) f(.default) }))) diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 6e459e7a23..34f22c5b6b 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -836,10 +836,10 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController } switch item.content { - case let .groupReference(groupReference): - let chatListController = ChatListControllerImpl(context: strongSelf.context, groupId: groupReference.groupId, controlsHistoryPreload: false, hideNetworkActivityStatus: true, previewing: true, enableDebugActions: false) + case let .groupReference(groupId, _, _, _, _): + let chatListController = ChatListControllerImpl(context: strongSelf.context, groupId: groupId, controlsHistoryPreload: false, hideNetworkActivityStatus: true, previewing: true, enableDebugActions: false) chatListController.navigationPresentation = .master - let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: archiveContextMenuItems(context: strongSelf.context, groupId: groupReference.groupId, chatListController: strongSelf), reactionItems: [], gesture: gesture) + let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: archiveContextMenuItems(context: strongSelf.context, groupId: groupId, chatListController: strongSelf), reactionItems: [], gesture: gesture) strongSelf.presentInGlobalOverlay(contextController) case let .peer(_, peer, _, _, _, _, _, _, promoInfo, _, _, _): let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .peer(peer.peerId), subject: nil, botStart: nil, mode: .standard(previewing: true)) @@ -1481,8 +1481,8 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController switch entry { case .all: return nil - case let .filter(filter): - return filter.id + case let .filter(id, _, _): + return id } } @@ -1996,7 +1996,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController return false } if value == .commit { - let context = strongSelf.context let presentationData = strongSelf.presentationData let progressSignal = Signal { subscriber in let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil)) diff --git a/submodules/ChatListUI/Sources/ChatListControllerNode.swift b/submodules/ChatListUI/Sources/ChatListControllerNode.swift index db5afda01a..abb2350bed 100644 --- a/submodules/ChatListUI/Sources/ChatListControllerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListControllerNode.swift @@ -1165,10 +1165,7 @@ final class ChatListControllerNode: ASDisplayNode { return nil } - var filter: ChatListNodePeersFilter = [] - if false, case .group = self.groupId { - filter.insert(.excludeRecent) - } + let filter: ChatListNodePeersFilter = [] let contentNode = ChatListSearchContainerNode(context: self.context, filter: filter, groupId: self.groupId, displaySearchFilters: displaySearchFilters, initialFilter: initialFilter, openPeer: { [weak self] peer, _, dismissSearch in self?.requestOpenPeerFromSearch?(peer, dismissSearch) diff --git a/submodules/ChatListUI/Sources/ChatListFilterPresetCategoryItem.swift b/submodules/ChatListUI/Sources/ChatListFilterPresetCategoryItem.swift index 95eafaf35f..3115272611 100644 --- a/submodules/ChatListUI/Sources/ChatListFilterPresetCategoryItem.swift +++ b/submodules/ChatListUI/Sources/ChatListFilterPresetCategoryItem.swift @@ -157,7 +157,6 @@ class ChatListFilterPresetCategoryItemNode: ItemListRevealOptionsItemNode, ItemL func asyncLayout() -> (_ item: ChatListFilterPresetCategoryItem, _ params: ListViewItemLayoutParams, _ neighbors: ItemListNeighbors, _ headerAtTop: Bool) -> (ListViewItemNodeLayout, (Bool, Bool) -> Void) { let makeTitleLayout = TextNode.asyncLayout(self.titleNode) - let editableControlLayout = ItemListEditableControlNode.asyncLayout(self.editableControlNode) let currentItem = self.item @@ -193,16 +192,10 @@ class ChatListFilterPresetCategoryItemNode: ItemListRevealOptionsItemNode, ItemL avatarSize = 40.0 leftInset = 65.0 + params.leftInset - var editableControlSizeAndApply: (CGFloat, (CGFloat) -> ItemListEditableControlNode)? + let editableControlSizeAndApply: (CGFloat, (CGFloat) -> ItemListEditableControlNode)? = nil let editingOffset: CGFloat - if false { - let sizeAndApply = editableControlLayout(item.presentationData.theme, false) - editableControlSizeAndApply = sizeAndApply - editingOffset = sizeAndApply.0 - } else { - editingOffset = 0.0 - } + editingOffset = 0.0 let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - 12.0 - editingOffset - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) diff --git a/submodules/ChatListUI/Sources/ChatListFilterPresetController.swift b/submodules/ChatListUI/Sources/ChatListFilterPresetController.swift index 64ca31b31f..a4d2703731 100644 --- a/submodules/ChatListUI/Sources/ChatListFilterPresetController.swift +++ b/submodules/ChatListUI/Sources/ChatListFilterPresetController.swift @@ -260,8 +260,8 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry { return .index(3) case .addIncludePeer: return .index(4) - case let .includeCategory(includeCategory): - return .includeCategory(includeCategory.category) + case let .includeCategory(_, category, _, _): + return .includeCategory(category) case .includeExpand: return .index(5) case .includePeerInfo: @@ -270,16 +270,16 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry { return .index(7) case .addExcludePeer: return .index(8) - case let .excludeCategory(excludeCategory): - return .excludeCategory(excludeCategory.category) + case let .excludeCategory(_, category, _, _): + return .excludeCategory(category) case .excludeExpand: return .index(9) case .excludePeerInfo: return .index(10) - case let .includePeer(peer): - return .peer(peer.peer.peerId) - case let .excludePeer(peer): - return .peer(peer.peer.peerId) + case let .includePeer(_, peer, _): + return .peer(peer.peerId) + case let .excludePeer(_, peer, _): + return .peer(peer.peerId) } } @@ -295,10 +295,10 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry { return .includeIndex(0) case .addIncludePeer: return .includeIndex(1) - case let .includeCategory(includeCategory): - return .includeIndex(2 + includeCategory.index) - case let .includePeer(includePeer): - return .includeIndex(200 + includePeer.index) + case let .includeCategory(index, _, _, _): + return .includeIndex(2 + index) + case let .includePeer(index, _, _): + return .includeIndex(200 + index) case .includeExpand: return .includeIndex(999) case .includePeerInfo: @@ -307,10 +307,10 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry { return .excludeIndex(0) case .addExcludePeer: return .excludeIndex(1) - case let .excludeCategory(excludeCategory): - return .excludeIndex(2 + excludeCategory.index) - case let .excludePeer(excludePeer): - return .excludeIndex(200 + excludePeer.index) + case let .excludeCategory(index, _, _, _): + return .excludeIndex(2 + index) + case let .excludePeer(index, _, _): + return .excludeIndex(200 + index) case .excludeExpand: return .excludeIndex(999) case .excludePeerInfo: diff --git a/submodules/ChatListUI/Sources/ChatListFilterPresetListController.swift b/submodules/ChatListUI/Sources/ChatListFilterPresetListController.swift index 1a170067c4..e9a86e85ff 100644 --- a/submodules/ChatListUI/Sources/ChatListFilterPresetListController.swift +++ b/submodules/ChatListUI/Sources/ChatListFilterPresetListController.swift @@ -94,16 +94,16 @@ private enum ChatListFilterPresetListEntry: ItemListNodeEntry { return 0 case .listHeader: return 100 - case let .preset(preset): - return 101 + preset.index.value + case let .preset(index, _, _, _, _, _, _): + return 101 + index.value case .addItem: return 1000 case .listFooter: return 1001 case .suggestedListHeader: return 1002 - case let .suggestedPreset(suggestedPreset): - return 1003 + suggestedPreset.index.value + case let .suggestedPreset(index, _, _, _): + return 1003 + index.value case .suggestedAddCustom: return 2000 } @@ -115,14 +115,14 @@ private enum ChatListFilterPresetListEntry: ItemListNodeEntry { return .screenHeader case .suggestedListHeader: return .suggestedListHeader - case let .suggestedPreset(suggestedPreset): - return .suggestedPreset(suggestedPreset.preset) + case let .suggestedPreset(_, _, _, preset): + return .suggestedPreset(preset) case .suggestedAddCustom: return .suggestedAddCustom case .listHeader: return .listHeader - case let .preset(preset): - return .preset(preset.preset.id) + case let .preset(_, _, _, preset, _, _, _): + return .preset(preset.id) case .addItem: return .addItem case .listFooter: @@ -297,8 +297,6 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch presentControllerImpl?(actionSheet) }) - let chatCountCache = Atomic<[ChatListFilterData: Int]>(value: [:]) - let filtersWithCountsSignal = context.engine.peers.updatedChatListFilters() |> distinctUntilChanged |> mapToSignal { filters -> Signal<[(ChatListFilter, Int)], NoError> in @@ -430,7 +428,7 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch } controller.setReorderEntry({ (fromIndex: Int, toIndex: Int, entries: [ChatListFilterPresetListEntry]) -> Signal in let fromEntry = entries[fromIndex] - guard case let .preset(fromFilter) = fromEntry else { + guard case let .preset(_, _, _, fromPreset, _, _, _) = fromEntry else { return .single(false) } var referenceFilter: ChatListFilter? @@ -438,8 +436,8 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch var afterAll = false if toIndex < entries.count { switch entries[toIndex] { - case let .preset(toFilter): - referenceFilter = toFilter.preset + case let .preset(_, _, _, preset, _, _, _): + referenceFilter = preset default: if entries[toIndex] < fromEntry { beforeAll = true @@ -459,7 +457,7 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch var filters = filtersWithAppliedOrder(filters: filtersWithCountsValue, order: updatedFilterOrderValue).map { $0.0 } let initialOrder = filters.map { $0.id } - if let index = filters.firstIndex(where: { $0.id == fromFilter.preset.id }) { + if let index = filters.firstIndex(where: { $0.id == fromPreset.id }) { filters.remove(at: index) } if let referenceFilter = referenceFilter { @@ -467,21 +465,21 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch for i in 0 ..< filters.count { if filters[i].id == referenceFilter.id { if fromIndex < toIndex { - filters.insert(fromFilter.preset, at: i + 1) + filters.insert(fromPreset, at: i + 1) } else { - filters.insert(fromFilter.preset, at: i) + filters.insert(fromPreset, at: i) } inserted = true break } } if !inserted { - filters.append(fromFilter.preset) + filters.append(fromPreset) } } else if beforeAll { - filters.insert(fromFilter.preset, at: 0) + filters.insert(fromPreset, at: 0) } else if afterAll { - filters.append(fromFilter.preset) + filters.append(fromPreset) } let updatedOrder = filters.map { $0.id } diff --git a/submodules/ChatListUI/Sources/ChatListFilterTabInlineContainerNode.swift b/submodules/ChatListUI/Sources/ChatListFilterTabInlineContainerNode.swift index 954642fba7..e6674f6282 100644 --- a/submodules/ChatListUI/Sources/ChatListFilterTabInlineContainerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListFilterTabInlineContainerNode.swift @@ -146,7 +146,7 @@ private final class ItemNode: ASDisplayNode { return } - if isExtracted, let theme = strongSelf.theme { + if isExtracted { strongSelf.extractedBackgroundNode.image = generateStretchableFilledCircleImage(diameter: 32.0, color: strongSelf.isSelected ? UIColor(rgb: 0xbbbbbb) : UIColor(rgb: 0xf1f1f1)) } transition.updateAlpha(node: strongSelf.extractedBackgroundNode, alpha: isExtracted ? 1.0 : 0.0, completion: { _ in @@ -652,8 +652,8 @@ final class ChatListFilterTabInlineContainerNode: ASDisplayNode { strongSelf.scrollNode.view.panGestureRecognizer.isEnabled = true strongSelf.scrollNode.view.setContentOffset(strongSelf.scrollNode.view.contentOffset, animated: false) switch filter { - case let .filter(filter): - strongSelf.contextGesture?(filter.id, sourceNode, gesture) + case let .filter(id, _, _): + strongSelf.contextGesture?(id, sourceNode, gesture) default: strongSelf.contextGesture?(nil, sourceNode, gesture) } @@ -666,11 +666,11 @@ final class ChatListFilterTabInlineContainerNode: ASDisplayNode { return } switch filter { - case let .filter(filter): + case let .filter(id, _, _): strongSelf.scrollNode.view.panGestureRecognizer.isEnabled = false strongSelf.scrollNode.view.panGestureRecognizer.isEnabled = true strongSelf.scrollNode.view.setContentOffset(strongSelf.scrollNode.view.contentOffset, animated: false) - strongSelf.contextGesture?(filter.id, sourceNode, gesture) + strongSelf.contextGesture?(id, sourceNode, gesture) default: strongSelf.contextGesture?(nil, sourceNode, gesture) } @@ -685,9 +685,9 @@ final class ChatListFilterTabInlineContainerNode: ASDisplayNode { unreadCount = count unreadHasUnmuted = true isNoFilter = true - case let .filter(filter): - unreadCount = filter.unread.value - unreadHasUnmuted = filter.unread.hasUnmuted + case let .filter(_, _, unread): + unreadCount = unread.value + unreadHasUnmuted = unread.hasUnmuted } if !wasAdded && (itemNodePair.regular.unreadCount != 0) != (unreadCount != 0) { badgeAnimations[filter.id] = (unreadCount != 0) ? .in : .out @@ -830,9 +830,7 @@ final class ChatListFilterTabInlineContainerNode: ASDisplayNode { transition.updateFrame(node: self.itemsBackgroundTintNode, frame: backgroundFrame) self.scrollNode.view.contentSize = CGSize(width: itemsBackgroundRightX + 8.0, height: size.height) - - var previousFrame: CGRect? - var nextFrame: CGRect? + var selectedFrame: CGRect? if let selectedFilter = selectedFilter, let currentIndex = reorderedFilters.firstIndex(where: { $0.id == selectedFilter }) { func interpolateFrame(from fromValue: CGRect, to toValue: CGRect, t: CGFloat) -> CGRect { diff --git a/submodules/ChatListUI/Sources/ChatListRecentPeersListItem.swift b/submodules/ChatListUI/Sources/ChatListRecentPeersListItem.swift index f119038ac7..dc71fbd908 100644 --- a/submodules/ChatListUI/Sources/ChatListRecentPeersListItem.swift +++ b/submodules/ChatListUI/Sources/ChatListRecentPeersListItem.swift @@ -122,9 +122,9 @@ class ChatListRecentPeersListItemNode: ListViewItemNode { peersNode.updateThemeAndStrings(theme: item.theme, strings: item.strings) } else { peersNode = ChatListSearchRecentPeersNode(context: item.context, theme: item.theme, mode: .list, strings: item.strings, peerSelected: { peer in - self?.item?.peerSelected(peer) + self?.item?.peerSelected(peer._asPeer()) }, peerContextAction: { peer, node, gesture in - self?.item?.peerContextAction(peer, node, gesture) + self?.item?.peerContextAction(peer._asPeer(), node, gesture) }, isPeerSelected: { _ in return false }) diff --git a/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift b/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift index 53d302d921..5224869b22 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift @@ -827,14 +827,11 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo if let strongSelf = self, !actions.options.isEmpty { let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] - var personalPeerName: String? - var isChannel = false + let personalPeerName: String? = nil if actions.options.contains(.deleteGlobally) { let globalTitle: String - if isChannel { - globalTitle = strongSelf.presentationData.strings.Conversation_DeleteMessagesForMe - } else if let personalPeerName = personalPeerName { + if let personalPeerName = personalPeerName { globalTitle = strongSelf.presentationData.strings.Conversation_DeleteMessagesFor(personalPeerName).string } else { globalTitle = strongSelf.presentationData.strings.Conversation_DeleteMessagesForEveryone @@ -854,14 +851,7 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo })) } if actions.options.contains(.deleteLocally) { - var localOptionText = strongSelf.presentationData.strings.Conversation_DeleteMessagesForMe -// if strongSelf.context.account.peerId == strongSelf.peerId { -// if messageIds.count == 1 { -// localOptionText = strongSelf.presentationData.strings.Conversation_Moderate_Delete -// } else { -// localOptionText = strongSelf.presentationData.strings.Conversation_DeleteManyMessages -// } -// } + let localOptionText = strongSelf.presentationData.strings.Conversation_DeleteMessagesForMe items.append(ActionSheetButtonItem(title: localOptionText, color: .destructive, action: { [weak actionSheet] in actionSheet?.dismissAnimated() if let strongSelf = self { diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index ba2e1330de..c32eb1d010 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -676,12 +676,12 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { if peerValue.peerId.namespace == Namespaces.Peer.SecretChat { enablePreview = false } - case let .groupReference(groupReference): - if let previousItem = previousItem, case let .groupReference(previousGroupReference) = previousItem.content, groupReference.hiddenByDefault != previousGroupReference.hiddenByDefault { + case let .groupReference(_, _, _, _, hiddenByDefault): + if let previousItem = previousItem, case let .groupReference(_, _, _, _, previousHiddenByDefault) = previousItem.content, hiddenByDefault != previousHiddenByDefault { UIView.transition(with: self.avatarNode.view, duration: 0.3, options: [.transitionCrossDissolve], animations: { }, completion: nil) } - self.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer.flatMap(EnginePeer.init), overrideImage: .archivedChatsIcon(hiddenByDefault: groupReference.hiddenByDefault), emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads) + self.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer.flatMap(EnginePeer.init), overrideImage: .archivedChatsIcon(hiddenByDefault: hiddenByDefault), emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads) } if let peer = peer { @@ -825,7 +825,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { var groupHiddenByDefault = false switch item.content { - case let .peer(messagesValue, peerValue, combinedReadStateValue, isRemovedFromTotalUnreadCountValue, peerPresenceValue, summaryInfoValue, embeddedStateValue, inputActivitiesValue, promoInfoValue, ignoreUnreadBadge, displayAsMessageValue, hasFailedMessagesValue): + case let .peer(messagesValue, peerValue, combinedReadStateValue, isRemovedFromTotalUnreadCountValue, peerPresenceValue, summaryInfoValue, embeddedStateValue, inputActivitiesValue, promoInfoValue, ignoreUnreadBadge, displayAsMessageValue, _): messages = messagesValue contentPeer = .chat(peerValue) combinedReadState = combinedReadStateValue @@ -1280,7 +1280,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { } } - var isMuted = isRemovedFromTotalUnreadCount + let isMuted = isRemovedFromTotalUnreadCount if isMuted { currentMutedIconImage = PresentationResourcesChatList.mutedIcon(item.presentationData.theme) } @@ -1351,7 +1351,6 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { let layoutOffset: CGFloat = 0.0 - let rawContentOriginX = 2.0 let rawContentWidth = params.width - leftInset - params.rightInset - 10.0 - editingOffset let (dateLayout, dateApply) = dateLayout(TextNodeLayoutArguments(attributedString: dateAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: rawContentWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) @@ -1417,7 +1416,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { if !displayAsMessage { if let peer = renderedPeer.chatMainPeer as? TelegramUser, let presence = presence as? TelegramUserPresence, !isServicePeer(peer) && !peer.flags.contains(.isSupport) && peer.id != item.context.account.peerId { let updatedPresence = TelegramUserPresence(status: presence.status, lastActivity: 0) - let relativeStatus = relativeUserPresenceStatus(updatedPresence, relativeTo: timestamp) + let relativeStatus = relativeUserPresenceStatus(EnginePeer.Presence(updatedPresence), relativeTo: timestamp) if case .online = relativeStatus { online = true } @@ -1825,7 +1824,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { } let separatorInset: CGFloat - if case let .groupReference(groupReference) = item.content, groupReference.hiddenByDefault { + if case let .groupReference(_, _, _, _, hiddenByDefault) = item.content, hiddenByDefault { separatorInset = 0.0 } else if (!nextIsPinned && item.index.pinningIndex != nil) || last { separatorInset = 0.0 @@ -1840,7 +1839,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { if item.selected { backgroundColor = theme.itemSelectedBackgroundColor } else if item.index.pinningIndex != nil { - if case let .groupReference(groupReference) = item.content, groupReference.hiddenByDefault { + if case let .groupReference(_, _, _, _, hiddenByDefault) = item.content, hiddenByDefault { backgroundColor = theme.itemBackgroundColor } else { backgroundColor = theme.pinnedItemBackgroundColor diff --git a/submodules/ChatListUI/Sources/Node/ChatListNode.swift b/submodules/ChatListUI/Sources/Node/ChatListNode.swift index 0435d3078f..e9c213c773 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNode.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNode.swift @@ -964,8 +964,8 @@ public final class ChatListNode: ListView { if index.messageIndex.id.peerId == removingPeerId { didIncludeRemovingPeerId = true } - } else if case let .GroupReferenceEntry(entry) = entry { - didIncludeHiddenByDefaultArchive = entry.hiddenByDefault + } else if case let .GroupReferenceEntry(_, _, _, _, _, _, _, _, hiddenByDefault) = entry { + didIncludeHiddenByDefaultArchive = hiddenByDefault } } } @@ -973,16 +973,16 @@ public final class ChatListNode: ListView { var doesIncludeArchive = false var doesIncludeHiddenByDefaultArchive = false for entry in processedView.filteredEntries { - if case let .PeerEntry(peerEntry) = entry { - if peerEntry.index.pinningIndex != nil { - updatedPinnedChats.append(peerEntry.index.messageIndex.id.peerId) + if case let .PeerEntry(index, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) = entry { + if index.pinningIndex != nil { + updatedPinnedChats.append(index.messageIndex.id.peerId) } - if peerEntry.index.messageIndex.id.peerId == removingPeerId { + if index.messageIndex.id.peerId == removingPeerId { doesIncludeRemovingPeerId = true } - } else if case let .GroupReferenceEntry(entry) = entry { + } else if case let .GroupReferenceEntry(_, _, _, _, _, _, _, _, hiddenByDefault) = entry { doesIncludeArchive = true - doesIncludeHiddenByDefaultArchive = entry.hiddenByDefault + doesIncludeHiddenByDefaultArchive = hiddenByDefault } } if previousPinnedChats != updatedPinnedChats { @@ -1343,8 +1343,8 @@ public final class ChatListNode: ListView { var isHiddenArchiveVisible = false strongSelf.forEachItemNode({ itemNode in if let itemNode = itemNode as? ChatListItemNode, let item = itemNode.item { - if case let .groupReference(groupReference) = item.content { - if groupReference.hiddenByDefault { + if case let .groupReference(_, _, _, _, hiddenByDefault) = item.content { + if hiddenByDefault { isHiddenArchiveVisible = true } } @@ -1599,8 +1599,8 @@ public final class ChatListNode: ListView { for item in transition.insertItems { if let item = item.item as? ChatListItem { switch item.content { - case let .peer(peer): - insertedPeerIds.append(peer.peer.peerId) + case let .peer(_, peer, _, _, _, _, _, _, _, _, _, _): + insertedPeerIds.append(peer.peerId) case .groupReference: break } diff --git a/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift b/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift index 99e05d168d..4882cb291f 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift @@ -64,8 +64,8 @@ enum ChatListNodeEntry: Comparable, Identifiable { return .index(index) case .ArchiveIntro: return .index(ChatListIndex.absoluteUpperBound.successor) - case let .AdditionalCategory(additionalCategory): - return .additionalCategory(additionalCategory.index) + case let .AdditionalCategory(index, _, _, _, _, _, _): + return .additionalCategory(index) } } @@ -81,8 +81,8 @@ enum ChatListNodeEntry: Comparable, Identifiable { return .GroupId(groupId) case .ArchiveIntro: return .ArchiveIntro - case let .AdditionalCategory(additionalCategory): - return .additionalCategory(additionalCategory.id) + case let .AdditionalCategory(_, id, _, _, _, _, _): + return .additionalCategory(id) } } diff --git a/submodules/ChatListUI/Sources/Node/ChatListNodeLocation.swift b/submodules/ChatListUI/Sources/Node/ChatListNodeLocation.swift index 70909efa41..122970ea2e 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNodeLocation.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNodeLocation.swift @@ -12,12 +12,12 @@ enum ChatListNodeLocation: Equatable { var filter: ChatListFilter? { switch self { - case let .initial(initial): - return initial.filter - case let .navigation(navigation): - return navigation.filter - case let .scroll(scroll): - return scroll.filter + case let .initial(_, filter): + return filter + case let .navigation(_, filter): + return filter + case let .scroll(_, _, _, _, filter): + return filter } } } diff --git a/submodules/ChatMessageInteractiveMediaBadge/BUILD b/submodules/ChatMessageInteractiveMediaBadge/BUILD index bb8f11a6d3..4fe306285a 100644 --- a/submodules/ChatMessageInteractiveMediaBadge/BUILD +++ b/submodules/ChatMessageInteractiveMediaBadge/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/ChatTitleActivityNode/BUILD b/submodules/ChatTitleActivityNode/BUILD index c6d3c8966e..e258d48149 100644 --- a/submodules/ChatTitleActivityNode/BUILD +++ b/submodules/ChatTitleActivityNode/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/CheckNode/BUILD b/submodules/CheckNode/BUILD index d64f036003..5fd684a8d2 100644 --- a/submodules/CheckNode/BUILD +++ b/submodules/CheckNode/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/CloudData/BUILD b/submodules/CloudData/BUILD index 662ebc2ee3..83da0d43aa 100644 --- a/submodules/CloudData/BUILD +++ b/submodules/CloudData/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/Postbox:Postbox", diff --git a/submodules/CloudData/Sources/CloudData.swift b/submodules/CloudData/Sources/CloudData.swift index 04f1df80be..12bb67f42b 100644 --- a/submodules/CloudData/Sources/CloudData.swift +++ b/submodules/CloudData/Sources/CloudData.swift @@ -14,15 +14,15 @@ private func fetchRawData(prefix: String) -> Signal { return Signal { subscriber in #if targetEnvironment(simulator) return EmptyDisposable - #endif - + #else let container = CKContainer.default() let publicDatabase = container.database(with: .public) let recordId = CKRecord.ID(recordName: "emergency-datacenter-\(prefix)") publicDatabase.fetch(withRecordID: recordId, completionHandler: { record, error in if let error = error { print("publicDatabase.fetch error: \(error)") - if let error = error as? NSError, error.domain == CKError.errorDomain, error.code == 1 { + let nsError = error as NSError + if nsError.domain == CKError.errorDomain, nsError.code == 1 { subscriber.putError(.networkUnavailable) } else { subscriber.putError(.generic) @@ -46,8 +46,8 @@ private func fetchRawData(prefix: String) -> Signal { }) return ActionDisposable { - } + #endif } } diff --git a/submodules/ComponentFlow/BUILD b/submodules/ComponentFlow/BUILD index d69165e200..6c7d864ad5 100644 --- a/submodules/ComponentFlow/BUILD +++ b/submodules/ComponentFlow/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Source/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ ], visibility = [ diff --git a/submodules/ComponentFlow/Source/Host/RootHostView.swift b/submodules/ComponentFlow/Source/Host/RootHostView.swift index 37d916ddf2..5a5d9fec91 100644 --- a/submodules/ComponentFlow/Source/Host/RootHostView.swift +++ b/submodules/ComponentFlow/Source/Host/RootHostView.swift @@ -80,7 +80,7 @@ public final class RootHostView: UIViewController { self.environment._isUpdated = false transition.setFrame(view: self.componentView, frame: CGRect(origin: CGPoint(), size: size)) - self.componentView.update( + let _ = self.componentView.update( transition: transition, component: self.content, environment: { diff --git a/submodules/ComposePollUI/BUILD b/submodules/ComposePollUI/BUILD index 78a59ef096..f076121bd0 100644 --- a/submodules/ComposePollUI/BUILD +++ b/submodules/ComposePollUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", @@ -17,6 +20,7 @@ swift_library( "//submodules/AlertUI:AlertUI", "//submodules/PresentationDataUtils:PresentationDataUtils", "//submodules/TextFormat:TextFormat", + "//submodules/ObjCRuntimeUtils:ObjCRuntimeUtils", ], visibility = [ "//visibility:public", diff --git a/submodules/ComposePollUI/Sources/CreatePollController.swift b/submodules/ComposePollUI/Sources/CreatePollController.swift index 304a5ebcd2..3a8e3eb8a4 100644 --- a/submodules/ComposePollUI/Sources/CreatePollController.swift +++ b/submodules/ComposePollUI/Sources/CreatePollController.swift @@ -260,8 +260,8 @@ private enum CreatePollEntry: ItemListNodeEntry { switch self { case .text: return CreatePollEntryTag.text - case let .option(option): - return CreatePollEntryTag.option(option.id) + case let .option(id, _, _, _, _, _, _, _, _): + return CreatePollEntryTag.option(id) default: break } @@ -276,8 +276,8 @@ private enum CreatePollEntry: ItemListNodeEntry { return .text case .optionsHeader: return .optionsHeader - case let .option(option): - return .option(option.id) + case let .option(id, _, _, _, _, _, _, _, _): + return .option(id) case .optionsInfo: return .optionsInfo case .anonymousVotes: @@ -305,7 +305,7 @@ private enum CreatePollEntry: ItemListNodeEntry { return 1 case .optionsHeader: return 2 - case let .option(option): + case .option: return 3 case .optionsInfo: return 1001 @@ -328,10 +328,10 @@ private enum CreatePollEntry: ItemListNodeEntry { static func <(lhs: CreatePollEntry, rhs: CreatePollEntry) -> Bool { switch lhs { - case let .option(lhsOption): + case let .option(_, lhsOrdering, _, _, _, _, _, _, _): switch rhs { - case let .option(rhsOption): - return lhsOption.ordering < rhsOption.ordering + case let .option(_, rhsOrdering, _, _, _, _, _, _, _): + return lhsOrdering < rhsOrdering default: break } @@ -992,17 +992,16 @@ public func createPollController(context: AccountContext, peer: Peer, isQuiz: Bo } controller.setReorderEntry({ (fromIndex: Int, toIndex: Int, entries: [CreatePollEntry]) -> Signal in let fromEntry = entries[fromIndex] - guard case let .option(option) = fromEntry else { + guard case let .option(id, _, _, _, _, _, _, _, _) = fromEntry else { return .single(false) } - let id = option.id var referenceId: Int? var beforeAll = false var afterAll = false if toIndex < entries.count { switch entries[toIndex] { - case let .option(toOption): - referenceId = toOption.id + case let .option(toId, _, _, _, _, _, _, _, _): + referenceId = toId default: if entries[toIndex] < fromEntry { beforeAll = true diff --git a/submodules/ComposePollUI/Sources/CreatePollTextInputItem.swift b/submodules/ComposePollUI/Sources/CreatePollTextInputItem.swift index 3b007588be..d7e607bf25 100644 --- a/submodules/ComposePollUI/Sources/CreatePollTextInputItem.swift +++ b/submodules/ComposePollUI/Sources/CreatePollTextInputItem.swift @@ -6,6 +6,7 @@ import SwiftSignalKit import TelegramPresentationData import ItemListUI import TextFormat +import ObjCRuntimeUtils public enum CreatePollTextInputItemTextLimitMode { case characters @@ -292,7 +293,7 @@ public class CreatePollTextInputItemNode: ListViewItemNode, ASEditableTextNodeDe let textLength: Int switch maxLength.mode { case .characters: - textLength = item.text.string.count ?? 0 + textLength = item.text.string.count case .bytes: textLength = item.text.string.data(using: .utf8, allowLossyConversion: true)?.count ?? 0 } @@ -511,7 +512,7 @@ public class CreatePollTextInputItemNode: ListViewItemNode, ASEditableTextNodeDe } public func editableTextNodeTarget(forAction action: Selector) -> ASEditableTextNodeTargetForAction? { - if action == Selector(("_showTextStyleOptions:")) { + if action == makeSelectorFromString("_showTextStyleOptions:") { if case .general = self.inputMenu.state { if self.textNode.attributedText == nil || self.textNode.attributedText!.length == 0 || self.textNode.selectedRange.length == 0 { return ASEditableTextNodeTargetForAction(target: nil) diff --git a/submodules/ConfettiEffect/BUILD b/submodules/ConfettiEffect/BUILD index 6103e15e37..9acf41b4d6 100644 --- a/submodules/ConfettiEffect/BUILD +++ b/submodules/ConfettiEffect/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/ConfettiEffect/Sources/ConfettiView.swift b/submodules/ConfettiEffect/Sources/ConfettiView.swift index 9eda1bd814..441cc4cc8f 100644 --- a/submodules/ConfettiEffect/Sources/ConfettiView.swift +++ b/submodules/ConfettiEffect/Sources/ConfettiView.swift @@ -87,7 +87,6 @@ public final class ConfettiView: UIView { let velocityYRange = Float(3.0) ..< Float(5.0) let angularVelocityRange = Float(1.0) ..< Float(6.0) let sizeVariation = Float(0.8) ..< Float(1.6) - let topDelayRange = Float(0.0) ..< Float(0.0) for i in 0 ..< 70 { let (image, size) = images[i % imageCount] @@ -99,9 +98,6 @@ public final class ConfettiView: UIView { let sideMassRange: Range = 110.0 ..< 120.0 let sideOriginYBase: Float = Float(frame.size.height * 9.0 / 10.0) - let sideOriginYVariation: Float = Float(frame.size.height / 12.0) - let sideOriginYRange = Float(sideOriginYBase - sideOriginYVariation) ..< Float(sideOriginYBase + sideOriginYVariation) - let sideOriginXRange = Float(0.0) ..< Float(100.0) let sideOriginVelocityValueRange = Float(1.1) ..< Float(1.3) let sideOriginVelocityValueScaling: Float = 2400.0 * Float(frame.height) / 896.0 let sideOriginVelocityBase: Float = Float.pi / 2.0 + atanf(Float(CGFloat(sideOriginYBase) / (frame.size.width * 0.8))) @@ -152,11 +148,7 @@ public final class ConfettiView: UIView { self.slowdownStartTimestamps[0] = 0.33 var haveParticlesAboveGround = false - let minPositionY: CGFloat = 0.0 let maxPositionY = self.bounds.height + 30.0 - let minDampingX: CGFloat = 40.0 - let maxDampingX: CGFloat = self.bounds.width - 40.0 - let centerX: CGFloat = self.bounds.width / 2.0 let dt: Float = 1.0 * 1.0 / 60.0 let typeDelays: [Float] = [0.0, 0.01, 0.08] @@ -220,7 +212,7 @@ public final class ConfettiView: UIView { var typesWithPositiveVelocity: [Bool] = [false, false, false] for particle in self.particles { - let (localDt, damping_) = dtAndDamping[particle.type] + let (localDt, _) = dtAndDamping[particle.type] if localDt.isZero { continue } diff --git a/submodules/ContactListUI/BUILD b/submodules/ContactListUI/BUILD index 28a4a99837..aa31a500f9 100644 --- a/submodules/ContactListUI/BUILD +++ b/submodules/ContactListUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ContactListUI/Sources/ContactListNode.swift b/submodules/ContactListUI/Sources/ContactListNode.swift index 286c371b31..d8a2854c12 100644 --- a/submodules/ContactListUI/Sources/ContactListNode.swift +++ b/submodules/ContactListUI/Sources/ContactListNode.swift @@ -1258,8 +1258,8 @@ public final class ContactListNode: ASDisplayNode { var peers: [(Peer, Int32)] = [] for entry in view.entries { switch entry { - case let .MessageEntry(messageEntry): - if let peer = messageEntry.5.peer { + case let .MessageEntry(_, _, _, _, _, renderedPeer, _, _, _, _): + if let peer = renderedPeer.peer { if peer is TelegramGroup { peers.append((peer, 0)) } else if let channel = peer as? TelegramChannel, case .group = channel.info { diff --git a/submodules/ContactListUI/Sources/InviteContactsControllerNode.swift b/submodules/ContactListUI/Sources/InviteContactsControllerNode.swift index 79eeb39c55..93df9f8c64 100644 --- a/submodules/ContactListUI/Sources/InviteContactsControllerNode.swift +++ b/submodules/ContactListUI/Sources/InviteContactsControllerNode.swift @@ -48,7 +48,7 @@ private enum InviteContactsEntry: Comparable, Identifiable { func item(context: AccountContext, presentationData: PresentationData, interaction: InviteContactsInteraction) -> ListViewItem { switch self { - case let .option(_, option, theme, _): + case let .option(_, option, _, _): return ContactListActionItem(presentationData: ItemListPresentationData(presentationData), title: option.title, icon: option.icon, header: nil, action: option.action) case let .peer(_, id, contact, count, selection, theme, strings, nameSortOrder, nameDisplayOrder): let status: ContactsPeerItemStatus diff --git a/submodules/ContactsPeerItem/BUILD b/submodules/ContactsPeerItem/BUILD index 47a5925430..fd0f757c66 100644 --- a/submodules/ContactsPeerItem/BUILD +++ b/submodules/ContactsPeerItem/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ContextUI/BUILD b/submodules/ContextUI/BUILD index f8157be861..8f1126f0c8 100644 --- a/submodules/ContextUI/BUILD +++ b/submodules/ContextUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ContextUI/Sources/ContextController.swift b/submodules/ContextUI/Sources/ContextController.swift index 8f033a294f..883a5902a4 100644 --- a/submodules/ContextUI/Sources/ContextController.swift +++ b/submodules/ContextUI/Sources/ContextController.swift @@ -1010,10 +1010,8 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi var completedEffect = false var completedContentNode = false var completedActionsNode = false - var targetNode: ASDisplayNode? if let transitionInfo = transitionInfo, let (sourceNode, sourceNodeRect) = transitionInfo.sourceNode() { - targetNode = sourceNode let projectedFrame = convertFrame(sourceNodeRect, from: sourceNode.view, to: self.view) self.originalProjectedContentViewFrame = (projectedFrame, projectedFrame) @@ -1090,18 +1088,10 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi animateOutToItem = false } - if animateOutToItem, let targetNode = targetNode, let originalProjectedContentViewFrame = self.originalProjectedContentViewFrame { - let actionsSideInset: CGFloat = (validLayout?.safeInsets.left ?? 0.0) + 11.0 + if animateOutToItem, let originalProjectedContentViewFrame = self.originalProjectedContentViewFrame { let localSourceFrame = self.view.convert(CGRect(origin: CGPoint(x: originalProjectedContentViewFrame.1.minX, y: originalProjectedContentViewFrame.1.minY), size: CGSize(width: originalProjectedContentViewFrame.1.width, height: originalProjectedContentViewFrame.1.height)), to: self.scrollNode.view) - if let snapshotView = targetNode.view.snapshotContentTree(unhide: true, keepTransform: true), false { - self.view.addSubview(snapshotView) - snapshotView.layer.animatePosition(from: CGPoint(x: self.contentContainerNode.frame.midX, y: self.contentContainerNode.frame.minY + localSourceFrame.height / 2.0), to: localSourceFrame.center, duration: transitionDuration * animationDurationFactor, timingFunction: transitionCurve.timingFunction, removeOnCompletion: false) - snapshotView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2 * animationDurationFactor, removeOnCompletion: false, completion: { _ in - }) - } - self.actionsContainerNode.layer.animatePosition(from: CGPoint(), to: CGPoint(x: localSourceFrame.center.x - self.actionsContainerNode.position.x, y: localSourceFrame.center.y - self.actionsContainerNode.position.y), duration: transitionDuration * animationDurationFactor, timingFunction: transitionCurve.timingFunction, removeOnCompletion: false, additive: true) let contentContainerOffset = CGPoint(x: localSourceFrame.center.x - self.contentContainerNode.frame.center.x, y: localSourceFrame.center.y - self.contentContainerNode.frame.center.y) self.contentContainerNode.layer.animatePosition(from: CGPoint(), to: contentContainerOffset, duration: transitionDuration * animationDurationFactor, timingFunction: transitionCurve.timingFunction, removeOnCompletion: false, additive: true, completion: { [weak self] _ in @@ -1724,7 +1714,7 @@ public final class ContextControllerReferenceViewInfo { } } -public protocol ContextReferenceContentSource: class { +public protocol ContextReferenceContentSource: AnyObject { func transitionInfo() -> ContextControllerReferenceViewInfo? } @@ -1750,7 +1740,7 @@ public final class ContextControllerPutBackViewInfo { } } -public protocol ContextExtractedContentSource: class { +public protocol ContextExtractedContentSource: AnyObject { var centerVertically: Bool { get } var keepInPlace: Bool { get } var ignoreContentTouches: Bool { get } @@ -1781,7 +1771,7 @@ public final class ContextControllerTakeControllerInfo { } } -public protocol ContextControllerContentSource: class { +public protocol ContextControllerContentSource: AnyObject { var controller: ViewController { get } var navigationController: NavigationController? { get } var passthroughTouches: Bool { get } diff --git a/submodules/CounterContollerTitleView/BUILD b/submodules/CounterContollerTitleView/BUILD index 0462915bd5..7ad134d009 100644 --- a/submodules/CounterContollerTitleView/BUILD +++ b/submodules/CounterContollerTitleView/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/CountrySelectionUI/BUILD b/submodules/CountrySelectionUI/BUILD index b5284ea80d..e681f57857 100644 --- a/submodules/CountrySelectionUI/BUILD +++ b/submodules/CountrySelectionUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/DatePickerNode/BUILD b/submodules/DatePickerNode/BUILD index cc26958683..02d1f00f53 100644 --- a/submodules/DatePickerNode/BUILD +++ b/submodules/DatePickerNode/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/DatePickerNode/Sources/TapeNode.swift b/submodules/DatePickerNode/Sources/TapeNode.swift index a1ad195d49..feccc0dda5 100644 --- a/submodules/DatePickerNode/Sources/TapeNode.swift +++ b/submodules/DatePickerNode/Sources/TapeNode.swift @@ -4,7 +4,7 @@ import Display import AsyncDisplayKit import AudioToolbox -@objc public protocol PickerViewDelegate: class { +@objc public protocol PickerViewDelegate: AnyObject { func pickerViewHeightForRows(_ pickerView: TapeNode) -> CGFloat @objc optional func pickerView(_ pickerView: TapeNode, didSelectRow row: Int) @objc optional func pickerView(_ pickerView: TapeNode, didTapRow row: Int) diff --git a/submodules/DateSelectionUI/BUILD b/submodules/DateSelectionUI/BUILD index 2d9080285d..be8c15b508 100644 --- a/submodules/DateSelectionUI/BUILD +++ b/submodules/DateSelectionUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/DebugSettingsUI/BUILD b/submodules/DebugSettingsUI/BUILD index 9b154444b7..f536359fa2 100644 --- a/submodules/DebugSettingsUI/BUILD +++ b/submodules/DebugSettingsUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/Display:Display", diff --git a/submodules/DebugSettingsUI/Sources/DebugAccountsController.swift b/submodules/DebugSettingsUI/Sources/DebugAccountsController.swift index 32a67c8272..0c88bf011b 100644 --- a/submodules/DebugSettingsUI/Sources/DebugAccountsController.swift +++ b/submodules/DebugSettingsUI/Sources/DebugAccountsController.swift @@ -75,11 +75,11 @@ private enum DebugAccountsControllerEntry: ItemListNodeEntry { func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem { let arguments = arguments as! DebugAccountsControllerArguments switch self { - case let .record(theme, record, current): + case let .record(_, record, current): return ItemListCheckboxItem(presentationData: presentationData, title: "\(UInt64(bitPattern: record.id.int64))", style: .left, checked: current, zeroSeparatorInsets: false, sectionId: self.section, action: { arguments.switchAccount(record.id) }) - case let .loginNewAccount(theme): + case .loginNewAccount: return ItemListActionItem(presentationData: presentationData, title: "Login to another account", kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: { arguments.loginNewAccount() }) diff --git a/submodules/DebugSettingsUI/Sources/DebugController.swift b/submodules/DebugSettingsUI/Sources/DebugController.swift index 3f9396f8d0..10f86849f8 100644 --- a/submodules/DebugSettingsUI/Sources/DebugController.swift +++ b/submodules/DebugSettingsUI/Sources/DebugController.swift @@ -617,7 +617,6 @@ private enum DebugControllerEntry: ItemListNodeEntry { let databasePath = context.account.basePath + "/postbox/db" let _ = try? FileManager.default.removeItem(atPath: databasePath) exit(0) - preconditionFailure() }), ]), ActionSheetItemGroup(items: [ ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in @@ -640,7 +639,6 @@ private enum DebugControllerEntry: ItemListNodeEntry { let databasePath = context.account.basePath + "/postbox" let _ = try? FileManager.default.removeItem(atPath: databasePath) exit(0) - preconditionFailure() }), ]), ActionSheetItemGroup(items: [ ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in diff --git a/submodules/DeleteChatPeerActionSheetItem/BUILD b/submodules/DeleteChatPeerActionSheetItem/BUILD index d991fcc4b4..da28adac66 100644 --- a/submodules/DeleteChatPeerActionSheetItem/BUILD +++ b/submodules/DeleteChatPeerActionSheetItem/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/DeviceAccess/BUILD b/submodules/DeviceAccess/BUILD index 77cdb116dd..83e31b8d67 100644 --- a/submodules/DeviceAccess/BUILD +++ b/submodules/DeviceAccess/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/TelegramCore:TelegramCore", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", diff --git a/submodules/DeviceLocationManager/BUILD b/submodules/DeviceLocationManager/BUILD index 583f811cfb..8635180aed 100644 --- a/submodules/DeviceLocationManager/BUILD +++ b/submodules/DeviceLocationManager/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", ], diff --git a/submodules/DirectionalPanGesture/BUILD b/submodules/DirectionalPanGesture/BUILD index 9e62d95bb1..e0b8dd6c1f 100644 --- a/submodules/DirectionalPanGesture/BUILD +++ b/submodules/DirectionalPanGesture/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], visibility = [ "//visibility:public", ], diff --git a/submodules/Display/BUILD b/submodules/Display/BUILD index 277d09ae20..8e56c1d1ec 100644 --- a/submodules/Display/BUILD +++ b/submodules/Display/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Source/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/ObjCRuntimeUtils:ObjCRuntimeUtils", "//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils", diff --git a/submodules/Display/Source/ContainableController.swift b/submodules/Display/Source/ContainableController.swift index ad9eb30558..22da56873a 100644 --- a/submodules/Display/Source/ContainableController.swift +++ b/submodules/Display/Source/ContainableController.swift @@ -2,11 +2,11 @@ import UIKit import AsyncDisplayKit import SwiftSignalKit -public protocol PresentableController: class { +public protocol PresentableController: AnyObject { func viewDidAppear(completion: @escaping () -> Void) } -public protocol ContainableController: class { +public protocol ContainableController: AnyObject { var view: UIView! { get } var displayNode: ASDisplayNode { get } var isViewLoaded: Bool { get } diff --git a/submodules/Display/Source/ContainedViewLayoutTransition.swift b/submodules/Display/Source/ContainedViewLayoutTransition.swift index 019a41615b..e1eebfc499 100644 --- a/submodules/Display/Source/ContainedViewLayoutTransition.swift +++ b/submodules/Display/Source/ContainedViewLayoutTransition.swift @@ -799,8 +799,6 @@ public extension ContainedViewLayoutTransition { } func animateTransformScale(node: ASDisplayNode, from fromScale: CGPoint, completion: ((Bool) -> Void)? = nil) { - let t = node.layer.transform - switch self { case .immediate: if let completion = completion { diff --git a/submodules/Display/Source/GenerateImage.swift b/submodules/Display/Source/GenerateImage.swift index 0606e987ef..8d3e7a6ae6 100644 --- a/submodules/Display/Source/GenerateImage.swift +++ b/submodules/Display/Source/GenerateImage.swift @@ -553,7 +553,6 @@ public class DrawingContext { } if self.hasGeneratedImage { preconditionFailure() - return nil } self.hasGeneratedImage = true diff --git a/submodules/Display/Source/ListView.swift b/submodules/Display/Source/ListView.swift index 68d30aa4cc..f8615f2ebc 100644 --- a/submodules/Display/Source/ListView.swift +++ b/submodules/Display/Source/ListView.swift @@ -2661,24 +2661,6 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture } } - if !offset.isZero { - let scrollToItemTransition: ContainedViewLayoutTransition - if !scrollToItem.animated { - scrollToItemTransition = .immediate - } else { - switch scrollToItem.curve { - case let .Spring(duration): - scrollToItemTransition = .animated(duration: duration, curve: .spring) - case let .Default(duration): - scrollToItemTransition = .animated(duration: duration ?? 0.3, curve: .easeInOut) - case let .Custom(duration, cp1x, cp1y, cp2x, cp2y): - scrollToItemTransition = .animated(duration: duration, curve: .custom(cp1x, cp1y, cp2x, cp2y)) - } - } - - //self.didScrollWithOffset?(-offset, scrollToItemTransition, nil) - } - for itemNode in self.itemNodes { var frame = itemNode.frame frame.origin.y += offset @@ -2750,24 +2732,6 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture self.ensureTopInsetForOverlayHighlightedItems = updateSizeAndInsets.ensureTopInsetForOverlayHighlightedItems self.visibleSize = updateSizeAndInsets.size - let updateSizeAndInsetsTransition: ContainedViewLayoutTransition - if updateSizeAndInsets.duration.isZero { - updateSizeAndInsetsTransition = .immediate - } else { - switch updateSizeAndInsets.curve { - case let .Spring(duration): - updateSizeAndInsetsTransition = .animated(duration: duration, curve: .spring) - case let .Default(duration): - updateSizeAndInsetsTransition = .animated(duration: duration ?? 0.3, curve: .easeInOut) - case let .Custom(duration, cp1x, cp1y, cp2x, cp2y): - updateSizeAndInsetsTransition = .animated(duration: duration, curve: .custom(cp1x, cp1y, cp2x, cp2y)) - } - } - - if !offsetFix.isZero { - //self.didScrollWithOffset?(-offsetFix, updateSizeAndInsetsTransition, nil) - } - for itemNode in self.itemNodes { itemNode.updateFrame(itemNode.frame.offsetBy(dx: 0.0, dy: offsetFix), within: self.visibleSize) } diff --git a/submodules/Display/Source/Navigation/NavigationController.swift b/submodules/Display/Source/Navigation/NavigationController.swift index eddc06841b..d855be2af2 100644 --- a/submodules/Display/Source/Navigation/NavigationController.swift +++ b/submodules/Display/Source/Navigation/NavigationController.swift @@ -107,7 +107,7 @@ private final class NavigationControllerNode: ASDisplayNode { } } -public protocol NavigationControllerDropContentItem: class { +public protocol NavigationControllerDropContentItem: AnyObject { } public final class NavigationControllerDropContent { @@ -406,7 +406,7 @@ open class NavigationController: UINavigationController, ContainableController, globalScrollToTopNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -1.0), size: CGSize(width: layout.size.width, height: 1.0)) } - var overlayContainerLayout = layout + let overlayContainerLayout = layout if let inCallStatusBar = self.inCallStatusBar { var inCallStatusBarFrame = CGRect(origin: CGPoint(), size: CGSize(width: layout.size.width, height: max(layout.statusBarHeight ?? 0.0, max(40.0, layout.safeInsets.top)))) diff --git a/submodules/Display/Source/WindowInputAccessoryHeightProvider.swift b/submodules/Display/Source/WindowInputAccessoryHeightProvider.swift index ef51090cbc..4b70932191 100644 --- a/submodules/Display/Source/WindowInputAccessoryHeightProvider.swift +++ b/submodules/Display/Source/WindowInputAccessoryHeightProvider.swift @@ -1,6 +1,6 @@ import Foundation import UIKit -public protocol WindowInputAccessoryHeightProvider: class { +public protocol WindowInputAccessoryHeightProvider: AnyObject { func getWindowInputAccessoryHeight() -> CGFloat } diff --git a/submodules/Emoji/BUILD b/submodules/Emoji/BUILD index 9b5e934bcf..cba5496dea 100644 --- a/submodules/Emoji/BUILD +++ b/submodules/Emoji/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], visibility = [ "//visibility:public", ], diff --git a/submodules/EncryptionKeyVisualization/BUILD b/submodules/EncryptionKeyVisualization/BUILD index f19adbb6ab..63804e3386 100644 --- a/submodules/EncryptionKeyVisualization/BUILD +++ b/submodules/EncryptionKeyVisualization/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/TelegramCore:TelegramCore", "//submodules/EncryptionKeyVisualization/Impl:EncryptionKeyVisualizationImpl", diff --git a/submodules/FileMediaResourceStatus/BUILD b/submodules/FileMediaResourceStatus/BUILD index 84090d2b33..44d70774c6 100644 --- a/submodules/FileMediaResourceStatus/BUILD +++ b/submodules/FileMediaResourceStatus/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/GalleryData/BUILD b/submodules/GalleryData/BUILD index d433b87091..5e3be4d4e2 100644 --- a/submodules/GalleryData/BUILD +++ b/submodules/GalleryData/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/GalleryData/Sources/GalleryData.swift b/submodules/GalleryData/Sources/GalleryData.swift index 4cc8b1b532..43632cd6ac 100644 --- a/submodules/GalleryData/Sources/GalleryData.swift +++ b/submodules/GalleryData/Sources/GalleryData.swift @@ -266,7 +266,7 @@ public enum ChatMessagePreviewControllerData { public func chatMessagePreviewControllerData(context: AccountContext, chatLocation: ChatLocation?, chatLocationContextHolder: Atomic?, message: Message, standalone: Bool, reverseMessageGalleryOrder: Bool, navigationController: NavigationController?) -> ChatMessagePreviewControllerData? { if let mediaData = chatMessageGalleryControllerData(context: context, chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, message: message, navigationController: navigationController, standalone: standalone, reverseMessageGalleryOrder: reverseMessageGalleryOrder, mode: .default, source: nil, synchronousLoad: true, actionInteraction: nil) { switch mediaData { - case let .gallery(gallery): + case .gallery: break case let .instantPage(gallery, centralIndex, galleryMedia): return .instantPage(gallery, centralIndex, galleryMedia) diff --git a/submodules/GalleryUI/BUILD b/submodules/GalleryUI/BUILD index 115b6fc4b4..d7df405df9 100644 --- a/submodules/GalleryUI/BUILD +++ b/submodules/GalleryUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/GalleryUI/Sources/GalleryController.swift b/submodules/GalleryUI/Sources/GalleryController.swift index 46a5458a96..df117ca2e1 100644 --- a/submodules/GalleryUI/Sources/GalleryController.swift +++ b/submodules/GalleryUI/Sources/GalleryController.swift @@ -868,11 +868,7 @@ public class GalleryController: ViewController, StandalonePresentableController ActionSheetButtonItem(title: isCopyLink ? strongSelf.presentationData.strings.Conversation_ContextMenuCopyLink : strongSelf.presentationData.strings.Conversation_LinkDialogCopy, color: .accent, action: { [weak actionSheet, weak self] in actionSheet?.dismissAnimated() if isCopyLink, let channel = message.peers[message.id.peerId] as? TelegramChannel { - var threadMessageId: MessageId? -// if case let .replyThread(replyThreadMessage) = chatPresentationInterfaceState.chatLocation { -// threadMessageId = replyThreadMessage.messageId -// } - let _ = (context.engine.messages.exportMessageLink(peerId: message.id.peerId, messageId: message.id, isThread: threadMessageId != nil) + let _ = (context.engine.messages.exportMessageLink(peerId: message.id.peerId, messageId: message.id, isThread: false) |> map { result -> String? in return result } @@ -1045,18 +1041,9 @@ public class GalleryController: ViewController, StandalonePresentableController if let strongSelf = self { strongSelf._hiddenMedia.set(.single(nil)) - var animatedOutNode = true - var animatedOutInterface = false - - let completion = { - if animatedOutNode && animatedOutInterface { - //self?.presentingViewController?.dismiss(animated: false, completion: nil) - } - } + let animatedOutNode = true strongSelf.galleryNode.animateOut(animateContent: animatedOutNode, completion: { - animatedOutInterface = true - //completion() }) } } diff --git a/submodules/GalleryUI/Sources/GalleryFooterNode.swift b/submodules/GalleryUI/Sources/GalleryFooterNode.swift index 95acee8794..4f14a43e08 100644 --- a/submodules/GalleryUI/Sources/GalleryFooterNode.swift +++ b/submodules/GalleryUI/Sources/GalleryFooterNode.swift @@ -37,15 +37,11 @@ public final class GalleryFooterNode: ASDisplayNode { let cleanInsets = layout.insets(options: []) var dismissedCurrentFooterContentNode: GalleryFooterContentNode? - var dismissedThumbnailPanelHeight: CGFloat? if self.currentFooterContentNode !== footerContentNode { if let currentFooterContentNode = self.currentFooterContentNode { currentFooterContentNode.requestLayout = nil dismissedCurrentFooterContentNode = currentFooterContentNode } - if let currentThumbnailPanelHeight = self.currentThumbnailPanelHeight { - dismissedThumbnailPanelHeight = currentThumbnailPanelHeight - } self.currentThumbnailPanelHeight = thumbnailPanelHeight self.currentFooterContentNode = footerContentNode if let footerContentNode = footerContentNode { diff --git a/submodules/GalleryUI/Sources/GalleryItemTransitionNode.swift b/submodules/GalleryUI/Sources/GalleryItemTransitionNode.swift index f3ca3f979e..807c3d8148 100644 --- a/submodules/GalleryUI/Sources/GalleryItemTransitionNode.swift +++ b/submodules/GalleryUI/Sources/GalleryItemTransitionNode.swift @@ -1,7 +1,7 @@ import Foundation import AccountContext -public protocol GalleryItemTransitionNode: class { +public protocol GalleryItemTransitionNode: AnyObject { func isAvailableForGalleryTransition() -> Bool func isAvailableForInstantPageTransition() -> Bool var decoration: UniversalVideoDecoration? { get } diff --git a/submodules/GalleryUI/Sources/GalleryThumbnailContainerNode.swift b/submodules/GalleryUI/Sources/GalleryThumbnailContainerNode.swift index 0af6fc4002..94a0c87568 100644 --- a/submodules/GalleryUI/Sources/GalleryThumbnailContainerNode.swift +++ b/submodules/GalleryUI/Sources/GalleryThumbnailContainerNode.swift @@ -280,9 +280,7 @@ public final class GalleryThumbnailContainerNode: ASDisplayNode, UIScrollViewDel return } - if let (centralIndex, progress) = self.centralIndexAndProgress { - //let contentOffset = contentOffsetToCenterItem(index: centralIndex, progress: progress, contentInset: self.scrollNode.view.contentInset) - + if let _ = self.centralIndexAndProgress { let transition = ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring) if !decelerate { self.isPanning = false diff --git a/submodules/GalleryUI/Sources/Items/ChatAnimationGalleryItem.swift b/submodules/GalleryUI/Sources/Items/ChatAnimationGalleryItem.swift index 87078d9697..386a27af17 100644 --- a/submodules/GalleryUI/Sources/Items/ChatAnimationGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/ChatAnimationGalleryItem.swift @@ -208,7 +208,7 @@ final class ChatAnimationGalleryItemNode: ZoomableContentGalleryItemNode { strongSelf.statusNode.alpha = 1.0 strongSelf.statusNodeContainer.isUserInteractionEnabled = true strongSelf.statusNode.transitionToState(.download(.white), completion: {}) - case let .Fetching(isActive, progress): + case let .Fetching(_, progress): strongSelf.statusNode.isHidden = false strongSelf.statusNode.alpha = 1.0 strongSelf.statusNodeContainer.isUserInteractionEnabled = true @@ -312,7 +312,7 @@ final class ChatAnimationGalleryItemNode: ZoomableContentGalleryItemNode { override func visibilityUpdated(isVisible: Bool) { super.visibilityUpdated(isVisible: isVisible) - if let (context, mediaReference) = self.contextAndMedia, let fileReference = mediaReference.concrete(TelegramMediaFile.self) { + if let (_, mediaReference) = self.contextAndMedia, let _ = mediaReference.concrete(TelegramMediaFile.self) { if isVisible { } else { self.fetchDisposable.set(nil) diff --git a/submodules/GalleryUI/Sources/Items/ChatDocumentGalleryItem.swift b/submodules/GalleryUI/Sources/Items/ChatDocumentGalleryItem.swift index 12829f7c15..4379cf5aca 100644 --- a/submodules/GalleryUI/Sources/Items/ChatDocumentGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/ChatDocumentGalleryItem.swift @@ -197,7 +197,7 @@ class ChatDocumentGalleryItemNode: ZoomableContentGalleryItemNode, WKNavigationD strongSelf.statusNode.alpha = 1.0 strongSelf.statusNodeContainer.isUserInteractionEnabled = true strongSelf.statusNode.transitionToState(.download(.white), completion: {}) - case let .Fetching(isActive, progress): + case let .Fetching(_, progress): strongSelf.statusNode.isHidden = false strongSelf.statusNode.alpha = 1.0 strongSelf.statusNodeContainer.isUserInteractionEnabled = true diff --git a/submodules/GalleryUI/Sources/Items/ChatExternalFileGalleryItem.swift b/submodules/GalleryUI/Sources/Items/ChatExternalFileGalleryItem.swift index 1dadd77a30..bd7f697d09 100644 --- a/submodules/GalleryUI/Sources/Items/ChatExternalFileGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/ChatExternalFileGalleryItem.swift @@ -195,7 +195,7 @@ class ChatExternalFileGalleryItemNode: GalleryItemNode { strongSelf.statusNode.alpha = 1.0 strongSelf.statusNodeContainer.isUserInteractionEnabled = true strongSelf.statusNode.transitionToState(.download(.white), completion: {}) - case let .Fetching(isActive, progress): + case let .Fetching(_, progress): strongSelf.statusNode.isHidden = false strongSelf.statusNode.alpha = 1.0 strongSelf.statusNodeContainer.isUserInteractionEnabled = true diff --git a/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift b/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift index c02208680d..3b14a1891e 100644 --- a/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift @@ -420,7 +420,7 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode { strongSelf.statusNode.alpha = 1.0 strongSelf.statusNodeContainer.isUserInteractionEnabled = true strongSelf.statusNode.transitionToState(.download(.white), completion: {}) - case let .Fetching(isActive, progress): + case let .Fetching(_, progress): strongSelf.statusNode.isHidden = false strongSelf.statusNode.alpha = 1.0 strongSelf.statusNodeContainer.isUserInteractionEnabled = true @@ -596,7 +596,7 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode { override func visibilityUpdated(isVisible: Bool) { super.visibilityUpdated(isVisible: isVisible) - if let (context, mediaReference) = self.contextAndMedia, let fileReference = mediaReference.concrete(TelegramMediaFile.self) { + if let (_, mediaReference) = self.contextAndMedia, let _ = mediaReference.concrete(TelegramMediaFile.self) { if isVisible { } else { self.fetchDisposable.set(nil) diff --git a/submodules/GalleryUI/Sources/SecretMediaPreviewController.swift b/submodules/GalleryUI/Sources/SecretMediaPreviewController.swift index 4fbec52b5f..b8d108ed4b 100644 --- a/submodules/GalleryUI/Sources/SecretMediaPreviewController.swift +++ b/submodules/GalleryUI/Sources/SecretMediaPreviewController.swift @@ -237,17 +237,8 @@ public final class SecretMediaPreviewController: ViewController { strongSelf._hiddenMedia.set(.single(nil)) let animatedOutNode = true - var animatedOutInterface = false - - let completion = { - if animatedOutNode && animatedOutInterface { - //self?.presentingViewController?.dismiss(animated: false, completion: nil) - } - } strongSelf.controllerNode.animateOut(animateContent: animatedOutNode, completion: { - animatedOutInterface = true - //completion() }) } } diff --git a/submodules/GameUI/BUILD b/submodules/GameUI/BUILD index b12e125010..1ea06ab121 100644 --- a/submodules/GameUI/BUILD +++ b/submodules/GameUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/Geocoding/BUILD b/submodules/Geocoding/BUILD index d03fe14734..35ce472ddf 100644 --- a/submodules/Geocoding/BUILD +++ b/submodules/Geocoding/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", ], diff --git a/submodules/GlassButtonNode/BUILD b/submodules/GlassButtonNode/BUILD index 7a35f60ab4..bab4d6718e 100644 --- a/submodules/GlassButtonNode/BUILD +++ b/submodules/GlassButtonNode/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/GradientBackground/BUILD b/submodules/GradientBackground/BUILD index f216710644..a84790b04b 100644 --- a/submodules/GradientBackground/BUILD +++ b/submodules/GradientBackground/BUILD @@ -8,6 +8,7 @@ swift_library( ]), copts = [ "-O", + "-warnings-as-errors", ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/GraphCore/BUILD b/submodules/GraphCore/BUILD index 10c347161d..058b5faf80 100644 --- a/submodules/GraphCore/BUILD +++ b/submodules/GraphCore/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/Display:Display", ], diff --git a/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/BarsComponentController.swift b/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/BarsComponentController.swift index f92dce8b73..fb586a4d37 100644 --- a/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/BarsComponentController.swift +++ b/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/BarsComponentController.swift @@ -216,7 +216,6 @@ class BarsComponentController: GeneralChartComponentController { } override func showDetailsView(at chartPosition: CGFloat, detailsViewPosition: CGFloat, dataIndex: Int, date: Date, animated: Bool, feedback: Bool) { - let rangeWithOffset = detailsViewPosition - barsWidth / currentHorizontalMainChartRange.distance * chartFrame().width / 2 + chartFrame().minX / 2 super.showDetailsView(at: chartPosition, detailsViewPosition: detailsViewPosition, dataIndex: dataIndex, date: date, animated: animated, feedback: feedback) mainBarsRenderer.setSelectedIndex(dataIndex, animated: true) } diff --git a/submodules/GraphCore/Sources/Charts/Renderes/BaseChartRenderer.swift b/submodules/GraphCore/Sources/Charts/Renderes/BaseChartRenderer.swift index fa9ce5bc4c..6c920496b2 100644 --- a/submodules/GraphCore/Sources/Charts/Renderes/BaseChartRenderer.swift +++ b/submodules/GraphCore/Sources/Charts/Renderes/BaseChartRenderer.swift @@ -13,7 +13,7 @@ import Cocoa import UIKit #endif -public protocol ChartViewRenderer: class { +public protocol ChartViewRenderer: AnyObject { var containerViews: [GView] { get set } func render(context: CGContext, bounds: CGRect, chartFrame: CGRect) } diff --git a/submodules/GraphCore/Sources/Charts/Renderes/LinesChartRenderer.swift b/submodules/GraphCore/Sources/Charts/Renderes/LinesChartRenderer.swift index b974f7ae51..949ffacc88 100644 --- a/submodules/GraphCore/Sources/Charts/Renderes/LinesChartRenderer.swift +++ b/submodules/GraphCore/Sources/Charts/Renderes/LinesChartRenderer.swift @@ -76,7 +76,6 @@ class LinesChartRenderer: BaseChartRenderer { if linesShapeAnimator.isAnimating { let animationOffset = linesShapeAnimator.current - let path = CGMutablePath() let fromPoints = fromLines.safeElement(at: index)?.points ?? [] let toPoints = toLines.safeElement(at: index)?.points ?? [] diff --git a/submodules/GraphCore/Sources/Charts/Renderes/PecentChartRenderer.swift b/submodules/GraphCore/Sources/Charts/Renderes/PecentChartRenderer.swift index 7c402941b2..c65487ec42 100644 --- a/submodules/GraphCore/Sources/Charts/Renderes/PecentChartRenderer.swift +++ b/submodules/GraphCore/Sources/Charts/Renderes/PecentChartRenderer.swift @@ -52,7 +52,7 @@ class PecentChartRenderer: BaseChartRenderer { let range = renderRange(bounds: bounds, chartFrame: chartFrame) - var paths: [CGMutablePath] = percentageData.components.map { _ in CGMutablePath() } + let paths: [CGMutablePath] = percentageData.components.map { _ in CGMutablePath() } var vertices: [CGFloat] = Array(repeating: 0, count: percentageData.components.count) if var locationIndex = percentageData.locations.firstIndex(where: { $0 > range.lowerBound }) { diff --git a/submodules/GraphCore/Sources/Charts/Renderes/PercentPieAnimationRenderer.swift b/submodules/GraphCore/Sources/Charts/Renderes/PercentPieAnimationRenderer.swift index dfa0ff3c97..23f11eb0af 100644 --- a/submodules/GraphCore/Sources/Charts/Renderes/PercentPieAnimationRenderer.swift +++ b/submodules/GraphCore/Sources/Charts/Renderes/PercentPieAnimationRenderer.swift @@ -125,7 +125,6 @@ class PercentPieAnimationRenderer: BaseChartRenderer { offset: animationFractionD) let startDestinationPoint = lineCenterPoint + CGPoint(x: destinationRadius, y: 0) - let centerDestinationPoint = lineCenterPoint + CGPoint(x: 0, y: destinationRadius) let endDestinationPoint = lineCenterPoint + CGPoint(x: -destinationRadius, y: 0) let initialStartDestinationAngle: CGFloat = 0 let initialCenterDestinationAngle: CGFloat = .pi / 2 diff --git a/submodules/GraphCore/Sources/Helpers/DisplayLinkService.swift b/submodules/GraphCore/Sources/Helpers/DisplayLinkService.swift index 89f98b23b2..e040b4b6e6 100644 --- a/submodules/GraphCore/Sources/Helpers/DisplayLinkService.swift +++ b/submodules/GraphCore/Sources/Helpers/DisplayLinkService.swift @@ -14,7 +14,7 @@ import UIKit #endif import CoreGraphics -public protocol DisplayLinkListner: class { +public protocol DisplayLinkListner: AnyObject { func update(delta: TimeInterval) } diff --git a/submodules/GraphUI/BUILD b/submodules/GraphUI/BUILD index 376406b82d..fc10bc1cb3 100644 --- a/submodules/GraphUI/BUILD +++ b/submodules/GraphUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/GridMessageSelectionNode/BUILD b/submodules/GridMessageSelectionNode/BUILD index 1d24313555..0f49aaa07e 100644 --- a/submodules/GridMessageSelectionNode/BUILD +++ b/submodules/GridMessageSelectionNode/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/HashtagSearchUI/BUILD b/submodules/HashtagSearchUI/BUILD index 76911cd41d..5a466af616 100644 --- a/submodules/HashtagSearchUI/BUILD +++ b/submodules/HashtagSearchUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/HexColor/BUILD b/submodules/HexColor/BUILD index faf074d046..4dfd5a4ec7 100644 --- a/submodules/HexColor/BUILD +++ b/submodules/HexColor/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/TextFormat:TextFormat", ], diff --git a/submodules/HorizontalPeerItem/BUILD b/submodules/HorizontalPeerItem/BUILD index 6fcfc15a69..1bce1aa70f 100644 --- a/submodules/HorizontalPeerItem/BUILD +++ b/submodules/HorizontalPeerItem/BUILD @@ -6,9 +6,11 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", - "//submodules/Postbox:Postbox", "//submodules/TelegramCore:TelegramCore", "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/HorizontalPeerItem/Sources/HorizontalPeerItem.swift b/submodules/HorizontalPeerItem/Sources/HorizontalPeerItem.swift index 3d97c4e3f6..cba0bc85fa 100644 --- a/submodules/HorizontalPeerItem/Sources/HorizontalPeerItem.swift +++ b/submodules/HorizontalPeerItem/Sources/HorizontalPeerItem.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import Display -import Postbox import AsyncDisplayKit import TelegramCore import SwiftSignalKit @@ -24,15 +23,15 @@ public final class HorizontalPeerItem: ListViewItem { let strings: PresentationStrings let mode: HorizontalPeerItemMode let context: AccountContext - public let peer: Peer - let action: (Peer) -> Void - let contextAction: (Peer, ASDisplayNode, ContextGesture?) -> Void - let isPeerSelected: (PeerId) -> Bool + public let peer: EnginePeer + let action: (EnginePeer) -> Void + let contextAction: (EnginePeer, ASDisplayNode, ContextGesture?) -> Void + let isPeerSelected: (EnginePeer.Id) -> Bool let customWidth: CGFloat? - let presence: PeerPresence? + let presence: EnginePeer.Presence? let unreadBadge: (Int32, Bool)? - public init(theme: PresentationTheme, strings: PresentationStrings, mode: HorizontalPeerItemMode, context: AccountContext, peer: Peer, presence: PeerPresence?, unreadBadge: (Int32, Bool)?, action: @escaping (Peer) -> Void, contextAction: @escaping (Peer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (PeerId) -> Bool, customWidth: CGFloat?) { + public init(theme: PresentationTheme, strings: PresentationStrings, mode: HorizontalPeerItemMode, context: AccountContext, peer: EnginePeer, presence: EnginePeer.Presence?, unreadBadge: (Int32, Bool)?, action: @escaping (EnginePeer) -> Void, contextAction: @escaping (EnginePeer, ASDisplayNode, ContextGesture?) -> Void, isPeerSelected: @escaping (EnginePeer.Id) -> Bool, customWidth: CGFloat?) { self.theme = theme self.strings = strings self.mode = mode @@ -163,7 +162,7 @@ public final class HorizontalPeerItemNode: ListViewItemNode { var online = false let timestamp = CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970 - if let peer = item.peer as? TelegramUser, let presence = item.presence as? TelegramUserPresence, !isServicePeer(peer) && !peer.flags.contains(.isSupport) { + if case let .user(peer) = item.peer, let presence = item.presence, !item.peer.isService, !peer.flags.contains(.isSupport) { let relativeStatus = relativeUserPresenceStatus(presence, relativeTo: Int32(timestamp)) if case .online = relativeStatus { online = true @@ -187,7 +186,7 @@ public final class HorizontalPeerItemNode: ListViewItemNode { if let strongSelf = self { strongSelf.item = item strongSelf.peerNode.theme = itemTheme - strongSelf.peerNode.setup(context: item.context, theme: item.theme, strings: item.strings, peer: EngineRenderedPeer(peer: EnginePeer(item.peer)), numberOfLines: 1, synchronousLoad: synchronousLoads) + strongSelf.peerNode.setup(context: item.context, theme: item.theme, strings: item.strings, peer: EngineRenderedPeer(peer: item.peer), numberOfLines: 1, synchronousLoad: synchronousLoads) strongSelf.peerNode.frame = CGRect(origin: CGPoint(), size: itemLayout.size) strongSelf.peerNode.updateSelection(selected: item.isPeerSelected(item.peer.id), animated: false) diff --git a/submodules/ImageBlur/BUILD b/submodules/ImageBlur/BUILD index bb486d2964..08d7c3d40a 100644 --- a/submodules/ImageBlur/BUILD +++ b/submodules/ImageBlur/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/FastBlur:FastBlur", ], diff --git a/submodules/ImageCompression/BUILD b/submodules/ImageCompression/BUILD index 752daa198e..fe40c802c3 100644 --- a/submodules/ImageCompression/BUILD +++ b/submodules/ImageCompression/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/MozjpegBinding:MozjpegBinding", ], diff --git a/submodules/ImageTransparency/BUILD b/submodules/ImageTransparency/BUILD index acae43de49..19c5699fcb 100644 --- a/submodules/ImageTransparency/BUILD +++ b/submodules/ImageTransparency/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + #"-warnings-as-errors", + ], deps = [ "//submodules/Display:Display", ], diff --git a/submodules/ImageTransparency/Sources/ImageTransparency.swift b/submodules/ImageTransparency/Sources/ImageTransparency.swift index 3283567641..8f73dcbd9e 100644 --- a/submodules/ImageTransparency/Sources/ImageTransparency.swift +++ b/submodules/ImageTransparency/Sources/ImageTransparency.swift @@ -29,7 +29,7 @@ private func generateHistogram(cgImage: CGImage) -> ([[vImagePixelCount]], Int)? } assert(error == kvImageNoError) - let histogramBins = (0...3).map { _ in + let histogramBins: [[vImagePixelCount]] = (0...3).map { _ in return [vImagePixelCount](repeating: 0, count: 256) } var mutableHistogram: [UnsafeMutablePointer?] = histogramBins.map { diff --git a/submodules/ImportStickerPackUI/BUILD b/submodules/ImportStickerPackUI/BUILD index 38960140a3..0c44d12e08 100644 --- a/submodules/ImportStickerPackUI/BUILD +++ b/submodules/ImportStickerPackUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ImportStickerPackUI/Sources/ImportStickerPackControllerNode.swift b/submodules/ImportStickerPackUI/Sources/ImportStickerPackControllerNode.swift index 5e0010ada7..e84e2685b1 100644 --- a/submodules/ImportStickerPackUI/Sources/ImportStickerPackControllerNode.swift +++ b/submodules/ImportStickerPackUI/Sources/ImportStickerPackControllerNode.swift @@ -694,10 +694,7 @@ final class ImportStickerPackControllerNode: ViewControllerTracingNode, UIScroll } } } - }, error: { [weak self] error in - if let strongSelf = self { - - } + }, error: { _ in })) } diff --git a/submodules/ImportStickerPackUI/Sources/ImportStickerPackTitleController.swift b/submodules/ImportStickerPackUI/Sources/ImportStickerPackTitleController.swift index 1b3ce7f95f..9ffc1207f0 100644 --- a/submodules/ImportStickerPackUI/Sources/ImportStickerPackTitleController.swift +++ b/submodules/ImportStickerPackUI/Sources/ImportStickerPackTitleController.swift @@ -105,7 +105,7 @@ private class TextField: UITextField, UIScrollViewDelegate { } func selectWhole() { - guard let scrollView = self.scrollView else { + guard let _ = self.scrollView else { return } // if scrollView.contentSize.width > scrollView.frame.width - scrollView.contentInset.left { @@ -813,7 +813,7 @@ func importStickerPackShortNameController(context: AccountContext, title: String contentNode?.inputFieldNode.updateTheme(presentationData.theme) }) let checkDisposable = MetaDisposable() - var value = value ?? "" + let value = value ?? "" contentNode.actionNodes.last?.actionEnabled = !value.isEmpty if !value.isEmpty { Queue.mainQueue().after(0.25) { diff --git a/submodules/InstantPageCache/BUILD b/submodules/InstantPageCache/BUILD index 1dd01739ff..101fd0f887 100644 --- a/submodules/InstantPageCache/BUILD +++ b/submodules/InstantPageCache/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/TelegramCore:TelegramCore", "//submodules/Postbox:Postbox", diff --git a/submodules/InstantPageUI/BUILD b/submodules/InstantPageUI/BUILD index 1a19aa0ed7..75a726f91c 100644 --- a/submodules/InstantPageUI/BUILD +++ b/submodules/InstantPageUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/InstantPageUI/Sources/InstantPageContentNode.swift b/submodules/InstantPageUI/Sources/InstantPageContentNode.swift index 30026bb0e6..ca5bf723df 100644 --- a/submodules/InstantPageUI/Sources/InstantPageContentNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageContentNode.swift @@ -179,7 +179,7 @@ final class InstantPageContentNode : ASDisplayNode { var itemNode = self.visibleItemsWithNodes[itemIndex] if let currentItemNode = itemNode { if !item.matchesNode(currentItemNode) { - (currentItemNode as! ASDisplayNode).removeFromSupernode() + currentItemNode.removeFromSupernode() self.visibleItemsWithNodes.removeValue(forKey: itemIndex) itemNode = nil } @@ -221,9 +221,9 @@ final class InstantPageContentNode : ASDisplayNode { } } } else { - if (itemNode as! ASDisplayNode).frame != itemFrame { - transition.updateFrame(node: (itemNode as! ASDisplayNode), frame: itemFrame) - itemNode?.updateLayout(size: itemFrame.size, transition: transition) + if let itemNode = itemNode, itemNode.frame != itemFrame { + transition.updateFrame(node: itemNode, frame: itemFrame) + itemNode.updateLayout(size: itemFrame.size, transition: transition) } } @@ -279,9 +279,9 @@ final class InstantPageContentNode : ASDisplayNode { for (index, itemNode) in self.visibleItemsWithNodes { if !visibleItemIndices.contains(index) { removeItemIndices.append(index) - (itemNode as! ASDisplayNode).removeFromSupernode() + itemNode.removeFromSupernode() } else { - var itemFrame = (itemNode as! ASDisplayNode).frame + var itemFrame = itemNode.frame let itemThreshold: CGFloat = 200.0 itemFrame.origin.y -= itemThreshold itemFrame.size.height += itemThreshold * 2.0 diff --git a/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift b/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift index e032ada47b..a2ae752fe6 100644 --- a/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift @@ -544,7 +544,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate { var itemNode = self.visibleItemsWithNodes[itemIndex] if let currentItemNode = itemNode { if !item.matchesNode(currentItemNode) { - (currentItemNode as! ASDisplayNode).removeFromSupernode() + currentItemNode.removeFromSupernode() self.visibleItemsWithNodes.removeValue(forKey: itemIndex) itemNode = nil } @@ -619,9 +619,9 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate { } } } else { - if (itemNode as! ASDisplayNode).frame != itemFrame { - transition.updateFrame(node: (itemNode as! ASDisplayNode), frame: itemFrame) - itemNode?.updateLayout(size: itemFrame.size, transition: transition) + if let itemNode = itemNode, itemNode.frame != itemFrame { + transition.updateFrame(node: itemNode, frame: itemFrame) + itemNode.updateLayout(size: itemFrame.size, transition: transition) } } @@ -689,9 +689,9 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate { for (index, itemNode) in self.visibleItemsWithNodes { if !visibleItemIndices.contains(index) { removeItemIndices.append(index) - (itemNode as! ASDisplayNode).removeFromSupernode() + itemNode.removeFromSupernode() } else { - var itemFrame = (itemNode as! ASDisplayNode).frame + var itemFrame = itemNode.frame let itemThreshold: CGFloat = 200.0 itemFrame.origin.y -= itemThreshold itemFrame.size.height += itemThreshold * 2.0 @@ -725,7 +725,6 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate { } let bounds = self.scrollNode.view.bounds - let contentOffset = self.scrollNode.view.contentOffset let maxBarHeight: CGFloat let minBarHeight: CGFloat @@ -741,7 +740,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate { minBarHeight = 20.0 } - var transition: ContainedViewLayoutTransition = .immediate + let transition: ContainedViewLayoutTransition = .immediate var navigationBarFrame = self.navigationBar.frame navigationBarFrame.size.width = bounds.size.width if navigationBarFrame.size.height.isZero { diff --git a/submodules/InstantPageUI/Sources/InstantPageLayout.swift b/submodules/InstantPageUI/Sources/InstantPageLayout.swift index a802fc10a2..4f157f5e4f 100644 --- a/submodules/InstantPageUI/Sources/InstantPageLayout.swift +++ b/submodules/InstantPageUI/Sources/InstantPageLayout.swift @@ -251,7 +251,7 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins let (textItem, textItems, textItemSize) = layoutTextItemWithString(attributedStringForRichText(text, styleStack: styleStack), boundingWidth: boundingWidth - horizontalInset * 2.0 - indexSpacing - maxIndexWidth, offset: CGPoint(x: horizontalInset + indexSpacing + maxIndexWidth, y: contentSize.height), media: media, webpage: webpage) contentSize.height += textItemSize.height - var indexItem = indexItems[i] + let indexItem = indexItems[i] var itemFrame = indexItem.frame var lineMidY: CGFloat = 0.0 @@ -286,7 +286,7 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins contentSize.height += subLayout.contentSize.height + spacing previousBlock = subBlock } - var indexItem = indexItems[i] + let indexItem = indexItems[i] var indexItemFrame = indexItem.frame if let textIndexItem = indexItem as? InstantPageTextItem, let line = textIndexItem.lines.first { indexItemFrame = indexItemFrame.offsetBy(dx: horizontalInset + maxIndexWidth - line.frame.width, dy: originY) @@ -412,7 +412,7 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins } else { return InstantPageLayout(origin: CGPoint(), contentSize: CGSize(), items: []) } - case let .video(id, caption, autoplay, loop): + case let .video(id, caption, autoplay, _): if let file = media[id] as? TelegramMediaFile, let dimensions = file.dimensions { let imageSize = dimensions var filledSize = imageSize.cgSize.aspectFitted(CGSize(width: boundingWidth - safeInset * 2.0, height: 1200.0)) @@ -489,7 +489,7 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins contentSize.height += captionSize.height return InstantPageLayout(origin: CGPoint(), contentSize: contentSize, items: items) - case let .postEmbed(url, webpageId, avatarId, author, date, blocks, caption): + case let .postEmbed(_, _, avatarId, author, date, blocks, caption): var contentSize = CGSize(width: boundingWidth, height: 0.0) let lineInset: CGFloat = 20.0 let verticalInset: CGFloat = 4.0 diff --git a/submodules/InstantPageUI/Sources/InstantPageScrollableNode.swift b/submodules/InstantPageUI/Sources/InstantPageScrollableNode.swift index ab221dac9f..30c1239ee8 100644 --- a/submodules/InstantPageUI/Sources/InstantPageScrollableNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageScrollableNode.swift @@ -6,7 +6,7 @@ import Postbox import Display import TelegramPresentationData -protocol InstantPageScrollableItem: class, InstantPageItem { +protocol InstantPageScrollableItem: AnyObject, InstantPageItem { var contentSize: CGSize { get } var horizontalInset: CGFloat { get } var isRTL: Bool { get } diff --git a/submodules/InstantPageUI/Sources/InstantPageSlideshowItemNode.swift b/submodules/InstantPageUI/Sources/InstantPageSlideshowItemNode.swift index 72b85c6bb2..a45ee2f1eb 100644 --- a/submodules/InstantPageUI/Sources/InstantPageSlideshowItemNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageSlideshowItemNode.swift @@ -183,7 +183,7 @@ private final class InstantPageSlideshowPagerNode: ASDisplayNode, UIScrollViewDe let contentNode: ASDisplayNode if let _ = media.media as? TelegramMediaImage { contentNode = InstantPageImageNode(context: self.context, sourcePeerType: self.sourcePeerType, theme: self.theme, webPage: self.webPage, media: media, attributes: [], interactive: true, roundCorners: false, fit: false, openMedia: self.openMedia, longPressMedia: self.longPressMedia, activatePinchPreview: nil, pinchPreviewFinished: nil) - } else if let file = media.media as? TelegramMediaFile { + } else if let _ = media.media as? TelegramMediaFile { contentNode = ASDisplayNode() } else { contentNode = ASDisplayNode() @@ -233,7 +233,7 @@ private final class InstantPageSlideshowPagerNode: ASDisplayNode, UIScrollViewDe if self.itemNodes.isEmpty { let node = self.makeNodeForItem(at: self.centralItemIndex ?? 0) node.frame = CGRect(origin: CGPoint(), size: scrollView.bounds.size) - if let containerLayout = self.containerLayout { + if let _ = self.containerLayout { //node.containerLayoutUpdated(containerLayout.0, navigationBarHeight: containerLayout.1, transition: .immediate) } self.addVisibleItemNode(node) @@ -248,7 +248,7 @@ private final class InstantPageSlideshowPagerNode: ASDisplayNode, UIScrollViewDe if self.visibleItemNode(at: centralItemIndex - 1) == nil { let node = self.makeNodeForItem(at: centralItemIndex - 1) node.frame = centralItemNode.frame.offsetBy(dx: -centralItemNode.frame.size.width - self.pageGap, dy: 0.0) - if let containerLayout = self.containerLayout { + if let _ = self.containerLayout { //node.containerLayoutUpdated(containerLayout.0, navigationBarHeight: containerLayout.1, transition: .immediate) } self.addVisibleItemNode(node) @@ -259,7 +259,7 @@ private final class InstantPageSlideshowPagerNode: ASDisplayNode, UIScrollViewDe if self.visibleItemNode(at: centralItemIndex + 1) == nil { let node = self.makeNodeForItem(at: centralItemIndex + 1) node.frame = centralItemNode.frame.offsetBy(dx: centralItemNode.frame.size.width + self.pageGap, dy: 0.0) - if let containerLayout = self.containerLayout { + if let _ = self.containerLayout { //node.containerLayoutUpdated(containerLayout.0, navigationBarHeight: containerLayout.1, transition: .immediate) } self.addVisibleItemNode(node) @@ -291,7 +291,7 @@ private final class InstantPageSlideshowPagerNode: ASDisplayNode, UIScrollViewDe if self.visibleItemNode(at: centralItemCandidateNode.index - 1) == nil { let node = self.makeNodeForItem(at: centralItemCandidateNode.index - 1) node.frame = centralItemCandidateNode.frame.offsetBy(dx: -centralItemCandidateNode.frame.size.width - self.pageGap, dy: 0.0) - if let containerLayout = self.containerLayout { + if let _ = self.containerLayout { //node.containerLayoutUpdated(containerLayout.0, navigationBarHeight: containerLayout.1, transition: .immediate) } self.addVisibleItemNode(node) @@ -302,7 +302,7 @@ private final class InstantPageSlideshowPagerNode: ASDisplayNode, UIScrollViewDe if self.visibleItemNode(at: centralItemCandidateNode.index + 1) == nil { let node = self.makeNodeForItem(at: centralItemCandidateNode.index + 1) node.frame = centralItemCandidateNode.frame.offsetBy(dx: centralItemCandidateNode.frame.size.width + self.pageGap, dy: 0.0) - if let containerLayout = self.containerLayout { + if let _ = self.containerLayout { //node.containerLayoutUpdated(containerLayout.0, navigationBarHeight: containerLayout.1, transition: .immediate) } self.addVisibleItemNode(node) diff --git a/submodules/InstantPageUI/Sources/InstantPageSubContentNode.swift b/submodules/InstantPageUI/Sources/InstantPageSubContentNode.swift index 15312dfe68..278a7d6875 100644 --- a/submodules/InstantPageUI/Sources/InstantPageSubContentNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageSubContentNode.swift @@ -179,7 +179,7 @@ final class InstantPageSubContentNode : ASDisplayNode { var itemNode = self.visibleItemsWithNodes[itemIndex] if let currentItemNode = itemNode { if !item.matchesNode(currentItemNode) { - (currentItemNode as! ASDisplayNode).removeFromSupernode() + currentItemNode.removeFromSupernode() self.visibleItemsWithNodes.removeValue(forKey: itemIndex) itemNode = nil } @@ -218,9 +218,9 @@ final class InstantPageSubContentNode : ASDisplayNode { } } } else { - if (itemNode as! ASDisplayNode).frame != itemFrame { - transition.updateFrame(node: (itemNode as! ASDisplayNode), frame: itemFrame) - itemNode?.updateLayout(size: itemFrame.size, transition: transition) + if let itemNode = itemNode, itemNode.frame != itemFrame { + transition.updateFrame(node: itemNode, frame: itemFrame) + itemNode.updateLayout(size: itemFrame.size, transition: transition) } } @@ -276,9 +276,9 @@ final class InstantPageSubContentNode : ASDisplayNode { for (index, itemNode) in self.visibleItemsWithNodes { if !visibleItemIndices.contains(index) { removeItemIndices.append(index) - (itemNode as! ASDisplayNode).removeFromSupernode() + itemNode.removeFromSupernode() } else { - var itemFrame = (itemNode as! ASDisplayNode).frame + var itemFrame = itemNode.frame let itemThreshold: CGFloat = 200.0 itemFrame.origin.y -= itemThreshold itemFrame.size.height += itemThreshold * 2.0 diff --git a/submodules/InviteLinksUI/BUILD b/submodules/InviteLinksUI/BUILD index e2a50b05fe..3e7f32d48a 100644 --- a/submodules/InviteLinksUI/BUILD +++ b/submodules/InviteLinksUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift b/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift index 702b661f9f..eeb6996255 100644 --- a/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift +++ b/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift @@ -736,7 +736,6 @@ public final class InviteLinkInviteController: ViewController { let rawControlsOffset = offset + listTopInset - controlsHeight let controlsOffset = max(layoutTopInset, rawControlsOffset) - let isOverscrolling = rawControlsOffset <= layoutTopInset let controlsFrame = CGRect(origin: CGPoint(x: 0.0, y: controlsOffset), size: CGSize(width: validLayout.size.width, height: controlsHeight)) let previousFrame = self.headerNode.frame diff --git a/submodules/InviteLinksUI/Sources/InviteLinkViewController.swift b/submodules/InviteLinksUI/Sources/InviteLinkViewController.swift index 0e48540ffd..32adcc7444 100644 --- a/submodules/InviteLinksUI/Sources/InviteLinkViewController.swift +++ b/submodules/InviteLinksUI/Sources/InviteLinkViewController.swift @@ -979,7 +979,6 @@ public final class InviteLinkViewController: ViewController { let rawControlsOffset = offset + listTopInset - controlsHeight let controlsOffset = max(layoutTopInset, rawControlsOffset) - let isOverscrolling = rawControlsOffset <= layoutTopInset let controlsFrame = CGRect(origin: CGPoint(x: 0.0, y: controlsOffset), size: CGSize(width: validLayout.size.width, height: controlsHeight)) let previousFrame = self.headerNode.frame diff --git a/submodules/InviteLinksUI/Sources/ItemListDatePickerItem.swift b/submodules/InviteLinksUI/Sources/ItemListDatePickerItem.swift index a67088f9a8..fb9fe12d82 100644 --- a/submodules/InviteLinksUI/Sources/ItemListDatePickerItem.swift +++ b/submodules/InviteLinksUI/Sources/ItemListDatePickerItem.swift @@ -123,7 +123,6 @@ public class ItemListDatePickerItemNode: ListViewItemNode, ItemListItemNode { let itemSeparatorColor: UIColor let leftInset = 16.0 + params.leftInset - let rightInset = 16.0 + params.rightInset let width = min(390.0, params.width - params.leftInset - params.rightInset) let cellSize = floor((width - 12.0 * 2.0) / 7.0) diff --git a/submodules/ItemListAddressItem/BUILD b/submodules/ItemListAddressItem/BUILD index 76423972ee..590b8aaa22 100644 --- a/submodules/ItemListAddressItem/BUILD +++ b/submodules/ItemListAddressItem/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ItemListAvatarAndNameInfoItem/BUILD b/submodules/ItemListAvatarAndNameInfoItem/BUILD index 609528ece4..dbf1c6e68d 100644 --- a/submodules/ItemListAvatarAndNameInfoItem/BUILD +++ b/submodules/ItemListAvatarAndNameInfoItem/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift b/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift index 3a8c99113e..daff7c21dd 100644 --- a/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift +++ b/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift @@ -48,7 +48,7 @@ public enum ItemListAvatarAndNameInfoItemName: Equatable { public var composedTitle: String { switch self { - case let .personName(firstName, lastName, phone): + case let .personName(firstName, lastName, _): if !firstName.isEmpty && !lastName.isEmpty { return firstName + " " + lastName } else if !firstName.isEmpty { @@ -77,16 +77,6 @@ public enum ItemListAvatarAndNameInfoItemName: Equatable { } else { return strings.User_DeletedAccount } - - if !firstName.isEmpty && !lastName.isEmpty { - return firstName + " " + lastName - } else if !firstName.isEmpty { - return firstName - } else if !lastName.isEmpty { - return lastName - } else { - return strings.User_DeletedAccount - } case let .title(title, _): return title } diff --git a/submodules/ItemListPeerActionItem/BUILD b/submodules/ItemListPeerActionItem/BUILD index 76e9eece2a..520700b146 100644 --- a/submodules/ItemListPeerActionItem/BUILD +++ b/submodules/ItemListPeerActionItem/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ItemListPeerItem/BUILD b/submodules/ItemListPeerItem/BUILD index 9d3ee832e8..82417c0e2f 100644 --- a/submodules/ItemListPeerItem/BUILD +++ b/submodules/ItemListPeerItem/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ItemListStickerPackItem/BUILD b/submodules/ItemListStickerPackItem/BUILD index 254167a8b7..5752bd50bc 100644 --- a/submodules/ItemListStickerPackItem/BUILD +++ b/submodules/ItemListStickerPackItem/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ItemListStickerPackItem/Sources/ItemListStickerPackItem.swift b/submodules/ItemListStickerPackItem/Sources/ItemListStickerPackItem.swift index 514e53971a..2b090b5ecc 100644 --- a/submodules/ItemListStickerPackItem/Sources/ItemListStickerPackItem.swift +++ b/submodules/ItemListStickerPackItem/Sources/ItemListStickerPackItem.swift @@ -643,7 +643,7 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode { strongSelf.selectionIconNode.image = image strongSelf.selectionIconNode.frame = CGRect(origin: CGPoint(x: params.width - params.rightInset - image.size.width - floor((44.0 - image.size.width) / 2.0), y: floor((contentSize.height - image.size.height) / 2.0)), size: image.size) } - case let .check(checked): + case .check: strongSelf.installationActionNode.isHidden = true strongSelf.installationActionImageNode.isHidden = true strongSelf.selectionIconNode.isHidden = true diff --git a/submodules/ItemListUI/BUILD b/submodules/ItemListUI/BUILD index 9a38bf8d03..af5616e0d6 100644 --- a/submodules/ItemListUI/BUILD +++ b/submodules/ItemListUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ItemListUI/Sources/ItemListControllerNode.swift b/submodules/ItemListUI/Sources/ItemListControllerNode.swift index 47124521f3..31aa4eda42 100644 --- a/submodules/ItemListUI/Sources/ItemListControllerNode.swift +++ b/submodules/ItemListUI/Sources/ItemListControllerNode.swift @@ -7,7 +7,7 @@ import TelegramCore import TelegramPresentationData import MergeLists -public protocol ItemListHeaderItemNode: class { +public protocol ItemListHeaderItemNode: AnyObject { func updateTheme(theme: PresentationTheme) } diff --git a/submodules/ItemListVenueItem/BUILD b/submodules/ItemListVenueItem/BUILD index 622c8270aa..27c0645443 100644 --- a/submodules/ItemListVenueItem/BUILD +++ b/submodules/ItemListVenueItem/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/JoinLinkPreviewUI/BUILD b/submodules/JoinLinkPreviewUI/BUILD index b94598cc1b..9524625964 100644 --- a/submodules/JoinLinkPreviewUI/BUILD +++ b/submodules/JoinLinkPreviewUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/LanguageLinkPreviewUI/BUILD b/submodules/LanguageLinkPreviewUI/BUILD index 4e08005b17..7dbed7278d 100644 --- a/submodules/LanguageLinkPreviewUI/BUILD +++ b/submodules/LanguageLinkPreviewUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/LanguageSuggestionUI/BUILD b/submodules/LanguageSuggestionUI/BUILD index 9b716eb7d0..b2e31d19ab 100644 --- a/submodules/LanguageSuggestionUI/BUILD +++ b/submodules/LanguageSuggestionUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + "-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/LanguageSuggestionUI/Sources/LanguageSuggestionController.swift b/submodules/LanguageSuggestionUI/Sources/LanguageSuggestionController.swift index 43607c18e5..06632d40d4 100644 --- a/submodules/LanguageSuggestionUI/Sources/LanguageSuggestionController.swift +++ b/submodules/LanguageSuggestionUI/Sources/LanguageSuggestionController.swift @@ -334,7 +334,6 @@ public func languageSuggestionController(context: AccountContext, suggestedLocal } let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let theme = context.sharedContext.presentationData let strings = LanguageSuggestionControllerStrings(localization: suggestedLocalization) guard let mainPath = getAppBundle().path(forResource: "en", ofType: "lproj") else { return nil diff --git a/submodules/LegacyMediaPickerUI/Sources/LegacyMediaPickers.swift b/submodules/LegacyMediaPickerUI/Sources/LegacyMediaPickers.swift index a5ba83eb74..1ada13b310 100644 --- a/submodules/LegacyMediaPickerUI/Sources/LegacyMediaPickers.swift +++ b/submodules/LegacyMediaPickerUI/Sources/LegacyMediaPickers.swift @@ -394,7 +394,7 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) - attributes.append(AutoremoveTimeoutMessageAttribute(timeout: Int32(timer), countdownBeginTime: nil)) } - var text = caption ?? "" + let text = caption ?? "" messages.append(LegacyAssetPickerEnqueueMessage(message: .message(text: text, attributes: attributes, mediaReference: .standalone(media: media), replyToMessageId: nil, localGroupingKey: item.groupedId, correlationId: nil), uniqueId: item.uniqueId)) } } diff --git a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h index 945d11ae6d..891eab4a7b 100644 --- a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h +++ b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h @@ -24,3 +24,5 @@ typedef enum { - (void)setClass:(Class)newClass; @end + +SEL _Nonnull makeSelectorFromString(NSString * _Nonnull string); diff --git a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m index 44d2c8830f..060faf64d0 100644 --- a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m +++ b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m @@ -122,3 +122,7 @@ static Class freedomMakeClass(Class superclass, Class subclass, SEL *copySelecto } @end + +SEL _Nonnull makeSelectorFromString(NSString * _Nonnull string) { + return NSSelectorFromString(string); +} diff --git a/submodules/Postbox/Sources/Message.swift b/submodules/Postbox/Sources/Message.swift index 37608f64bd..ae09e04b3f 100644 --- a/submodules/Postbox/Sources/Message.swift +++ b/submodules/Postbox/Sources/Message.swift @@ -38,6 +38,22 @@ public struct MessageId: Hashable, Comparable, CustomStringConvertible, PostboxC buffer.offset += 16 } + + private init(bytes: UnsafePointer, offset: inout Int) { + var peerIdInt64Value: Int64 = 0 + memcpy(&peerIdInt64Value, bytes.advanced(by: offset), 8) + + self.peerId = PeerId(peerIdInt64Value) + + var namespaceValue: Int32 = 0 + memcpy(&namespaceValue, bytes.advanced(by: offset + 8), 4) + self.namespace = namespaceValue + var idValue: Int32 = 0 + memcpy(&idValue, bytes.advanced(by: offset + 12), 4) + self.id = idValue + + offset += 16 + } public init(decoder: PostboxDecoder) { self.peerId = PeerId(decoder.decodeInt64ForKey("p", orElse: 0)) @@ -59,6 +75,15 @@ public struct MessageId: Hashable, Comparable, CustomStringConvertible, PostboxC buffer.write(&namespace, offset: 0, length: 4) buffer.write(&id, offset: 0, length: 4) } + + public func encodeToData(_ data: inout Data) { + var peerIdValue = self.peerId.toInt64() + var namespace = self.namespace + var id = self.id + data.append(Data(bytesNoCopy: &peerIdValue, count: 8, deallocator: .none)) + data.append(Data(bytesNoCopy: &namespace, count: 4, deallocator: .none)) + data.append(Data(bytesNoCopy: &id, count: 4, deallocator: .none)) + } public static func encodeArrayToBuffer(_ array: [MessageId], buffer: WriteBuffer) { var length: Int32 = Int32(array.count) @@ -67,6 +92,16 @@ public struct MessageId: Hashable, Comparable, CustomStringConvertible, PostboxC id.encodeToBuffer(buffer) } } + + public static func encodeArrayToData(_ array: [MessageId]) -> Data { + var result = Data() + var length: Int32 = Int32(array.count) + result.append(Data(bytesNoCopy: &length, count: 4, deallocator: .none)) + for id in array { + id.encodeToData(&result) + } + return result + } public static func decodeArrayFromBuffer(_ buffer: ReadBuffer) -> [MessageId] { var length: Int32 = 0 @@ -81,6 +116,25 @@ public struct MessageId: Hashable, Comparable, CustomStringConvertible, PostboxC return array } + public static func decodeArrayFromData(_ data: Data) -> [MessageId] { + return data.withUnsafeBytes { bytes -> [MessageId] in + guard let baseAddress = bytes.baseAddress?.assumingMemoryBound(to: UInt8.self) else { + return [] + } + var offset = 0 + var length: Int32 = 0 + memcpy(&length, baseAddress, 4) + offset += 4 + var i = 0 + var array: [MessageId] = [] + while i < Int(length) { + array.append(MessageId(bytes: baseAddress, offset: &offset)) + i += 1 + } + return array + } + } + public static func <(lhs: MessageId, rhs: MessageId) -> Bool { if lhs.namespace == rhs.namespace { if lhs.id == rhs.id { diff --git a/submodules/ShareController/Sources/ShareControllerPeerGridItem.swift b/submodules/ShareController/Sources/ShareControllerPeerGridItem.swift index 596e2c2231..9e826af425 100644 --- a/submodules/ShareController/Sources/ShareControllerPeerGridItem.swift +++ b/submodules/ShareController/Sources/ShareControllerPeerGridItem.swift @@ -178,7 +178,7 @@ final class ShareControllerPeerGridItemNode: GridItemNode { let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970) var online = false if let peer = peer?.peer as? TelegramUser, let presence = presence as? TelegramUserPresence, !isServicePeer(peer) && !peer.flags.contains(.isSupport) && peer.id != context.account.peerId { - let relativeStatus = relativeUserPresenceStatus(presence, relativeTo: timestamp) + let relativeStatus = relativeUserPresenceStatus(EnginePeer.Presence(presence), relativeTo: timestamp) if case .online = relativeStatus { online = true } diff --git a/submodules/ShareController/Sources/ShareControllerRecentPeersGridItem.swift b/submodules/ShareController/Sources/ShareControllerRecentPeersGridItem.swift index b0f39917d7..6f395eee22 100644 --- a/submodules/ShareController/Sources/ShareControllerRecentPeersGridItem.swift +++ b/submodules/ShareController/Sources/ShareControllerRecentPeersGridItem.swift @@ -61,7 +61,7 @@ final class ShareControllerRecentPeersGridItemNode: GridItemNode { peersNode.updateThemeAndStrings(theme: theme, strings: strings) } else { peersNode = ChatListSearchRecentPeersNode(context: context, theme: theme, mode: .actionSheet, strings: strings, peerSelected: { [weak self] peer in - self?.controllerInteraction?.togglePeer(RenderedPeer(peer: peer), true) + self?.controllerInteraction?.togglePeer(RenderedPeer(peer: peer._asPeer()), true) }, peerContextAction: { _, _, gesture in gesture?.cancel() }, isPeerSelected: { [weak self] peerId in return self?.controllerInteraction?.selectedPeerIds.contains(peerId) ?? false }, share: true) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift index 155f60a7bd..501c75e0f1 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift @@ -132,6 +132,16 @@ public extension EnginePeer { var isVerified: Bool { return self._asPeer().isVerified } + + var isService: Bool { + if case let .user(peer) = self { + if peer.id.isReplies { + return true + } + return (peer.id.namespace == Namespaces.Peer.CloudUser && (peer.id.id._internalGetInt32Value() == 777000 || peer.id.id._internalGetInt32Value() == 333000)) + } + return false + } } public extension EnginePeer { diff --git a/submodules/TelegramCore/Sources/Utils/Coding.swift b/submodules/TelegramCore/Sources/Utils/Coding.swift new file mode 100644 index 0000000000..e6770f323f --- /dev/null +++ b/submodules/TelegramCore/Sources/Utils/Coding.swift @@ -0,0 +1,14 @@ +import Foundation +import Postbox + +public final class EngineEncoder { + public static func encode(_ value: Encodable) throws -> Data { + return try AdaptedPostboxEncoder().encode(value) + } +} + +public final class EngineDecoder { + public static func decode(_ type: T.Type, from data: Data) throws -> T where T : Decodable { + return try AdaptedPostboxDecoder().decode(type, from: data) + } +} diff --git a/submodules/TelegramStringFormatting/Sources/PresenceStrings.swift b/submodules/TelegramStringFormatting/Sources/PresenceStrings.swift index 6621d58bad..edf9e67ab2 100644 --- a/submodules/TelegramStringFormatting/Sources/PresenceStrings.swift +++ b/submodules/TelegramStringFormatting/Sources/PresenceStrings.swift @@ -1,5 +1,4 @@ import Foundation -import Postbox import TelegramCore import TelegramPresentationData @@ -222,9 +221,9 @@ public enum RelativeUserPresenceStatus { case lastMonth } -public func relativeUserPresenceStatus(_ presence: TelegramUserPresence, relativeTo timestamp: Int32) -> RelativeUserPresenceStatus { +public func relativeUserPresenceStatus(_ presence: EnginePeer.Presence, relativeTo timestamp: Int32) -> RelativeUserPresenceStatus { switch presence.status { - case .none: + case .longTimeAgo: return .offline case let .present(statusTimestamp): if statusTimestamp >= timestamp { diff --git a/submodules/TelegramUI/Sources/ChatTitleView.swift b/submodules/TelegramUI/Sources/ChatTitleView.swift index 20e097103e..d46fc70974 100644 --- a/submodules/TelegramUI/Sources/ChatTitleView.swift +++ b/submodules/TelegramUI/Sources/ChatTitleView.swift @@ -420,7 +420,7 @@ final class ChatTitleView: UIView, NavigationBarTitleView { let timestamp = CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970 for participant in participants.participants { if let presence = peerView.peerPresences[participant.peerId] as? TelegramUserPresence { - let relativeStatus = relativeUserPresenceStatus(presence, relativeTo: Int32(timestamp)) + let relativeStatus = relativeUserPresenceStatus(EnginePeer.Presence(presence), relativeTo: Int32(timestamp)) switch relativeStatus { case .online: onlineCount += 1 diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoData.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoData.swift index 8b148d38de..676828b575 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoData.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoData.swift @@ -724,7 +724,7 @@ func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: Presen let timestamp = CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970 for participant in participants.participants { if let presence = peerView.peerPresences[participant.peerId] as? TelegramUserPresence { - let relativeStatus = relativeUserPresenceStatus(presence, relativeTo: Int32(timestamp)) + let relativeStatus = relativeUserPresenceStatus(EnginePeer.Presence(presence), relativeTo: Int32(timestamp)) switch relativeStatus { case .online: onlineCount += 1 diff --git a/submodules/TemporaryCachedPeerDataManager/Sources/PeerChannelMemberCategoriesContextsManager.swift b/submodules/TemporaryCachedPeerDataManager/Sources/PeerChannelMemberCategoriesContextsManager.swift index dade7e25b3..b6b70ca702 100644 --- a/submodules/TemporaryCachedPeerDataManager/Sources/PeerChannelMemberCategoriesContextsManager.swift +++ b/submodules/TemporaryCachedPeerDataManager/Sources/PeerChannelMemberCategoriesContextsManager.swift @@ -522,7 +522,7 @@ public final class PeerChannelMemberCategoriesContextsManager { if let presences = (view.views[key] as? PeerPresencesView)?.presences { for (_, presence) in presences { if let presence = presence as? TelegramUserPresence { - let relativeStatus = relativeUserPresenceStatus(presence, relativeTo: Int32(timestamp)) + let relativeStatus = relativeUserPresenceStatus(EnginePeer.Presence(presence), relativeTo: Int32(timestamp)) switch relativeStatus { case .online: count += 1