-
-
Notifications
You must be signed in to change notification settings - Fork 34
🐛 - Cap home shortcuts to 4 to prevent Android crash #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -76,17 +76,23 @@ export const useFavoritesStore = create<FavoritesStore>((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), | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The expression
Suggested change
|
||||||
| iconName: "star", | ||||||
| data: { | ||||||
| originId: route.originId, | ||||||
| destinationId: route.destinationId, | ||||||
| }, | ||||||
| })), | ||||||
| ) | ||||||
| }, | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While defining the constant here works, it's generally better practice to define configuration constants like
MAX_HOME_SHORTCUTSat the top level of the file. This improves visibility and maintainability, especially if the value needs to be referenced elsewhere in the future.