Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[trello.com/c/pwKrXiiC] Update the logic of reading messages. #703

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

vovameister
Copy link
Member

the following changes have been added:

  1. All unnecessary functions responsible for and implementing full reading of the chatroom have been removed
  2. Now chats that are manually marked as unread will not make the last chat transaction unread, this prevents potential bugs
  3. Now messages in the chat view model have an unread parameter, which allows you to track which messages on the screen are unread
  4. Relationships between transactions and reactions, between messages and reactions have been added to the database. This allows you to add unread reaction to message in the view model and work with the reading flow.
  5. Now when you click on the alert notification about an incoming message, the chat opens and scrolls to this message

@@ -39,4 +40,7 @@ extension MessageTransaction {
reactionsData = data
}
}
func addToRichMessageTransactions(_ transaction: RichMessageTransaction) {
self.mutableSetValue(forKey: "richMessageTransactions").add(transaction)
Copy link
Member

@ChrisBenua ChrisBenua Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see why you had to do like this. If you mutate richMessageTransactions, nothing will be saved to database.

The same thing would happen if you've used raw NSMutableSet

Comment is for other reviewers)

@@ -215,13 +224,22 @@ final class ChatViewController: MessagesViewController {

override func scrollViewDidScroll(_ scrollView: UIScrollView) {
super.scrollViewDidScroll(scrollView)
let visibleIndexPaths = messagesCollectionView.indexPathsForVisibleItems
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same code is repeated twice. Please extract it to function

@@ -70,6 +70,11 @@ final class ChatListViewController: KeyboardObservingViewController {
var searchController: UISearchController?

private var transactionsRequiringBalanceUpdate: [String] = []
private lazy var chatsManuallyMarkedAsUnread: Set<Int> = Set() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need lazy var here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes because NSFetchedResultsController(setBadgeValue(unreadController?.fetchedObjects?.count)) will be available later

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. You set lazy var to empty set, for what?

Copy link
Member Author

@vovameister vovameister Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry I might use another value before, and it crushed the app on init. I will remove lazy

@@ -20,6 +20,8 @@ final class InMemoryCoreDataStack: CoreDataStack {

let description = NSPersistentStoreDescription()
description.type = NSInMemoryStoreType
description.shouldMigrateStoreAutomatically = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? I don't think that NSInMemoryStoreType requires migrations at all

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vovameister take a look, please!

Copy link
Collaborator

@Lainaaa Lainaaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm
However, check, please, Christian comments

@@ -541,6 +542,21 @@ private extension ChatMessageFactory {
]
))
}
func checkTransactionForUnreadReaction(transaction: ChatTransaction) -> Bool {
if let messageTransaction = transaction as? MessageTransaction,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe as part of this тask we can take richMessageTransactions out to ChatTransaction and avoid code duplication?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants