[1.53.*] Pre-release merge (#450)

This commit is contained in:
tramline-github[bot]
2024-02-13 16:32:29 +00:00
committed by GitHub
6 changed files with 17 additions and 15 deletions
+6 -2
View File
@@ -33,8 +33,6 @@
"matchPackagePatterns": [
"^androidx.*",
],
"matchPackageNames": [
],
"groupName": "AndroidX"
},
{
@@ -50,6 +48,12 @@
],
"allowedVersions": "!/.*-1-8$/",
},
{
"matchPackagePatterns": [
"^androidx.glance",
],
"allowedVersions": "<=1.0.0",
},
],
"regexManagers": [
{
@@ -31,15 +31,18 @@ import dev.msfjarvis.claw.common.theme.LightThemeColors
import dev.msfjarvis.claw.model.UIPost
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
class SavedPostsWidget(private val posts: List<UIPost>) : GlanceAppWidget() {
class SavedPostsWidget(private val posts: Flow<List<UIPost>>) : GlanceAppWidget() {
override suspend fun provideGlance(context: Context, id: GlanceId) {
val postWindow = posts.first().take(50).toImmutableList()
provideContent {
GlanceTheme(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) GlanceTheme.colors
else ColorProviders(light = LightThemeColors, dark = DarkThemeColors)
) {
WidgetHost(posts.toImmutableList())
WidgetHost(postWindow)
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2023 Harsh Shandilya.
* Copyright © 2023-2024 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
@@ -14,8 +14,6 @@ import com.deliveryhero.whetstone.Whetstone
import com.deliveryhero.whetstone.broadcastreceiver.ContributesBroadcastReceiverInjector
import dev.msfjarvis.claw.android.viewmodel.ClawViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
@ContributesBroadcastReceiverInjector
class WidgetReceiver : GlanceAppWidgetReceiver() {
@@ -23,7 +21,7 @@ class WidgetReceiver : GlanceAppWidgetReceiver() {
@Inject lateinit var viewModel: ClawViewModel
override val glanceAppWidget: GlanceAppWidget
get() = SavedPostsWidget(runBlocking { viewModel.savedPosts.first().take(50) })
get() = SavedPostsWidget(viewModel.savedPosts)
override fun onReceive(context: Context, intent: Intent) {
Whetstone.inject(this, context)
@@ -53,7 +53,6 @@ import kotlinx.collections.immutable.toImmutableMap
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.shareIn
import kotlinx.coroutines.launch
@@ -161,10 +160,7 @@ constructor(
} else {
savedPostsRepository.savePost(post.toSavedPost())
}
val newPosts = savedPosts.first()
withContext(mainDispatcher) {
SavedPostsWidget(newPosts.take(50)).updateAll(getApplication())
}
withContext(mainDispatcher) { SavedPostsWidget(savedPosts).updateAll(getApplication()) }
}
}
@@ -23,6 +23,7 @@ import dev.msfjarvis.claw.model.fromSavedPost
import dev.msfjarvis.claw.model.toSavedPost
import javax.inject.Inject
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
/**
* WorkManager-backed [CoroutineWorker] that gets all the posts from [SavedPostsRepository], fetches
@@ -47,7 +48,7 @@ constructor(
.map { result -> result.value.toSavedPost() }
.let { savedPostsRepository.savePosts(it) }
SavedPostsWidget(
savedPostsRepository.savedPosts.first().take(50).map(UIPost.Companion::fromSavedPost)
savedPostsRepository.savedPosts.map { it.map(UIPost.Companion::fromSavedPost) }
)
.updateAll(applicationContext)
return Result.success()
+1 -1
View File
@@ -7,7 +7,7 @@ coil = "2.5.0"
composeCompiler = "1.5.9"
coroutines = "1.8.0-RC2"
dagger = "2.50"
glance = "1.1.0-alpha01"
glance = "1.0.0"
junit = "5.10.2"
konvert = "3.0.0"
kotlin = "1.9.22"