-
Notifications
You must be signed in to change notification settings - Fork 19
Cleaned up variable name and comments #8
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ class ConversationViewModel: NSObject { | |
|
|
||
| private(set) var observableConversation: ObservableFetchRequestResult<PersistentConversationDataItem>? | ||
| lazy private(set) var observableMessageList = conversationsRepository.getObservableMessages(for: conversationSid) | ||
| private(set) var observervableTypingMemeberList: ObservableFetchRequestResult<PersistentParticipantDataItem>? | ||
| private(set) var observableTypingParticipantList: ObservableFetchRequestResult<PersistentParticipantDataItem>? | ||
| private(set) var messageItems: [MessageListItemCell] = [] { | ||
| didSet { | ||
| self.delegate?.messageListUpdated(from: oldValue, to: messageItems) | ||
|
|
@@ -40,7 +40,7 @@ class ConversationViewModel: NSObject { | |
|
|
||
| weak var delegate: ConversationViewModelDelegate? | ||
|
|
||
| // MARK: Init | ||
| // MARK: Initialize the Conversation | ||
| init(conversationSid: String, conversationsRepository: ConversationsRepositoryProtocol = ConversationsRepository.shared, messagesManager: MessagesManagerProtocol = MessagesManager()) { | ||
| self.conversationSid = conversationSid | ||
| self.conversationsRepository = conversationsRepository | ||
|
|
@@ -68,17 +68,17 @@ class ConversationViewModel: NSObject { | |
| messagesManager.reactToMessage(withSid: sid, withReaction: reaction) | ||
| } | ||
|
|
||
| // MARK: Deintialization | ||
| // Deinitialization | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return |
||
| deinit { | ||
| // During transition, remove observers | ||
| unsubscribeFromConversationChanges() | ||
| } | ||
|
|
||
| // MARK: Methods | ||
| // Methods | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here please, too. |
||
| private func unsubscribeFromConversationChanges() { | ||
| observableConversation?.removeObserver(self) | ||
| observableMessageList.removeObserver(self) | ||
| observervableTypingMemeberList?.removeObserver(self) | ||
| observervableTypingMemberList?.removeObserver(self) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be |
||
| } | ||
|
|
||
| private func listenForConversationChanges() { | ||
|
|
@@ -88,7 +88,7 @@ class ConversationViewModel: NSObject { | |
| } | ||
|
|
||
| private func listenForTypingParticipant() { | ||
| observervableTypingMemeberList?.observe(with: self) {[weak self] participants in | ||
| observervableTypingMemberList?.observe(with: self) {[weak self] participants in | ||
| guard let participants = participants else { | ||
| return | ||
| } | ||
|
|
@@ -107,7 +107,7 @@ class ConversationViewModel: NSObject { | |
|
|
||
| func loadConversation() { | ||
| observableConversation = fetchConversation(sid: conversationSid) | ||
| observervableTypingMemeberList = conversationsRepository.getTypingParticipants(inConversation: conversationSid).data | ||
| observervableTypingMemberList = conversationsRepository.getTypingParticipants(inConversation: conversationSid).data | ||
| listenForConversationChanges() | ||
| listenForConversationMessagesChanges() | ||
| listenForTypingParticipant() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for these.