Renamed func currentSender() -> SenderType to var currentSender: SenderType (#1714)

* refactor: Renamed `func currentSender() -> SenderType` to `var currentSender: SenderType`

* refactor: Renamed `func currentSender() -> SenderType` to `var currentSender: SenderType`

Changelog
This commit is contained in:
Martin Púčik
2022-05-10 16:42:34 +02:00
committed by GitHub
parent 9793c9deb0
commit cf07a475c9
8 changed files with 9 additions and 8 deletions
+1
View File
@@ -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
+1 -1
View File
@@ -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?
+1 -1
View File
@@ -105,7 +105,7 @@ let messages: [MessageType] = []
extension ChatViewController: MessagesDataSource {
func currentSender() -> SenderType {
var currentSender: SenderType {
return Sender(senderId: "any_unique_id", displayName: "Steven")
}
@@ -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)
}
@@ -152,7 +152,7 @@ class ChatViewController: MessagesViewController, MessagesDataSource {
// MARK: - MessagesDataSource
func currentSender() -> SenderType {
var currentSender: SenderType {
return SampleData.shared.currentSender
}
@@ -89,7 +89,7 @@ struct MessagesView: UIViewControllerRepresentable {
}
extension MessagesView.Coordinator: MessagesDataSource {
func currentSender() -> SenderType {
var currentSender: SenderType {
return SampleData.shared.currentSender
}
+2 -2
View File
@@ -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 {
@@ -37,7 +37,7 @@ class MockMessagesDataSource: MessagesDataSource {
return senders[0]
}
func currentSender() -> SenderType {
var currentSender: SenderType {
return currentUser
}