Limit the number of pushed shortcuts

This commit is contained in:
Benoit Marty 2021-11-05 12:48:27 +01:00 committed by Benoit Marty
parent f3655d4664
commit e8fb408579
1 changed files with 6 additions and 3 deletions

View File

@ -50,6 +50,7 @@ class ShortcutsHandler @Inject constructor(
) : PinCodeStoreListener {
private val isRequestPinShortcutSupported = ShortcutManagerCompat.isRequestPinShortcutSupported(context)
private val maxShortcutCountPerActivity = ShortcutManagerCompat.getMaxShortcutCountPerActivity(context)
// Value will be set correctly if necessary
private var hasPinCode = AtomicBoolean(true)
@ -101,7 +102,9 @@ class ShortcutsHandler @Inject constructor(
// No shortcut in this case (privacy)
ShortcutManagerCompat.removeAllDynamicShortcuts(context)
} else {
val shortcuts = rooms.mapIndexed { index, room ->
val shortcuts = rooms
.take(maxShortcutCountPerActivity)
.mapIndexed { index, room ->
shortcutCreator.create(room, index)
}