From b3f4b0235283b539c10335438a83047699534760 Mon Sep 17 00:00:00 2001 From: Guy Tepper Date: Sun, 17 May 2026 21:48:11 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20-=20Cap=20home=20shortcuts=20to?= =?UTF-8?q?=204=20to=20prevent=20Android=20crash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/favorites/favorites.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/app/models/favorites/favorites.ts b/app/models/favorites/favorites.ts index 1ccc533b..3506e8ba 100644 --- a/app/models/favorites/favorites.ts +++ b/app/models/favorites/favorites.ts @@ -76,17 +76,23 @@ export const useFavoritesStore = create((set, get) => ({ const toText = (route: FavoriteRoute) => translate("favorites.toStation", { stationName: stationsObject[route.destinationId][stationLocale] }) + // Both iOS quick actions and Android dynamic shortcuts cap at ~4-5 per app; + // some Android devices report lower limits and throw if exceeded. + const MAX_HOME_SHORTCUTS = 4 + Shortcuts.setShortcuts( - get().routes.map((route) => ({ - type: `favorite-${route.id}`, - title: route.label || fromText(route), - subtitle: !route.label && toText(route), - iconName: "star", - data: { - originId: route.originId, - destinationId: route.destinationId, - }, - })), + get() + .routes.slice(0, MAX_HOME_SHORTCUTS) + .map((route) => ({ + type: `favorite-${route.id}`, + title: route.label || fromText(route), + subtitle: !route.label && toText(route), + iconName: "star", + data: { + originId: route.originId, + destinationId: route.destinationId, + }, + })), ) },