some story touch-ups

This commit is contained in:
Austin Huang 2021-06-29 11:07:38 -04:00
parent 7ead5046d9
commit c326356acc
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
2 changed files with 5 additions and 4 deletions

View File

@ -11,10 +11,10 @@ interface StoriesService {
suspend fun fetch(@Path("mediaId") mediaId: Long): String
@GET("/api/v1/feed/reels_tray/")
suspend fun getFeedStories(): ReelsTrayResponse
suspend fun getFeedStories(): ReelsTrayResponse?
@GET("/api/v1/highlights/{uid}/highlights_tray/")
suspend fun fetchHighlights(@Path("uid") uid: Long): ReelsTrayResponse
suspend fun fetchHighlights(@Path("uid") uid: Long): ReelsTrayResponse?
@GET("/api/v1/archive/reel/day_shells/")
suspend fun fetchArchive(@QueryMap queryParams: Map<String, String>): ArchiveResponse?

View File

@ -26,8 +26,8 @@ open class StoriesRepository(private val service: StoriesService) {
suspend fun getFeedStories(): List<Story> {
val response = service.getFeedStories()
val result = response.tray?.toMutableList() ?: mutableListOf()
if (response.broadcasts != null) {
val result: MutableList<Story> = mutableListOf()
if (response?.broadcasts != null) {
val length = response.broadcasts.size
for (i in 0 until length) {
val broadcast = response.broadcasts.get(i)
@ -49,6 +49,7 @@ open class StoriesRepository(private val service: StoriesService) {
)
}
}
if (response?.tray != null) result.addAll(response.tray)
return sort(result.toList())
}