diff --git a/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/SpotlessPlugin.kt b/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/SpotlessPlugin.kt index 35132476..614e0187 100644 --- a/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/SpotlessPlugin.kt +++ b/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/SpotlessPlugin.kt @@ -46,6 +46,6 @@ class SpotlessPlugin : Plugin { } private companion object { - private const val KTFMT_VERSION = "0.43" + private const val KTFMT_VERSION = "0.44" } } diff --git a/common/src/main/kotlin/dev/msfjarvis/claw/common/NetworkState.kt b/common/src/main/kotlin/dev/msfjarvis/claw/common/NetworkState.kt index 4252a892..96446295 100644 --- a/common/src/main/kotlin/dev/msfjarvis/claw/common/NetworkState.kt +++ b/common/src/main/kotlin/dev/msfjarvis/claw/common/NetworkState.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2021-2022 Harsh Shandilya. + * Copyright © 2021-2023 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. @@ -8,6 +8,8 @@ package dev.msfjarvis.claw.common internal sealed class NetworkState { class Success(val data: T) : NetworkState() + class Error(val error: Throwable, val description: String) : NetworkState() + object Loading : NetworkState() } diff --git a/common/src/main/kotlin/dev/msfjarvis/claw/common/posts/LobstersCard.kt b/common/src/main/kotlin/dev/msfjarvis/claw/common/posts/LobstersCard.kt index 4f5453d9..f9c1016c 100644 --- a/common/src/main/kotlin/dev/msfjarvis/claw/common/posts/LobstersCard.kt +++ b/common/src/main/kotlin/dev/msfjarvis/claw/common/posts/LobstersCard.kt @@ -258,9 +258,13 @@ fun LobstersCardPreview() { postActions = object : PostActions { override fun viewPost(postUrl: String, commentsUrl: String) {} + override fun viewComments(postId: String) {} + override fun viewCommentsPage(commentsUrl: String) {} + override fun toggleSave(post: SavedPost) {} + override suspend fun getComments(postId: String): LobstersPostDetails { return LobstersPostDetails( shortId = "ooga", @@ -275,6 +279,7 @@ fun LobstersCardPreview() { comments = emptyList(), ) } + override suspend fun getLinkMetadata(url: String): LinkMetadata { return LinkMetadata("", "", "") } diff --git a/common/src/main/kotlin/dev/msfjarvis/claw/common/posts/PostActions.kt b/common/src/main/kotlin/dev/msfjarvis/claw/common/posts/PostActions.kt index 56d13ba3..bec39e0b 100644 --- a/common/src/main/kotlin/dev/msfjarvis/claw/common/posts/PostActions.kt +++ b/common/src/main/kotlin/dev/msfjarvis/claw/common/posts/PostActions.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2021-2022 Harsh Shandilya. + * Copyright © 2021-2023 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,9 +14,14 @@ import dev.msfjarvis.claw.model.LobstersPostDetails @Stable interface PostActions { fun viewPost(postUrl: String, commentsUrl: String) + fun viewComments(postId: String) + fun viewCommentsPage(commentsUrl: String) + fun toggleSave(post: SavedPost) + suspend fun getComments(postId: String): LobstersPostDetails + suspend fun getLinkMetadata(url: String): LinkMetadata } diff --git a/coroutine-utils/src/main/kotlin/dev/msfjarvis/claw/util/coroutines/DispatcherProvider.kt b/coroutine-utils/src/main/kotlin/dev/msfjarvis/claw/util/coroutines/DispatcherProvider.kt index 59570f14..f5440533 100644 --- a/coroutine-utils/src/main/kotlin/dev/msfjarvis/claw/util/coroutines/DispatcherProvider.kt +++ b/coroutine-utils/src/main/kotlin/dev/msfjarvis/claw/util/coroutines/DispatcherProvider.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2022 Harsh Shandilya. + * Copyright © 2022-2023 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. @@ -18,9 +18,13 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi interface DispatcherProvider { fun main(): CoroutineDispatcher = Dispatchers.Main + fun default(): CoroutineDispatcher = Dispatchers.Default + fun io(): CoroutineDispatcher = Dispatchers.IO + fun unconfined(): CoroutineDispatcher = Dispatchers.Unconfined + fun database(): CoroutineDispatcher = Dispatchers.IO.limitedParallelism(1) } diff --git a/database/src/test/kotlin/dev/msfjarvis/claw/database/local/PostCommentsQueriesTest.kt b/database/src/test/kotlin/dev/msfjarvis/claw/database/local/PostCommentsQueriesTest.kt index 823cc57b..486ae1f3 100644 --- a/database/src/test/kotlin/dev/msfjarvis/claw/database/local/PostCommentsQueriesTest.kt +++ b/database/src/test/kotlin/dev/msfjarvis/claw/database/local/PostCommentsQueriesTest.kt @@ -17,6 +17,7 @@ import java.util.UUID class PostCommentsQueriesTest : FunSpec() { private lateinit var postQueries: PostCommentsQueries + init { beforeEach { val driver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY)