Poll fixes (#1238)

* update cache when voting on a poll

* fix poll controls color

* don't allow voting on old poll from cache

* check for RecyclerView.NO_POSITION in click listener

* fix crash when voting in a boosted poll
This commit is contained in:
Konrad Pozniak 2019-05-05 08:26:17 +02:00 committed by GitHub
commit b8c32a96de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 85 additions and 31 deletions

View file

@ -1,5 +1,6 @@
package com.keylesspalace.tusky.appstore
import com.google.gson.Gson
import com.keylesspalace.tusky.db.AccountManager
import com.keylesspalace.tusky.db.AppDatabase
import io.reactivex.Single
@ -10,7 +11,8 @@ import javax.inject.Inject
class CacheUpdater @Inject constructor(
eventHub: EventHub,
accountManager: AccountManager,
private val appDatabase: AppDatabase
private val appDatabase: AppDatabase,
gson: Gson
) {
private val disposable: Disposable
@ -28,6 +30,10 @@ class CacheUpdater @Inject constructor(
timelineDao.removeAllByUser(accountId, event.accountId)
is StatusDeletedEvent ->
timelineDao.delete(accountId, event.statusId)
is PollVoteEvent -> {
val pollString = gson.toJson(event.poll)
timelineDao.setVoted(accountId, event.statusId, pollString)
}
}
}
}