Skip to content

Commit 8516690

Browse files
committed
pr comments
1 parent a777c77 commit 8516690

8 files changed

Lines changed: 20 additions & 17 deletions

File tree

data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Status.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ data class Status(
2626
@SerialName("visibility") val visibility: Privacy,
2727
@SerialName("sensitive") val sensitive: Boolean,
2828
@SerialName("spoiler_text") val spoilerText: String,
29-
@SerialName("media_attachments") val mediaAttachments: List<Attachment>? = emptyList(),
29+
@SerialName("media_attachments") val mediaAttachments: List<Attachment>? = null,
3030
@SerialName("application") val application: Application? = null,
3131

3232
// rendering attributes

data/repository/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ kotlin {
1818
implementation(projects.domain.timeline)
1919
implementation(libs.io.insert.koin.core)
2020
implementation(libs.kotlinx.coroutines.core)
21-
//temp until we map to UI models
21+
//TODO remove as api dependency once we can stop dependening on StoreResponse in UI
2222
api(libs.store)
2323
implementation(libs.com.squareup.sqldelight.coroutines.extensions)
2424
}

data/repository/src/commonMain/kotlin/social/androiddev/common/repository/timeline/ModelMappers.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import social.androiddev.common.network.model.Status
1313
import social.androiddev.common.timeline.StatusDB
1414
import social.androiddev.domain.timeline.FeedType
1515
import social.androiddev.domain.timeline.model.StatusLocal
16+
import social.androiddev.domain.timeline.model.Visibility
1617

1718
fun StatusDB.toLocal(
1819
key: FeedType
@@ -26,7 +27,7 @@ fun StatusDB.toLocal(
2627
content = content,
2728
sensitive = sensitive ?: false,
2829
spoilerText = spoilerText,
29-
visibility = visibility,
30+
visibility = Visibility.valueOf(visibility),
3031
avatarUrl = avatarUrl,
3132
accountAddress = accountAddress,
3233
userName = userName

data/repository/src/commonMain/kotlin/social/androiddev/common/repository/timeline/TimelineFetcher.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ import social.androiddev.common.network.MastodonApi
1414
import social.androiddev.common.persistence.localstorage.DodoAuthStorage
1515
import social.androiddev.common.timeline.StatusDB
1616
import social.androiddev.domain.timeline.FeedType
17-
1817
/**
1918
* Wrapper for [MastodonApi.getHomeFeed] while also getting an auth token from storage
2019
* and mapping result to list of [StatusDB]
2120
*/
22-
2321
fun MastodonApi.timelineFetcher(authStorage: DodoAuthStorage): Fetcher<FeedType, List<StatusDB>> =
2422
Fetcher.of { key: FeedType ->
2523
when (key) {
@@ -32,4 +30,4 @@ fun MastodonApi.timelineFetcher(authStorage: DodoAuthStorage): Fetcher<FeedType,
3230
.map { it.statusDB() }
3331
}
3432
}
35-
}
33+
}

data/repository/src/commonTest/kotlin/social/androiddev/common/repository/timeline/RealHomeTimelineRepositoryTest.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ import kotlin.test.assertTrue
1919
import kotlin.test.fail
2020

2121

22-
class RealHomeTimelineRepositoryTest{
23-
@Test fun sucessTest(): TestResult {
24-
return runTest{
22+
class RealHomeTimelineRepositoryTest {
23+
@Test
24+
fun sucessTest(): TestResult {
25+
return runTest {
2526
val testRepo = RealHomeTimelineRepository(fakeSuccessStore)
2627
val result = testRepo.read(FeedType.Home).first()
2728
assertTrue { result is StoreResponse.Data }
@@ -30,16 +31,18 @@ class RealHomeTimelineRepositoryTest{
3031
}
3132
}
3233

33-
@Test fun failureTest(): TestResult {
34-
return runTest{
34+
@Test
35+
fun failureTest(): TestResult {
36+
return runTest {
3537
val testRepo = RealHomeTimelineRepository(fakeFailureStore)
3638
val result = testRepo.read(FeedType.Home).first()
3739
assertTrue { result is StoreResponse.Error.Message }
38-
assertTrue { result.errorMessageOrNull() == failureResponse.message}
40+
assertTrue { result.errorMessageOrNull() == failureResponse.message }
3941

4042
}
4143
}
4244
}
45+
4346
val fakeSuccessStore = object : Store<FeedType, List<StatusLocal>> {
4447
override suspend fun clear(key: FeedType) {
4548
TODO("Not yet implemented")

data/repository/src/commonTest/kotlin/social/androiddev/common/repository/timeline/fixtures/TestFixtures.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import social.androiddev.common.network.model.Token
2222
import social.androiddev.common.persistence.localstorage.DodoAuthStorage
2323
import social.androiddev.domain.timeline.FeedType
2424
import social.androiddev.domain.timeline.model.StatusLocal
25+
import social.androiddev.domain.timeline.model.Visibility
2526

2627
val fakeStorage = object : DodoAuthStorage {
2728
override var currentDomain: String? = "androiddev.social"
@@ -47,7 +48,7 @@ val fakeLocalStatus = StatusLocal(
4748
null,
4849
false,
4950
"",
50-
"",
51+
Visibility.UNLISTED,
5152
"",
5253
"",
5354
""

domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/StatusLocal.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ data class StatusLocal(
2222
val account: Account? = null,
2323
val sensitive: Boolean = false,
2424
val spoilerText: String? = null,
25-
val visibility: String = "Public",
25+
val visibility: Visibility = Visibility.UNLISTED,
2626
val avatarUrl: String = "",
2727
val accountAddress: String = "",
2828
val userName: String

ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/TimelineViewModel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class TimelineViewModel(
4040
.mapLatest(::render)
4141
.stateIn(scope, SharingStarted.Eagerly, StoreResponse.Loading(ResponseOrigin.Cache))
4242

43-
private fun render(it: StoreResponse<List<StatusLocal>>): StoreResponse.Data<List<FeedItemState>> {
44-
return when (val response: StoreResponse<List<StatusLocal>> = it) {
43+
private fun render(response: StoreResponse<List<StatusLocal>>): StoreResponse.Data<List<FeedItemState>> {
44+
return when (response) {
4545
is StoreResponse.Data -> {
4646
val result = StoreResponse.Data(
4747
response.value.map {
@@ -62,7 +62,7 @@ class TimelineViewModel(
6262
}
6363

6464
else -> {
65-
StoreResponse.Data(emptyList(), it.origin)
65+
StoreResponse.Data(emptyList(), response.origin)
6666
}
6767
}
6868
}

0 commit comments

Comments
 (0)