Commit 612f67bd authored by Lucio Maciel's avatar Lucio Maciel

Fix ANR on ChatRoom screen

parent eb57fd00
...@@ -54,6 +54,7 @@ android { ...@@ -54,6 +54,7 @@ android {
packagingOptions { packagingOptions {
exclude 'META-INF/core.kotlin_module' exclude 'META-INF/core.kotlin_module'
exclude 'META-INF/main.kotlin_module'
} }
} }
......
package chat.rocket.android.chatinformation.di package chat.rocket.android.chatinformation.di
import chat.rocket.android.chatinformation.ui.MessageInfoFragment import chat.rocket.android.chatinformation.ui.MessageInfoFragment
import chat.rocket.android.dagger.scope.PerFragment
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
...@@ -8,5 +9,6 @@ import dagger.android.ContributesAndroidInjector ...@@ -8,5 +9,6 @@ import dagger.android.ContributesAndroidInjector
abstract class MessageInfoFragmentProvider { abstract class MessageInfoFragmentProvider {
@ContributesAndroidInjector(modules = [MessageInfoFragmentModule::class]) @ContributesAndroidInjector(modules = [MessageInfoFragmentModule::class])
@PerFragment
abstract fun provideMessageInfoFragment(): MessageInfoFragment abstract fun provideMessageInfoFragment(): MessageInfoFragment
} }
\ No newline at end of file
...@@ -559,7 +559,7 @@ class ChatRoomPresenter @Inject constructor( ...@@ -559,7 +559,7 @@ class ChatRoomPresenter @Inject constructor(
try { try {
val members = retryIO("getMembers($chatRoomId, $chatRoomType, $offset)") { val members = retryIO("getMembers($chatRoomId, $chatRoomType, $offset)") {
client.getMembers(chatRoomId, roomTypeOf(chatRoomType), offset, 50).result client.getMembers(chatRoomId, roomTypeOf(chatRoomType), offset, 50).result
} }.take(50) // Get only 50, the backend is returning 7k+ users
usersRepository.saveAll(members) usersRepository.saveAll(members)
val self = localRepository.get(LocalRepository.CURRENT_USERNAME_KEY) val self = localRepository.get(LocalRepository.CURRENT_USERNAME_KEY)
// Take at most the 100 most recent messages distinguished by user. Can return less. // Take at most the 100 most recent messages distinguished by user. Can return less.
......
...@@ -265,6 +265,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -265,6 +265,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
} }
recycler_view.addOnLayoutChangeListener(layoutChangeListener) recycler_view.addOnLayoutChangeListener(layoutChangeListener)
recycler_view.addOnScrollListener(onScrollListener) recycler_view.addOnScrollListener(onScrollListener)
// Load just once, on the first page...
presenter.loadActiveMembers(chatRoomId, chatRoomType, filterSelfOut = true)
} }
val oldMessagesCount = adapter.itemCount val oldMessagesCount = adapter.itemCount
...@@ -273,7 +276,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -273,7 +276,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
recycler_view.scrollToPosition(0) recycler_view.scrollToPosition(0)
verticalScrollOffset.set(0) verticalScrollOffset.set(0)
} }
presenter.loadActiveMembers(chatRoomId, chatRoomType, filterSelfOut = true)
toggleNoChatView(adapter.itemCount) toggleNoChatView(adapter.itemCount)
} }
} }
......
...@@ -4,8 +4,8 @@ ext { ...@@ -4,8 +4,8 @@ ext {
compileSdk : 27, compileSdk : 27,
targetSdk : 27, targetSdk : 27,
buildTools : '27.0.3', buildTools : '27.0.3',
kotlin : '1.2.41', kotlin : '1.2.50',
coroutine : '0.22.5', coroutine : '0.23.1',
dokka : '0.9.16', dokka : '0.9.16',
// Main dependencies // Main dependencies
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment