mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 07:37:03 +05:30
feat(android): enable read posts feature
This commit is contained in:
parent
ed071a0fff
commit
4b4f00ad8e
3 changed files with 3 additions and 17 deletions
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
* Add a swipe action on each story to open the comments page on `lobste.rs`
|
* Add a swipe action on each story to open the comments page on `lobste.rs`
|
||||||
|
* Automatically mark posts as "read" and visually distinguish between them
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
@file:Suppress("UnstableApiUsage")
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
import com.android.build.api.variant.BuildConfigField
|
|
||||||
import dev.msfjarvis.claw.gradle.addTestDependencies
|
import dev.msfjarvis.claw.gradle.addTestDependencies
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
@ -35,15 +34,6 @@ android {
|
||||||
packagingOptions.resources.pickFirsts += "**/*.bin"
|
packagingOptions.resources.pickFirsts += "**/*.bin"
|
||||||
}
|
}
|
||||||
|
|
||||||
androidComponents {
|
|
||||||
onVariants { variant ->
|
|
||||||
variant.buildConfigFields.put(
|
|
||||||
"ENABLE_READ_COMMENTS",
|
|
||||||
BuildConfigField("boolean", "false", "Not yet buddy boy")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
baselineProfile {
|
baselineProfile {
|
||||||
dexLayoutOptimization = true
|
dexLayoutOptimization = true
|
||||||
mergeIntoMain = true
|
mergeIntoMain = true
|
||||||
|
|
|
@ -12,7 +12,6 @@ import androidx.activity.ComponentActivity
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import dev.msfjarvis.claw.android.BuildConfig
|
|
||||||
import dev.msfjarvis.claw.android.ui.navigation.Destinations
|
import dev.msfjarvis.claw.android.ui.navigation.Destinations
|
||||||
import dev.msfjarvis.claw.android.viewmodel.ClawViewModel
|
import dev.msfjarvis.claw.android.viewmodel.ClawViewModel
|
||||||
import dev.msfjarvis.claw.common.posts.PostActions
|
import dev.msfjarvis.claw.common.posts.PostActions
|
||||||
|
@ -38,16 +37,12 @@ fun rememberPostActions(
|
||||||
return remember {
|
return remember {
|
||||||
object : PostActions {
|
object : PostActions {
|
||||||
override fun viewPost(postId: String, postUrl: String, commentsUrl: String) {
|
override fun viewPost(postId: String, postUrl: String, commentsUrl: String) {
|
||||||
if (BuildConfig.ENABLE_READ_COMMENTS) {
|
viewModel.markPostAsRead(postId)
|
||||||
viewModel.markPostAsRead(postId)
|
|
||||||
}
|
|
||||||
urlLauncher.openUri(postUrl.ifEmpty { commentsUrl })
|
urlLauncher.openUri(postUrl.ifEmpty { commentsUrl })
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun viewComments(postId: String) {
|
override fun viewComments(postId: String) {
|
||||||
if (BuildConfig.ENABLE_READ_COMMENTS) {
|
viewModel.markPostAsRead(postId)
|
||||||
viewModel.markPostAsRead(postId)
|
|
||||||
}
|
|
||||||
val currentRoute = navController.currentDestination?.route
|
val currentRoute = navController.currentDestination?.route
|
||||||
val newRoute =
|
val newRoute =
|
||||||
Destinations.Comments.route.replace(Destinations.Comments.placeholder, postId)
|
Destinations.Comments.route.replace(Destinations.Comments.placeholder, postId)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue