update Room to 2.1.0 (#1323)
This commit is contained in:
parent
4b96c1e3f4
commit
22bd0462b7
|
@ -124,10 +124,10 @@ dependencies {
|
||||||
// architecture components
|
// architecture components
|
||||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
|
||||||
//room
|
//room
|
||||||
implementation 'androidx.room:room-runtime:2.0.0'
|
implementation 'androidx.room:room-runtime:2.1.0'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
kapt 'androidx.room:room-compiler:2.0.0'
|
kapt 'androidx.room:room-compiler:2.1.0'
|
||||||
implementation 'androidx.room:room-rxjava2:2.0.0'
|
implementation 'androidx.room:room-rxjava2:2.1.0'
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
implementation "com.google.dagger:dagger:$daggerVersion"
|
implementation "com.google.dagger:dagger:$daggerVersion"
|
||||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||||
|
|
|
@ -11,7 +11,6 @@ import com.keylesspalace.tusky.db.AppDatabase
|
||||||
import com.keylesspalace.tusky.network.TimelineCases
|
import com.keylesspalace.tusky.network.TimelineCases
|
||||||
import com.keylesspalace.tusky.util.Listing
|
import com.keylesspalace.tusky.util.Listing
|
||||||
import com.keylesspalace.tusky.util.NetworkState
|
import com.keylesspalace.tusky.util.NetworkState
|
||||||
import io.reactivex.Single
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxkotlin.addTo
|
import io.reactivex.rxkotlin.addTo
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
@ -55,10 +54,9 @@ class ConversationsViewModel @Inject constructor(
|
||||||
val newConversation = conversation.copy(
|
val newConversation = conversation.copy(
|
||||||
lastStatus = conversation.lastStatus.copy(favourited = favourite)
|
lastStatus = conversation.lastStatus.copy(favourited = favourite)
|
||||||
)
|
)
|
||||||
Single.fromCallable {
|
|
||||||
database.conversationDao().insert(newConversation)
|
database.conversationDao().insert(newConversation)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.doOnError { t -> Log.w("ConversationViewModel", "Failed to favourite conversation", t) }
|
.doOnError { t -> Log.w("ConversationViewModel", "Failed to favourite conversation", t) }
|
||||||
.subscribe()
|
.subscribe()
|
||||||
|
@ -74,10 +72,9 @@ class ConversationsViewModel @Inject constructor(
|
||||||
val newConversation = conversation.copy(
|
val newConversation = conversation.copy(
|
||||||
lastStatus = conversation.lastStatus.copy(poll = poll)
|
lastStatus = conversation.lastStatus.copy(poll = poll)
|
||||||
)
|
)
|
||||||
Single.fromCallable {
|
|
||||||
database.conversationDao().insert(newConversation)
|
database.conversationDao().insert(newConversation)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.doOnError { t -> Log.w("ConversationViewModel", "Failed to favourite conversation", t) }
|
.doOnError { t -> Log.w("ConversationViewModel", "Failed to favourite conversation", t) }
|
||||||
.subscribe()
|
.subscribe()
|
||||||
|
@ -118,18 +115,14 @@ class ConversationsViewModel @Inject constructor(
|
||||||
/* this is not ideal since deleting last toot from an conversation
|
/* this is not ideal since deleting last toot from an conversation
|
||||||
should not delete the conversation but show another toot of the conversation */
|
should not delete the conversation but show another toot of the conversation */
|
||||||
timelineCases.delete(conversation.lastStatus.id)
|
timelineCases.delete(conversation.lastStatus.id)
|
||||||
Single.fromCallable {
|
|
||||||
database.conversationDao().delete(conversation)
|
database.conversationDao().delete(conversation)
|
||||||
}
|
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.subscribe()
|
.subscribe()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveConversationToDb(conversation: ConversationEntity) {
|
private fun saveConversationToDb(conversation: ConversationEntity) {
|
||||||
Single.fromCallable {
|
|
||||||
database.conversationDao().insert(conversation)
|
database.conversationDao().insert(conversation)
|
||||||
}
|
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.subscribe()
|
.subscribe()
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package com.keylesspalace.tusky.db
|
||||||
import androidx.paging.DataSource
|
import androidx.paging.DataSource
|
||||||
import androidx.room.*
|
import androidx.room.*
|
||||||
import com.keylesspalace.tusky.components.conversation.ConversationEntity
|
import com.keylesspalace.tusky.components.conversation.ConversationEntity
|
||||||
|
import io.reactivex.Single
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface ConversationsDao {
|
interface ConversationsDao {
|
||||||
|
@ -25,10 +26,10 @@ interface ConversationsDao {
|
||||||
fun insert(conversations: List<ConversationEntity>)
|
fun insert(conversations: List<ConversationEntity>)
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
fun insert(conversation: ConversationEntity)
|
fun insert(conversation: ConversationEntity): Single<Long>
|
||||||
|
|
||||||
@Delete
|
@Delete
|
||||||
fun delete(conversation: ConversationEntity)
|
fun delete(conversation: ConversationEntity): Single<Int>
|
||||||
|
|
||||||
@Query("SELECT * FROM ConversationEntity WHERE accountId = :accountId ORDER BY s_createdAt DESC")
|
@Query("SELECT * FROM ConversationEntity WHERE accountId = :accountId ORDER BY s_createdAt DESC")
|
||||||
fun conversationsForAccount(accountId: Long) : DataSource.Factory<Int, ConversationEntity>
|
fun conversationsForAccount(accountId: Long) : DataSource.Factory<Int, ConversationEntity>
|
||||||
|
|
Loading…
Reference in New Issue