mirror of
https://github.com/nextcloud/talk-android
synced 2025-08-16 00:15:01 +01:00
Fixes to offline caching
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
7bd0918bd7
commit
124c2951d9
@ -57,9 +57,9 @@ class NextcloudTalkOfflineRepositoryImpl(val nextcloudTalkDatabase: TalkDatabase
|
||||
.deleteConversation(userId, conversationId)
|
||||
}
|
||||
|
||||
override fun getConversationsForUser(user: UserEntity): LiveData<List<Conversation>> {
|
||||
override fun getConversationsForUser(userId: Long): LiveData<List<Conversation>> {
|
||||
return nextcloudTalkDatabase.conversationsDao()
|
||||
.getConversationsForUser(user.id)
|
||||
.getConversationsForUser(userId)
|
||||
.map { data ->
|
||||
data.map {
|
||||
it.toConversation()
|
||||
@ -71,18 +71,18 @@ class NextcloudTalkOfflineRepositoryImpl(val nextcloudTalkDatabase: TalkDatabase
|
||||
return nextcloudTalkDatabase
|
||||
}
|
||||
|
||||
override suspend fun clearConversationsForUser(user: UserEntity) {
|
||||
override suspend fun clearConversationsForUser(userId: Long) {
|
||||
nextcloudTalkDatabase.conversationsDao()
|
||||
.clearConversationsForUser(user.id)
|
||||
.clearConversationsForUser(userId)
|
||||
}
|
||||
|
||||
override suspend fun saveConversationsForUser(
|
||||
user: UserEntity,
|
||||
userId: Long,
|
||||
conversations: List<Conversation>
|
||||
) {
|
||||
nextcloudTalkDatabase.conversationsDao()
|
||||
.updateConversationsForUser(
|
||||
user.id,
|
||||
userId,
|
||||
conversations.map {
|
||||
it.toConversationEntity()
|
||||
}.toTypedArray()
|
||||
@ -90,10 +90,10 @@ class NextcloudTalkOfflineRepositoryImpl(val nextcloudTalkDatabase: TalkDatabase
|
||||
}
|
||||
|
||||
override suspend fun deleteConversationForUserWithTimestamp(
|
||||
user: UserEntity,
|
||||
userId: Long,
|
||||
timestamp: Long
|
||||
) {
|
||||
nextcloudTalkDatabase.conversationsDao()
|
||||
.deleteConversationsForUserWithTimestamp(user.id, timestamp)
|
||||
.deleteConversationsForUserWithTimestamp(userId, timestamp)
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ import com.nextcloud.talk.models.database.UserEntity
|
||||
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||
|
||||
interface NextcloudTalkOfflineRepository {
|
||||
fun getConversationsForUser(user: UserEntity): LiveData<List<Conversation>>
|
||||
suspend fun clearConversationsForUser(user: UserEntity)
|
||||
fun getConversationsForUser(userId: Long): LiveData<List<Conversation>>
|
||||
suspend fun clearConversationsForUser(userId: Long)
|
||||
suspend fun saveConversationsForUser(
|
||||
user: UserEntity,
|
||||
userId: Long,
|
||||
conversations: List<Conversation>
|
||||
)
|
||||
|
||||
@ -50,7 +50,7 @@ interface NextcloudTalkOfflineRepository {
|
||||
)
|
||||
|
||||
suspend fun deleteConversationForUserWithTimestamp(
|
||||
user: UserEntity,
|
||||
userId: Long,
|
||||
timestamp: Long
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class ConversationsListViewModel constructor(
|
||||
val searchQuery = MutableLiveData<String>()
|
||||
val currentUserLiveData: MutableLiveData<UserEntity> = MutableLiveData()
|
||||
val conversationsLiveData = Transformations.switchMap(currentUserLiveData) {
|
||||
offlineRepository.getConversationsForUser(it)
|
||||
offlineRepository.getConversationsForUser(it.id)
|
||||
}
|
||||
|
||||
var currentUserAvatar: MutableLiveData<Drawable> = MutableLiveData()
|
||||
@ -189,7 +189,7 @@ class ConversationsListViewModel constructor(
|
||||
it.user = currentUserLiveData.value!!.id
|
||||
}
|
||||
|
||||
offlineRepository.saveConversationsForUser(currentUserLiveData.value!!, mutableList)
|
||||
offlineRepository.saveConversationsForUser(currentUserLiveData.value!!.id, mutableList)
|
||||
messageData = ""
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user