Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit c31bbe6

Browse files
martinpucikPatrick-Kladek
authored andcommitted
Renamed func currentSender() -> SenderType to var currentSender: SenderType (MessageKit#1714)
* refactor: Renamed `func currentSender() -> SenderType` to `var currentSender: SenderType` * refactor: Renamed `func currentSender() -> SenderType` to `var currentSender: SenderType` Changelog
1 parent 8fc7771 commit c31bbe6

8 files changed

Lines changed: 9 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ See [MIGRATION_GUIDE.md](https://github.com/MessageKit/MessageKit/blob/main/Docu
1616
- **Breaking change**: Dropped CocoaPods support
1717
- **Breaking change**: Dropped support for iOS 12 [2bd234b](https://github.com/MessageKit/MessageKit/commit/2bd234b1e878f392089f166d6868ce644d6c9e95) by [@martinpucik](https://github.com/martinpucik)
1818
- **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)
19+
- **Breaking change**: Renamed `func currentSender() -> SenderType` to `var currentSender: SenderType` [#1714](https://github.com/MessageKit/MessageKit/pull/1714) by [@martinpucik](https://github.com/martinpucik)
1920
- **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)
2021
- **Breaking change**: Added an argument to `messageContainerMaxWidth` [cd4f75b](https://github.com/MessageKit/MessageKit/commit/cd4f75b561129fc25e6c4576000e5a92ccd81cad) by [@martinpucik](https://github.com/martinpucik)
2122
```swift

Documentation/FAQs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func didTapMessage(in cell: MessageCollectionViewCell) {
109109

110110
## Animations are laggy/Scrolling is not smooth/General poor performance
111111

112-
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.
112+
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.
113113

114114
## How can I use MessageKit with SwiftUI?
115115

Documentation/QuickStart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ let messages: [MessageType] = []
105105

106106
extension ChatViewController: MessagesDataSource {
107107

108-
func currentSender() -> SenderType {
108+
var currentSender: SenderType {
109109
return Sender(senderId: "any_unique_id", displayName: "Steven")
110110
}
111111

Example/Sources/View Controllers/AdvancedExampleViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ extension AdvancedExampleViewController: CameraInputBarAccessoryViewDelegate {
467467

468468
func sendImageMessage( photo : UIImage) {
469469

470-
let photoMessage = MockMessage(image: photo, user: self.currentSender() as! MockUser, messageId: UUID().uuidString, date: Date())
470+
let photoMessage = MockMessage(image: photo, user: self.currentSender as! MockUser, messageId: UUID().uuidString, date: Date())
471471
self.insertMessage(photoMessage)
472472
}
473473

Example/Sources/View Controllers/ChatViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class ChatViewController: MessagesViewController, MessagesDataSource {
152152

153153
// MARK: - MessagesDataSource
154154

155-
func currentSender() -> SenderType {
155+
var currentSender: SenderType {
156156
return SampleData.shared.currentSender
157157
}
158158

Example/Sources/Views/SwiftUI/MessagesView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct MessagesView: UIViewControllerRepresentable {
8989
}
9090

9191
extension MessagesView.Coordinator: MessagesDataSource {
92-
func currentSender() -> SenderType {
92+
var currentSender: SenderType {
9393
return SampleData.shared.currentSender
9494
}
9595

Sources/Protocols/MessagesDataSource.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import UIKit
2929
public protocol MessagesDataSource: AnyObject {
3030

3131
/// The `SenderType` of new messages in the `MessagesCollectionView`.
32-
func currentSender() -> SenderType
32+
var currentSender: SenderType { get }
3333

3434
/// A helper method to determine if a given message is from the current `SenderType`.
3535
///
@@ -192,7 +192,7 @@ public protocol MessagesDataSource: AnyObject {
192192
public extension MessagesDataSource {
193193

194194
func isFromCurrentSender(message: MessageType) -> Bool {
195-
return message.sender.senderId == currentSender().senderId
195+
return message.sender.senderId == currentSender.senderId
196196
}
197197

198198
func numberOfItems(inSection section: Int, in messagesCollectionView: MessagesCollectionView) -> Int {

Tests/MessageKitTests/Mocks/MockMessagesDataSource.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class MockMessagesDataSource: MessagesDataSource {
3737
return senders[0]
3838
}
3939

40-
func currentSender() -> SenderType {
40+
var currentSender: SenderType {
4141
return currentUser
4242
}
4343

0 commit comments

Comments
 (0)