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

This commit is contained in:
Konrad Pozniak 2019-07-10 06:52:13 +02:00 committed by GitHub
parent d4ec0bb101
commit db369aec75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View file

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

View file

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