diff --git a/CHANGELOG.md b/CHANGELOG.md index e90be913..6d0b5ee4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ See [MIGRATION_GUIDE.md](https://github.com/MessageKit/MessageKit/blob/main/Docu - **Breaking change**: Dropped CocoaPods support - **Breaking change**: Dropped support for iOS 12 [2bd234b](https://github.com/MessageKit/MessageKit/commit/2bd234b1e878f392089f166d6868ce644d6c9e95) by [@martinpucik](https://github.com/martinpucik) - **Breaking change**: Moved messageInputBar from inputAccessoryView to a subview in MessagesViewController [#1704](https://github.com/MessageKit/MessageKit/pull/1704) by [@martinpucik](https://github.com/martinpucik) +- **Breaking change**: Renamed `func currentSender() -> SenderType` to `var currentSender: SenderType` [#1714](https://github.com/MessageKit/MessageKit/pull/1714) by [@martinpucik](https://github.com/martinpucik) - **Deprecation**: Deprecated `maintainPositionOnKeyboardFrameChangedMoved` in favor of `maintainPositionOnInputBarHeightChanged` which better describes the intended use of this property [#1704](https://github.com/MessageKit/MessageKit/pull/1705) by [@martinpucik](https://github.com/martinpucik) - **Breaking change**: Added an argument to `messageContainerMaxWidth` [cd4f75b](https://github.com/MessageKit/MessageKit/commit/cd4f75b561129fc25e6c4576000e5a92ccd81cad) by [@martinpucik](https://github.com/martinpucik) ```swift diff --git a/Documentation/FAQs.md b/Documentation/FAQs.md index 42d7b696..ae6943dd 100644 --- a/Documentation/FAQs.md +++ b/Documentation/FAQs.md @@ -109,7 +109,7 @@ func didTapMessage(in cell: MessageCollectionViewCell) { ## Animations are laggy/Scrolling is not smooth/General poor performance -In general, if you're experiencing performance issues, you should look through the implementation of your MessageKit delegate methods like `currentSender()`, etc to find any expensive/blocking method calls or operations. Some delegate methods are called many times per message rendered and thus if their implementations are not efficient then performance can significantly degrade. Avoid doing blocking activities like synchronous database lookups, keychain access, networking, etc. in your MessageKit delegate methods. You should instead cache what you need. +In general, if you're experiencing performance issues, you should look through the implementation of your MessageKit delegate methods like `var currentSender`, etc to find any expensive/blocking method calls or operations. Some delegate methods are called many times per message rendered and thus if their implementations are not efficient then performance can significantly degrade. Avoid doing blocking activities like synchronous database lookups, keychain access, networking, etc. in your MessageKit delegate methods. You should instead cache what you need. ## How can I use MessageKit with SwiftUI? diff --git a/Documentation/QuickStart.md b/Documentation/QuickStart.md index 52456a47..501c7d2c 100644 --- a/Documentation/QuickStart.md +++ b/Documentation/QuickStart.md @@ -105,7 +105,7 @@ let messages: [MessageType] = [] extension ChatViewController: MessagesDataSource { - func currentSender() -> SenderType { + var currentSender: SenderType { return Sender(senderId: "any_unique_id", displayName: "Steven") } diff --git a/Example/Sources/View Controllers/AdvancedExampleViewController.swift b/Example/Sources/View Controllers/AdvancedExampleViewController.swift index 5357c43d..9a7963a8 100644 --- a/Example/Sources/View Controllers/AdvancedExampleViewController.swift +++ b/Example/Sources/View Controllers/AdvancedExampleViewController.swift @@ -467,7 +467,7 @@ extension AdvancedExampleViewController: CameraInputBarAccessoryViewDelegate { func sendImageMessage( photo : UIImage) { - let photoMessage = MockMessage(image: photo, user: self.currentSender() as! MockUser, messageId: UUID().uuidString, date: Date()) + let photoMessage = MockMessage(image: photo, user: self.currentSender as! MockUser, messageId: UUID().uuidString, date: Date()) self.insertMessage(photoMessage) } diff --git a/Example/Sources/View Controllers/ChatViewController.swift b/Example/Sources/View Controllers/ChatViewController.swift index e00f2edf..aeb7d9be 100644 --- a/Example/Sources/View Controllers/ChatViewController.swift +++ b/Example/Sources/View Controllers/ChatViewController.swift @@ -152,7 +152,7 @@ class ChatViewController: MessagesViewController, MessagesDataSource { // MARK: - MessagesDataSource - func currentSender() -> SenderType { + var currentSender: SenderType { return SampleData.shared.currentSender } diff --git a/Example/Sources/Views/SwiftUI/MessagesView.swift b/Example/Sources/Views/SwiftUI/MessagesView.swift index 16ba72c6..44fd3dea 100644 --- a/Example/Sources/Views/SwiftUI/MessagesView.swift +++ b/Example/Sources/Views/SwiftUI/MessagesView.swift @@ -89,7 +89,7 @@ struct MessagesView: UIViewControllerRepresentable { } extension MessagesView.Coordinator: MessagesDataSource { - func currentSender() -> SenderType { + var currentSender: SenderType { return SampleData.shared.currentSender } diff --git a/Sources/Protocols/MessagesDataSource.swift b/Sources/Protocols/MessagesDataSource.swift index 894a36f9..41215e37 100644 --- a/Sources/Protocols/MessagesDataSource.swift +++ b/Sources/Protocols/MessagesDataSource.swift @@ -29,7 +29,7 @@ import UIKit public protocol MessagesDataSource: AnyObject { /// The `SenderType` of new messages in the `MessagesCollectionView`. - func currentSender() -> SenderType + var currentSender: SenderType { get } /// A helper method to determine if a given message is from the current `SenderType`. /// @@ -192,7 +192,7 @@ public protocol MessagesDataSource: AnyObject { public extension MessagesDataSource { func isFromCurrentSender(message: MessageType) -> Bool { - return message.sender.senderId == currentSender().senderId + return message.sender.senderId == currentSender.senderId } func numberOfItems(inSection section: Int, in messagesCollectionView: MessagesCollectionView) -> Int { diff --git a/Tests/MessageKitTests/Mocks/MockMessagesDataSource.swift b/Tests/MessageKitTests/Mocks/MockMessagesDataSource.swift index 42ecdb9e..9bdaaa2b 100644 --- a/Tests/MessageKitTests/Mocks/MockMessagesDataSource.swift +++ b/Tests/MessageKitTests/Mocks/MockMessagesDataSource.swift @@ -37,7 +37,7 @@ class MockMessagesDataSource: MessagesDataSource { return senders[0] } - func currentSender() -> SenderType { + var currentSender: SenderType { return currentUser }