Skip to content

Commit

Permalink
Fix crash on new shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
yostyle committed Sep 11, 2023
1 parent e8126d2 commit bd2f7fc
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,20 @@ class ShortcutsHandler @Inject constructor(
}

private fun createShortcuts(rooms: List<RoomSummary>) {
if (hasPinCode.get()) {
// No shortcut in this case (privacy)
ShortcutManagerCompat.removeAllDynamicShortcuts(context)
} else {
val shortcuts = rooms
.take(maxShortcutCountPerActivity)
.mapIndexed { index, room ->
shortcutCreator.create(room, index)
}
// Tchap: remove all shortcuts before add others to avoid exceeding max shortcuts count per activity.
ShortcutManagerCompat.removeAllDynamicShortcuts(context)

shortcuts.forEach { shortcut ->
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
}
// No shortcut in this case (privacy)
if (hasPinCode.get()) return

val shortcuts = rooms
.take(maxShortcutCountPerActivity)
.mapIndexed { index, room ->
shortcutCreator.create(room, index)
}

shortcuts.forEach { shortcut ->
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
}
}

Expand Down

0 comments on commit bd2f7fc

Please sign in to comment.