fix timeline reloading and favs/boosts/polls showing up at wrong pos (#1374)

main
Konrad Pozniak 5 years ago committed by GitHub
parent 934d313cb3
commit 0581b51999
  1. 6
      app/src/main/java/com/keylesspalace/tusky/db/TimelineDao.kt
  2. 9
      app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java

@ -74,12 +74,12 @@ AND
abstract fun removeAllPlaceholdersBetween(account: Long, maxId: String, sinceId: String)
@Query("""UPDATE TimelineStatusEntity SET favourited = :favourited
WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId - :statusId)""")
WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""")
abstract fun setFavourited(accountId: Long, statusId: String, favourited: Boolean)
@Query("""UPDATE TimelineStatusEntity SET reblogged = :reblogged
WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId - :statusId)""")
WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""")
abstract fun setReblogged(accountId: Long, statusId: String, reblogged: Boolean)
@Query("""DELETE FROM TimelineStatusEntity WHERE timelineUserId = :accountId AND
@ -101,6 +101,6 @@ AND authorServerId != :accountServerId AND createdAt < :olderThan""")
abstract fun cleanup(accountId: Long, accountServerId: String, olderThan: Long)
@Query("""UPDATE TimelineStatusEntity SET poll = :poll
WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId - :statusId)""")
WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""")
abstract fun setVoted(accountId: Long, statusId: String, poll: String)
}

@ -301,20 +301,21 @@ public class TimelineFragment extends SFragment implements
if (!statuses.isEmpty()) {
filterStatuses(statuses);
if (!this.statuses.isEmpty() && topId != null) {
// clear old cached statuses
Iterator<Either<Placeholder, Status>> iterator = statuses.iterator();
Iterator<Either<Placeholder, Status>> iterator = this.statuses.iterator();
while (iterator.hasNext()) {
Either<Placeholder, Status> item = iterator.next();
if(item.isRight()) {
Status status = item.asRight();
if (status.getId().length() < topId.length() || status.getId().compareTo(topId) <= 0) {
if (status.getId().length() < topId.length() || status.getId().compareTo(topId) < 0) {
iterator.remove();
}
} else {
Placeholder placeholder = item.asLeft();
if (placeholder.getId().length() < topId.length() || placeholder.getId().compareTo(topId) <= 0) {
if (placeholder.getId().length() < topId.length() || placeholder.getId().compareTo(topId) < 0) {
iterator.remove();
}
}

Loading…
Cancel
Save