Commit f4c71ec2 authored by dev-ritik's avatar dev-ritik

add support to fetch avatar realtime

parent cf7ffd51
package chat.rocket.android.db
import android.app.Application
import androidx.core.net.toUri
import chat.rocket.android.R
import chat.rocket.android.db.model.BaseMessageEntity
import chat.rocket.android.db.model.BaseUserEntity
......@@ -15,6 +16,7 @@ import chat.rocket.android.db.model.UrlEntity
import chat.rocket.android.db.model.UserEntity
import chat.rocket.android.db.model.UserStatus
import chat.rocket.android.db.model.asEntity
import chat.rocket.android.util.extensions.avatarUrl
import chat.rocket.android.util.extensions.exhaustive
import chat.rocket.android.util.extensions.removeTrailingSlash
import chat.rocket.android.util.extensions.toEntity
......@@ -33,6 +35,7 @@ import chat.rocket.core.model.Myself
import chat.rocket.core.model.Room
import chat.rocket.core.model.attachment.Attachment
import chat.rocket.core.model.userId
import com.facebook.drawee.backends.pipeline.Fresco
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.channels.Channel
import kotlinx.coroutines.experimental.launch
......@@ -174,6 +177,13 @@ class DatabaseManager(val context: Application, val serverUrl: String) {
status = myself.status?.toString() ?: user.status
) ?: myself.asUser().toEntity()
if (myself.avatarOrigin != null && myself.active == null &&
myself.name == null && myself.username == null) {
user?.username?.let {
Fresco.getImagePipeline().evictFromCache(serverUrl.avatarUrl(it).toUri())
}
}
Timber.d("UPDATING SELF: $entity")
entity?.let { sendOperation(Operation.UpsertUser(it)) }
}
......
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