Upgrade AndroidX dependencies (#3169)
* upgrade AndroidX dependencies * use new @Upsert in InstanceDao * fix crash because of new Room nullchecks * make TimelineStatusEntity.reblogAccount a val as well
This commit is contained in:
parent
16df2bfe87
commit
006f0de05c
7 changed files with 34 additions and 57 deletions
|
@ -153,7 +153,7 @@ fun Status.toEntity(
|
|||
}
|
||||
|
||||
fun TimelineStatusWithAccount.toViewData(gson: Gson, isDetailed: Boolean = false): StatusViewData {
|
||||
if (this.status.isPlaceholder) {
|
||||
if (this.account == null) {
|
||||
Log.d(TAG, "Constructing Placeholder(${this.status.serverId}, ${this.status.expanded})")
|
||||
return StatusViewData.Placeholder(this.status.serverId, this.status.expanded)
|
||||
}
|
||||
|
|
|
@ -16,41 +16,18 @@
|
|||
package com.keylesspalace.tusky.db
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.RewriteQueriesToDropUnusedColumns
|
||||
import androidx.room.Transaction
|
||||
import androidx.room.Update
|
||||
import androidx.room.Upsert
|
||||
|
||||
@Dao
|
||||
interface InstanceDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE, entity = InstanceEntity::class)
|
||||
suspend fun insertOrIgnore(instance: InstanceInfoEntity): Long
|
||||
@Upsert(entity = InstanceEntity::class)
|
||||
suspend fun upsert(instance: InstanceInfoEntity)
|
||||
|
||||
@Update(onConflict = OnConflictStrategy.IGNORE, entity = InstanceEntity::class)
|
||||
suspend fun updateOrIgnore(instance: InstanceInfoEntity)
|
||||
|
||||
@Transaction
|
||||
suspend fun upsert(instance: InstanceInfoEntity) {
|
||||
if (insertOrIgnore(instance) == -1L) {
|
||||
updateOrIgnore(instance)
|
||||
}
|
||||
}
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE, entity = InstanceEntity::class)
|
||||
suspend fun insertOrIgnore(emojis: EmojisEntity): Long
|
||||
|
||||
@Update(onConflict = OnConflictStrategy.IGNORE, entity = InstanceEntity::class)
|
||||
suspend fun updateOrIgnore(emojis: EmojisEntity)
|
||||
|
||||
@Transaction
|
||||
suspend fun upsert(emojis: EmojisEntity) {
|
||||
if (insertOrIgnore(emojis) == -1L) {
|
||||
updateOrIgnore(emojis)
|
||||
}
|
||||
}
|
||||
@Upsert(entity = InstanceEntity::class)
|
||||
suspend fun upsert(emojis: EmojisEntity)
|
||||
|
||||
@RewriteQueriesToDropUnusedColumns
|
||||
@Query("SELECT * FROM InstanceEntity WHERE instance = :instance LIMIT 1")
|
||||
|
|
|
@ -18,7 +18,7 @@ package com.keylesspalace.tusky.db
|
|||
import androidx.paging.PagingSource
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy.REPLACE
|
||||
import androidx.room.OnConflictStrategy.Companion.REPLACE
|
||||
import androidx.room.Query
|
||||
|
||||
@Dao
|
||||
|
|
|
@ -104,11 +104,11 @@ data class TimelineAccountEntity(
|
|||
val bot: Boolean
|
||||
)
|
||||
|
||||
class TimelineStatusWithAccount {
|
||||
data class TimelineStatusWithAccount(
|
||||
@Embedded
|
||||
lateinit var status: TimelineStatusEntity
|
||||
val status: TimelineStatusEntity,
|
||||
@Embedded(prefix = "a_")
|
||||
lateinit var account: TimelineAccountEntity
|
||||
val account: TimelineAccountEntity? = null, // null when placeholder
|
||||
@Embedded(prefix = "rb_")
|
||||
var reblogAccount: TimelineAccountEntity? = null
|
||||
}
|
||||
val reblogAccount: TimelineAccountEntity? = null // null when no reblog
|
||||
)
|
||||
|
|
|
@ -193,9 +193,9 @@ class CachedTimelineRemoteMediatorTest {
|
|||
listOf(
|
||||
mockStatusEntityWithAccount("8"),
|
||||
mockStatusEntityWithAccount("7"),
|
||||
TimelineStatusWithAccount().apply {
|
||||
TimelineStatusWithAccount(
|
||||
status = Placeholder("5", loading = false).toEntity(1)
|
||||
},
|
||||
),
|
||||
mockStatusEntityWithAccount("3"),
|
||||
mockStatusEntityWithAccount("2"),
|
||||
mockStatusEntityWithAccount("1"),
|
||||
|
@ -547,8 +547,8 @@ class CachedTimelineRemoteMediatorTest {
|
|||
private fun AppDatabase.insert(statuses: List<TimelineStatusWithAccount>) {
|
||||
runBlocking {
|
||||
statuses.forEach { statusWithAccount ->
|
||||
if (!statusWithAccount.status.isPlaceholder) {
|
||||
timelineDao().insertAccount(statusWithAccount.account)
|
||||
statusWithAccount.account?.let { account ->
|
||||
timelineDao().insertAccount(account)
|
||||
}
|
||||
statusWithAccount.reblogAccount?.let { account ->
|
||||
timelineDao().insertAccount(account)
|
||||
|
|
|
@ -92,26 +92,26 @@ fun mockStatusEntityWithAccount(
|
|||
val mockedStatus = mockStatus(id)
|
||||
val gson = Gson()
|
||||
|
||||
return TimelineStatusWithAccount().apply {
|
||||
return TimelineStatusWithAccount(
|
||||
status = mockedStatus.toEntity(
|
||||
timelineUserId = userId,
|
||||
gson = gson,
|
||||
expanded = expanded,
|
||||
contentShowing = false,
|
||||
contentCollapsed = true
|
||||
)
|
||||
),
|
||||
account = mockedStatus.account.toEntity(
|
||||
accountId = userId,
|
||||
gson = gson
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun mockPlaceholderEntityWithAccount(
|
||||
id: String,
|
||||
userId: Long = 1,
|
||||
): TimelineStatusWithAccount {
|
||||
return TimelineStatusWithAccount().apply {
|
||||
return TimelineStatusWithAccount(
|
||||
status = Placeholder(id, false).toEntity(userId)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,30 +1,31 @@
|
|||
[versions]
|
||||
agp = "7.4.0"
|
||||
androidx-activity = "1.6.0"
|
||||
androidx-appcompat = "1.6.0-rc01"
|
||||
agp = "7.4.1"
|
||||
androidx-activity = "1.6.1"
|
||||
androidx-appcompat = "1.6.0"
|
||||
androidx-browser = "1.4.0"
|
||||
androidx-cardview = "1.0.0"
|
||||
androidx-constraintlayout = "2.1.4"
|
||||
androidx-core = "1.9.0"
|
||||
androidx-exifinterface = "1.3.4"
|
||||
androidx-fragment = "1.5.3"
|
||||
androidx-junit = "1.1.3"
|
||||
androidx-exifinterface = "1.3.5"
|
||||
androidx-fragment = "1.5.5"
|
||||
androidx-junit = "1.1.5"
|
||||
androidx-paging = "3.1.1"
|
||||
androidx-preference = "1.2.0"
|
||||
androidx-recyclerview = "1.1.0"
|
||||
androidx-recyclerview = "1.2.1"
|
||||
androidx-sharetarget = "1.2.0"
|
||||
androidx-splashscreen = "1.0.0"
|
||||
androidx-swiperefresh-layout = "1.1.0"
|
||||
androidx-testing = "2.1.0"
|
||||
androidx-viewpager2 = "1.0.0"
|
||||
androidx-work = "2.7.1"
|
||||
androidx-room = "2.5.0"
|
||||
autodispose = "2.1.1"
|
||||
bouncycastle = "1.70"
|
||||
conscrypt = "2.5.2"
|
||||
coroutines = "1.6.4"
|
||||
dagger = "2.43.2"
|
||||
emoji2 = "1.1.0"
|
||||
espresso = "3.4.0"
|
||||
espresso = "3.5.1"
|
||||
filemoji-compat = "3.2.7"
|
||||
glide = "4.13.2"
|
||||
glide-animation-plugin = "2.23.0"
|
||||
|
@ -41,7 +42,6 @@ networkresult-calladapter = "1.0.0"
|
|||
okhttp = "4.10.0"
|
||||
retrofit = "2.9.0"
|
||||
robolectric = "4.8.1"
|
||||
room = "2.4.3"
|
||||
rxandroid3 = "3.0.0"
|
||||
rxjava3 = "3.1.3"
|
||||
rxkotlin3 = "3.0.1"
|
||||
|
@ -77,10 +77,10 @@ androidx-lifecycle-reactivestreams-ktx = { module = "androidx.lifecycle:lifecycl
|
|||
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
|
||||
androidx-paging-runtime-ktx = { module = "androidx.paging:paging-runtime-ktx", version.ref = "androidx-paging" }
|
||||
androidx-preference-ktx = { module = "androidx.preference:preference-ktx", version.ref = "androidx-preference" }
|
||||
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
|
||||
androidx-room-paging = { module = "androidx.room:room-paging", version.ref = "room" }
|
||||
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
|
||||
androidx-room-testing = { module = "androidx.room:room-testing", version.ref = "room" }
|
||||
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "androidx-room" }
|
||||
androidx-room-paging = { module = "androidx.room:room-paging", version.ref = "androidx-room" }
|
||||
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "androidx-room" }
|
||||
androidx-room-testing = { module = "androidx.room:room-testing", version.ref = "androidx-room" }
|
||||
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "androidx-recyclerview" }
|
||||
androidx-sharetarget = { module = "androidx.sharetarget:sharetarget", version.ref = "androidx-sharetarget" }
|
||||
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "androidx-swiperefresh-layout" }
|
||||
|
|
Loading…
Reference in a new issue