-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
Fetch messages in background #4475
base: master
Are you sure you want to change the base?
Conversation
not to be merged for 20.1.0, might review only afterwards |
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.
something is wrong with the chatBlocks, they don't get merged correctly (i guess because "lastKnown" in the fieldMap is not set up correctly). In the UI this leads to the fact that the newest loaded message is shown first, and then the older messages appear. With correctly merged chatBlocks this should not happen.
There is a high danger to introduce serious bugs when something is wrong with the chatBlocks, so i might be quite nitpicky with this PR ;)
@@ -446,6 +449,34 @@ class ConversationsListActivity : | |||
updateFilterConversationButtonColor() | |||
} | |||
|
|||
private fun List<ConversationModel>.refreshMessages() { |
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.
As we already have a ConversationListViewModel we should use this, so as the code is just about data handling it should not be in the Activity.
9bf582b
to
7dfc82c
Compare
fyi @rapterjet2004 i rebased on master... |
7dfc82c
to
9b756d4
Compare
6ed9910
to
096c0aa
Compare
|
||
private suspend fun updateRoomMessage(model: ConversationModel, limit: Int, credentials: String, baseUrl: String) { | ||
val urlForChatting = ApiUtils.getUrlForChat(1, baseUrl, model.token) // FIXME v1? | ||
chatRepository.setData(model, credentials, urlForChatting) |
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.
i don't have a better idea yet,
but using the same chatRepository and only setData etc in a loop feels risky.
Some question that come to my mind:
Is the way we use dependency injection fine with this loop approach?
Is async / synchronized handling correct?
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.
Dependency Injection is a bit confusing, as even though the provider is annotated as a @singleton, it's not an actual Singleton. Each time we inject, we create a separate instance.
Async handling should be fine, the suspend function runs in ViewModelScope, so it shouldn't be attached the activity lifecycle.
app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt
Outdated
Show resolved
Hide resolved
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/4475-talk.apk |
will do some testing tomorrow, then it should be fine to merge |
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
48dc925
to
3cba747
Compare
sorry Julius i won't merge this PR. There were just too many things wrong when i tested (messages that i expected to be there were missing / Messages were loaded from when conversation was created / ...) Also the calculation with the previous/current/result lists doesn't make sense to me. Tbh i would like to close the PR for now and we should have a fresh look at it later. |
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.
see comment in pr
Fetches messages and saves them when refreshing the conversation list. Only refreshes what is needed, to save battery.
🏁 Checklist
/backport to stable-xx.x