Merge pull request #1415 from obfusk/fix-shortcuts

ShortcutHelper: trim after skipping missing cards
This commit is contained in:
Sylvia van Os
2023-07-11 19:31:18 +02:00
committed by GitHub

View File

@@ -70,15 +70,8 @@ class ShortcutHelper {
ShortcutInfoCompat found = list.remove(foundIndex.intValue());
list.addFirst(found);
} else {
// The item is new to the list. First, we need to trim the list
// until it is able to accept a new item, then the item is
// inserted.
while (list.size() >= MAX_SHORTCUTS) {
list.pollLast();
}
// The item is new to the list. We add it and trim the list later.
ShortcutInfoCompat shortcut = createShortcutBuilder(context, card).build();
list.addFirst(shortcut);
}
@@ -99,6 +92,11 @@ class ShortcutHelper {
finalList.addLast(updatedShortcut);
rank++;
// trim the list
if (rank >= MAX_SHORTCUTS) {
break;
}
}
}