3532: Show badge on conversations tab on new conversations (#3890)
Fixes #3532 (Old PR, now closed: https://github.com/tuskyapp/Tusky/pull/3533) Listens on new notifications and if a "direct mention" is detected a badge (red dot) is shown on the conversations tab if present. I am missing things like this a lot and also big accounts are unhappy with the usability so far: https://mastodon.social/@pallenberg/110129889996182814
This commit is contained in:
parent
ff1c4a4b27
commit
b286255630
9 changed files with 1109 additions and 4 deletions
|
|
@ -4,6 +4,8 @@ import android.app.NotificationManager
|
|||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.annotation.WorkerThread
|
||||
import com.keylesspalace.tusky.appstore.EventHub
|
||||
import com.keylesspalace.tusky.appstore.NewNotificationsEvent
|
||||
import com.keylesspalace.tusky.components.notifications.NotificationHelper.filterNotification
|
||||
import com.keylesspalace.tusky.db.AccountEntity
|
||||
import com.keylesspalace.tusky.db.AccountManager
|
||||
|
|
@ -46,7 +48,8 @@ data class Links(val next: String?, val prev: String?) {
|
|||
class NotificationFetcher @Inject constructor(
|
||||
private val mastodonApi: MastodonApi,
|
||||
private val accountManager: AccountManager,
|
||||
private val context: Context
|
||||
private val context: Context,
|
||||
private val eventHub: EventHub
|
||||
) {
|
||||
suspend fun fetchAndShow() {
|
||||
for (account in accountManager.getAllAccountsOrderedByActive()) {
|
||||
|
|
@ -60,6 +63,10 @@ class NotificationFetcher @Inject constructor(
|
|||
.sortedWith(compareBy({ it.id.length }, { it.id })) // oldest notifications first
|
||||
.toMutableList()
|
||||
|
||||
// TODO do this before filter above? But one could argue that (for example) a tab badge is also a notification
|
||||
// (and should therefore adhere to the notification config).
|
||||
eventHub.dispatch(NewNotificationsEvent(account.accountId, notifications))
|
||||
|
||||
// There's a maximum limit on the number of notifications an Android app
|
||||
// can display. If the total number of notifications (current notifications,
|
||||
// plus new ones) exceeds this then some newer notifications will be dropped.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue