A cheap attempt at a native Bluesky client for Android

Models: again, fix replyToNotFollowing block logic

+22 -44
+22 -44
app/src/main/java/industries/geesawra/monarch/datalayer/Models.kt
··· 117 117 follower = post.post.author.viewer?.followedBy != null, 118 118 ) 119 119 120 - sd.replyToNotFollowing = when (sd.reason) { 121 - is FeedViewPostReasonUnion.ReasonPin -> false 122 - is FeedViewPostReasonUnion.ReasonRepost -> false 123 - is FeedViewPostReasonUnion.Unknown -> false 124 - else -> { 125 - val (parent, _) = sd.parent() 126 - val root = sd.root() 120 + sd.replyToNotFollowing = run { 121 + when (sd.reason) { 122 + is FeedViewPostReasonUnion.ReasonPin, 123 + FeedViewPostReasonUnion.Unknown, 124 + FeedViewPostReasonUnion.ReasonRepost -> false 125 + 126 + else -> { 127 + val (parent, _) = sd.parent() 128 + val root = sd.root() 129 + 130 + parent?.let { 131 + val parentFollowing = parent.following 132 + val rootFollowing = root?.following ?: false 133 + 134 + if (!parentFollowing && root == null) { 135 + return@run false 136 + } 127 137 128 - parent?.let { 129 - val parentFollowing = parent.following 130 - val rootFollowing = root?.following ?: false 138 + val res = parentFollowing || rootFollowing 139 + return@run !res 140 + } 131 141 132 - val res = parentFollowing || rootFollowing 133 - !res 142 + return@run false 134 143 } 135 - 136 - false 137 144 } 138 145 } 139 146 ··· 430 437 431 438 data class Notifications( 432 439 var list: List<Notification> = listOf() 433 - ) { 434 - // fun likes() { 435 - // val likes = mutableMapOf<Post, RepeatedNotification>() 436 - // list.forEach { 437 - // when (it) { 438 - // is Notification.Like -> { 439 - // if (likes.contains(it.post)) { 440 - // val l = likes[it.post]!! 441 - // l.authors += RepeatedAuthor(it.author, it.createdAt) 442 - // if (it.createdAt > l.timestamp) { 443 - // l.timestamp = it.createdAt 444 - // } 445 - // likes[it.post] = l 446 - // } else { 447 - // likes[it.post] = RepeatedNotification( 448 - // kind = RepeatableNotification.Like, 449 - // authors = listOf(RepeatedAuthor(it.author, it.createdAt)), 450 - // timestamp = it.createdAt 451 - // ) 452 - // } 453 - // } 454 - // 455 - // else -> null 456 - // } 457 - // } 458 - // 459 - // val asd = likes.entries.sortedByDescending { it.value.timestamp }.associate { it.toPair() } 460 - // Log.d("likes", likes.toString()) 461 - // } 462 - } 440 + ) 463 441 464 442 enum class RepeatableNotification(val u: Unit) { 465 443 Like(Unit),