From aa2968e76afcc4338e61ca31263db2b0bfc3f764 Mon Sep 17 00:00:00 2001 From: Hsing-Li Chang Date: Sun, 7 Nov 2021 22:19:16 -0600 Subject: [PATCH 1/2] added missing handler --- ChatSDKCore/Classes/Hooks/PHookHandler.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ChatSDKCore/Classes/Hooks/PHookHandler.h b/ChatSDKCore/Classes/Hooks/PHookHandler.h index a46b9bc3..1a9ad41d 100755 --- a/ChatSDKCore/Classes/Hooks/PHookHandler.h +++ b/ChatSDKCore/Classes/Hooks/PHookHandler.h @@ -57,6 +57,7 @@ #define bHookWillPushUser @"bHookWillPushUser" #define bHookUserUpdated @"bHookUserUpdated" +#define bHookUserLastOnlineUpdated @"bHookUserLastOnlineUpdated" #define bHookServerPingFailed @"bHookServerPingFailed" From bf37c6f01d34f57d3ddedb240fc5074149b5afd4 Mon Sep 17 00:00:00 2001 From: Hsing-Li Chang Date: Sun, 7 Nov 2021 23:03:36 -0600 Subject: [PATCH 2/2] removed warnings and updated some deprecated usages --- ChatK!t/ChatSDK/CKFileMessage.swift | 1 - ChatK!t/ChatSDK/CKUser.swift | 14 +++++++------- ChatK!t/ChatSDK/ChatKitModule.swift | 5 +++-- ChatK!t/Core/ChatViewController.swift | 8 ++++---- ChatK!t/Core/Customization/Provider.swift | 2 +- ChatK!t/Core/Entities/Reply.swift | 2 +- ChatK!t/Core/Entities/User.swift | 2 +- .../KeyboardOverlay/RecordKeyboardOverlay.swift | 2 +- .../Core/Message/Content/FileMessageContent.swift | 4 +--- ChatK!t/Core/Message/Content/FileMessageView.swift | 1 - ChatK!t/Core/Message/Model/MessagesModel.swift | 2 +- ChatK!t/Core/Message/View/MessagesView.swift | 2 +- ChatK!t/Core/Message/View/PMessagesView.swift | 2 +- ChatK!t/Core/Toolbar/ChatToolbar.swift | 4 ++-- ChatK!t/Core/Utils/DownloadManager.swift | 4 ++-- ChatK!t/Core/Views/ReconnectingView.swift | 4 ++-- 16 files changed, 28 insertions(+), 31 deletions(-) diff --git a/ChatK!t/ChatSDK/CKFileMessage.swift b/ChatK!t/ChatSDK/CKFileMessage.swift index 12792423..4723307f 100644 --- a/ChatK!t/ChatSDK/CKFileMessage.swift +++ b/ChatK!t/ChatSDK/CKFileMessage.swift @@ -6,7 +6,6 @@ // import Foundation -import ChatKit import ChatSDK public class CKFileMessage: CKDownloadableMessage { diff --git a/ChatK!t/ChatSDK/CKUser.swift b/ChatK!t/ChatSDK/CKUser.swift index 9093fd51..09756c9b 100644 --- a/ChatK!t/ChatSDK/CKUser.swift +++ b/ChatK!t/ChatSDK/CKUser.swift @@ -44,13 +44,13 @@ open class CKUser: User { } open func userLastOnline() -> Date? { - if let module = BChatSDK.lastOnline() { - if let date = module.lastOnline(for: user) { - return date - } else { - module.getLastOnline(for: user) - } - } +// if let module = BChatSDK.lastOnline() { +// if let date = module.lastOnline(for: user) { +// return date +// } else { +// module.getLastOnline(for: user) +// } +// } return nil } diff --git a/ChatK!t/ChatSDK/ChatKitModule.swift b/ChatK!t/ChatSDK/ChatKitModule.swift index 4b99824c..aa9d81c2 100644 --- a/ChatK!t/ChatSDK/ChatKitModule.swift +++ b/ChatK!t/ChatSDK/ChatKitModule.swift @@ -418,7 +418,7 @@ open class ChatKitIntegration: NSObject, ChatViewControllerDelegate, ChatModelDe open func viewWillAppear() { BChatSDK.ui().setLocalNotificationHandler({ [weak self] thread in if let thread = thread { - var enable = BLocalNotificationHandler().showLocalNotification(thread) + let enable = BLocalNotificationHandler().showLocalNotification(thread) if enable, let current = self?.thread, thread.entityID() != current.entityID() { return true } @@ -433,7 +433,8 @@ open class ChatKitIntegration: NSObject, ChatViewControllerDelegate, ChatModelDe open func viewDidAppear() { if let thread = thread { if thread.typeIs(bThreadFilterPublic) { - BChatSDK.thread().addUsers([BChatSDK.currentUser()], to: thread) + guard let currentUser = BChatSDK.currentUser() else { return } + BChatSDK.thread().addUsers([currentUser], to: thread) } } } diff --git a/ChatK!t/Core/ChatViewController.swift b/ChatK!t/Core/ChatViewController.swift index b47eb5ee..061bedc5 100644 --- a/ChatK!t/Core/ChatViewController.swift +++ b/ChatK!t/Core/ChatViewController.swift @@ -14,12 +14,12 @@ import AudioToolbox // func add(message: Message) //} -public protocol ChatViewControllerTypingDelegate: class { +public protocol ChatViewControllerTypingDelegate: AnyObject { func didStartTyping() func didStopTyping() } -public protocol ChatViewControllerDelegate: class { +public protocol ChatViewControllerDelegate: AnyObject { func viewDidLoad() func viewWillAppear() func viewDidAppear() @@ -368,8 +368,8 @@ open class ChatViewController: UIViewController { updateNavigationBar() } - open func updateConnectionStatus(_ status: ConnectionStatus? = .none) { - if status == .none { + open func updateConnectionStatus(_ status: ConnectionStatus? = Optional.none) { + if status == Optional.none { updateNavigationBar(reconnecting: false) } reconnectingView.update(status) diff --git a/ChatK!t/Core/Customization/Provider.swift b/ChatK!t/Core/Customization/Provider.swift index cc9f3c44..e3f6b2b7 100644 --- a/ChatK!t/Core/Customization/Provider.swift +++ b/ChatK!t/Core/Customization/Provider.swift @@ -19,7 +19,7 @@ open class Provider { open func makeBackground(blur: Bool = true, effect: UIBlurEffect? = nil) -> UIView { if blur { - var background: UIVisualEffectView = UIVisualEffectView(effect: effect ?? UIBlurEffect(style: .systemThinMaterial)) + let background: UIVisualEffectView = UIVisualEffectView(effect: effect ?? UIBlurEffect(style: .systemThinMaterial)) background.autoresizingMask = [.flexibleWidth, .flexibleHeight] return background } else { diff --git a/ChatK!t/Core/Entities/Reply.swift b/ChatK!t/Core/Entities/Reply.swift index 457b5f1d..69dad0a8 100644 --- a/ChatK!t/Core/Entities/Reply.swift +++ b/ChatK!t/Core/Entities/Reply.swift @@ -7,7 +7,7 @@ import Foundation -public protocol Reply : class { +public protocol Reply : AnyObject { func replyTitle() -> String? func replyText() -> String? func replyImageURL() -> URL? diff --git a/ChatK!t/Core/Entities/User.swift b/ChatK!t/Core/Entities/User.swift index 4c6c6517..c2f8d8d4 100644 --- a/ChatK!t/Core/Entities/User.swift +++ b/ChatK!t/Core/Entities/User.swift @@ -7,7 +7,7 @@ import Foundation -public protocol User : class { +public protocol User : AnyObject { func userId() -> String func userName() -> String diff --git a/ChatK!t/Core/KeyboardOverlay/RecordKeyboardOverlay.swift b/ChatK!t/Core/KeyboardOverlay/RecordKeyboardOverlay.swift index a78dbc4b..13834213 100644 --- a/ChatK!t/Core/KeyboardOverlay/RecordKeyboardOverlay.swift +++ b/ChatK!t/Core/KeyboardOverlay/RecordKeyboardOverlay.swift @@ -49,7 +49,7 @@ open class RecordKeyboardOverlay: UIView, KeyboardOverlay { } -public protocol RecordViewDelegate: class { +public protocol RecordViewDelegate: AnyObject { func send(audio: Data, duration: Int) } diff --git a/ChatK!t/Core/Message/Content/FileMessageContent.swift b/ChatK!t/Core/Message/Content/FileMessageContent.swift index a845e161..9c146da1 100644 --- a/ChatK!t/Core/Message/Content/FileMessageContent.swift +++ b/ChatK!t/Core/Message/Content/FileMessageContent.swift @@ -6,8 +6,6 @@ // import Foundation -import ChatKit -import ChatSDK open class FileMessageContent: DefaultDownloadableMessageContent, MessageProgressHelperDelegate { @@ -64,7 +62,7 @@ open class FileMessageContent: DefaultDownloadableMessageContent, MessageProgres } } else { - let image = UIImage(named: imageName, in: Bundle(for: FileMessageContent.self), compatibleWith: nil) + image = UIImage(named: imageName, in: Bundle(for: FileMessageContent.self), compatibleWith: nil) } } _view.imageView.image = image diff --git a/ChatK!t/Core/Message/Content/FileMessageView.swift b/ChatK!t/Core/Message/Content/FileMessageView.swift index 4ecef3d4..a04bfc4b 100644 --- a/ChatK!t/Core/Message/Content/FileMessageView.swift +++ b/ChatK!t/Core/Message/Content/FileMessageView.swift @@ -7,7 +7,6 @@ import Foundation import FFCircularProgressView -import ChatKit open class FileMessageView: UIView { diff --git a/ChatK!t/Core/Message/Model/MessagesModel.swift b/ChatK!t/Core/Message/Model/MessagesModel.swift index b2d4795b..f2e9f7ce 100644 --- a/ChatK!t/Core/Message/Model/MessagesModel.swift +++ b/ChatK!t/Core/Message/Model/MessagesModel.swift @@ -8,7 +8,7 @@ import Foundation import RxSwift -public protocol ChatModelDelegate: class { +public protocol ChatModelDelegate: AnyObject { var model: ChatModel? { get set diff --git a/ChatK!t/Core/Message/View/MessagesView.swift b/ChatK!t/Core/Message/View/MessagesView.swift index b0c6233c..af18f529 100644 --- a/ChatK!t/Core/Message/View/MessagesView.swift +++ b/ChatK!t/Core/Message/View/MessagesView.swift @@ -253,7 +253,7 @@ extension MessagesView: UITableViewDelegate { open func heightForIndexPath(_ indexPath: IndexPath) -> CGFloat { var height: CGFloat? - var width = UIScreen.main.bounds.width + let width = UIScreen.main.bounds.width // if frame.width > 0 { // width = frame.width // } diff --git a/ChatK!t/Core/Message/View/PMessagesView.swift b/ChatK!t/Core/Message/View/PMessagesView.swift index 29fe84f9..8900eae8 100644 --- a/ChatK!t/Core/Message/View/PMessagesView.swift +++ b/ChatK!t/Core/Message/View/PMessagesView.swift @@ -8,7 +8,7 @@ import Foundation import RxSwift -public protocol PMessagesView: class { +public protocol PMessagesView: AnyObject { func scrollToBottom(animated: Bool, force: Bool) func apply(snapshot: NSDiffableDataSourceSnapshot, animated: Bool) -> Completable func reload(messages: [AbstractMessage], animated: Bool) -> Completable diff --git a/ChatK!t/Core/Toolbar/ChatToolbar.swift b/ChatK!t/Core/Toolbar/ChatToolbar.swift index 6c30a010..4bbf40aa 100644 --- a/ChatK!t/Core/Toolbar/ChatToolbar.swift +++ b/ChatK!t/Core/Toolbar/ChatToolbar.swift @@ -7,12 +7,12 @@ import Foundation -public protocol ChatToolbarDelegate: class { +public protocol ChatToolbarDelegate: AnyObject { func selectedMessages() -> [AbstractMessage] func clearSelection(_ updateView: Bool?, animated: Bool) } -public protocol ChatToolbarActionsDelegate: class { +public protocol ChatToolbarActionsDelegate: AnyObject { var toolbarActions: [ToolbarAction] { get } diff --git a/ChatK!t/Core/Utils/DownloadManager.swift b/ChatK!t/Core/Utils/DownloadManager.swift index 83a41253..7bb7e25a 100644 --- a/ChatK!t/Core/Utils/DownloadManager.swift +++ b/ChatK!t/Core/Utils/DownloadManager.swift @@ -61,7 +61,7 @@ open class DownloadManager { } open func localURL(for id: String, pathExtension: String? = nil) -> URL? { - var path = path.appendingPathComponent(id) + var path = self.path.appendingPathComponent(id) if let ext = pathExtension { path.appendPathExtension(ext) } @@ -268,7 +268,7 @@ open class DefaultDownloadManagerListener: DownloadManagerListener { } open func downloadProgressUpdated(_ id: String, pathExtension: String?, progress: Float) { - if var message = message(for: id) { + if let message = message(for: id) { message.setDownloadProgress(progress) } } diff --git a/ChatK!t/Core/Views/ReconnectingView.swift b/ChatK!t/Core/Views/ReconnectingView.swift index cf5fd3f4..b35b535a 100644 --- a/ChatK!t/Core/Views/ReconnectingView.swift +++ b/ChatK!t/Core/Views/ReconnectingView.swift @@ -68,8 +68,8 @@ open class ReconnectingView : UIView { } - open func update(_ connStatus: ConnectionStatus? = .none) { - if connStatus != .none { + open func update(_ connStatus: ConnectionStatus? = Optional.none) { + if connStatus != Optional.none { isHidden = false if connStatus != status {