Skip to content

Commit de8f4cd

Browse files
committed
Address coderabbit comments
1 parent a8e2caa commit de8f4cd

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

app/src/main/java/com/cornellappdev/score/model/HighlightsRepository.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import android.util.Log
44
import com.apollographql.apollo.ApolloClient
55
import com.example.score.HighlightsQuery
66
import kotlinx.coroutines.CoroutineScope
7+
import kotlinx.coroutines.TimeoutCancellationException
78
import kotlinx.coroutines.flow.MutableStateFlow
89
import kotlinx.coroutines.flow.asStateFlow
910
import kotlinx.coroutines.launch
1011
import kotlinx.coroutines.withTimeout
1112
import javax.inject.Inject
1213
import javax.inject.Singleton
14+
import kotlin.coroutines.cancellation.CancellationException
1315

1416
private const val TIMEOUT_TIME_MILLIS = 5000L
1517

@@ -48,8 +50,13 @@ class HighlightsRepository @Inject constructor(
4850
_highlightsFlow.value = ApiResponse.Error
4951
}
5052

53+
} catch (e: TimeoutCancellationException) {
54+
Log.e("HighlightsRepository", "Highlights request timed out", e)
55+
_highlightsFlow.value = ApiResponse.Error
56+
} catch (e: CancellationException) {
57+
throw e
5158
} catch (e: Exception) {
52-
Log.e("HighlightsRepository", "Error fetching posts: ", e)
59+
Log.e("HighlightsRepository", "Error fetching highlights", e)
5360
_highlightsFlow.value = ApiResponse.Error
5461
}
5562
}

app/src/main/java/com/cornellappdev/score/screen/HighlightsScreen.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import androidx.compose.foundation.layout.Spacer
66
import androidx.compose.foundation.layout.fillMaxSize
77
import androidx.compose.foundation.layout.height
88
import androidx.compose.foundation.layout.padding
9+
import androidx.compose.foundation.rememberScrollState
10+
import androidx.compose.foundation.verticalScroll
911
import androidx.compose.material3.Text
1012
import androidx.compose.runtime.Composable
1113
import androidx.compose.ui.Modifier
@@ -83,6 +85,7 @@ private fun HighlightsScreenContent(
8385
) {
8486
Column(
8587
modifier = Modifier.fillMaxSize()
88+
.verticalScroll(rememberScrollState())
8689
) {
8790
Column(
8891
modifier = Modifier.padding(horizontal = 24.dp)

0 commit comments

Comments
 (0)