Browse Source

some story touch-ups

renovate/org.robolectric-robolectric-4.x
Austin Huang 3 years ago
parent
commit
c326356acc
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 4
      app/src/main/java/awais/instagrabber/repositories/StoriesService.kt
  2. 5
      app/src/main/java/awais/instagrabber/webservices/StoriesRepository.kt

4
app/src/main/java/awais/instagrabber/repositories/StoriesService.kt

@ -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?

5
app/src/main/java/awais/instagrabber/webservices/StoriesRepository.kt

@ -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())
}

Loading…
Cancel
Save