Remove dead shortcuts

This commit is contained in:
David Teresi 2021-07-05 14:13:32 -04:00
parent 69d0ed3fb8
commit 996b4e7a45

View File

@ -49,6 +49,13 @@ class ShortcutsHandler @Inject constructor(
)
?.asObservable()
?.subscribe { rooms ->
// Remove dead shortcuts (i.e. deleted rooms)
val roomIds = rooms.map { it.roomId }
val deadShortcutIds = ShortcutManagerCompat.getShortcuts(context, ShortcutManagerCompat.FLAG_MATCH_DYNAMIC)
.map { it.id }
.filter { !roomIds.contains(it) }
ShortcutManagerCompat.removeLongLivedShortcuts(context, deadShortcutIds)
val shortcuts = rooms
.sortedBy { room ->
// pushDynamicShortcut adds each shortcut to the top of the shortcut ranking,