Skip to content

Commit 60b52a5

Browse files
add vehicle type filtering
1 parent d924cab commit 60b52a5

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/components/ExternalFeaturesDiscoveryModal.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,18 @@ interface FilteredExtensionGroups {
865865
suggestionGroups: JoystickMapSuggestionGroup[]
866866
}
867867
868+
/**
869+
* Check if a suggestion group targets the currently selected joystick profile
870+
* @param {JoystickMapSuggestionGroup} group - The group to evaluate
871+
* @returns {boolean} True when the group is compatible with the selected profile
872+
*/
873+
const suggestionGroupMatchesSelectedProfile = (group: JoystickMapSuggestionGroup): boolean => {
874+
if (!group.target?.length) return true
875+
if (!selectedProfileHash.value) return false
876+
877+
return group.target.includes(selectedProfileHash.value)
878+
}
879+
868880
/**
869881
* Helper to filter suggestion groups within an extension by a predicate
870882
* @param {JoystickMapSuggestionGroupsFromExtension} extensionGroup - The extension group to filter
@@ -877,6 +889,7 @@ const filterExtensionGroups = (
877889
): FilteredExtensionGroups => ({
878890
extensionName: extensionGroup.extensionName,
879891
suggestionGroups: extensionGroup.suggestionGroups
892+
.filter((group) => suggestionGroupMatchesSelectedProfile(group))
880893
.map((group) => ({
881894
...group,
882895
buttonMappingSuggestions: group.buttonMappingSuggestions.filter(predicate),

src/libs/blueos/schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const JoystickMapSuggestionGroupSchema = z.object({
101101
id: z.string(),
102102
name: z.string(),
103103
buttonMappingSuggestions: z.array(JoystickButtonMappingSuggestionSchema),
104+
targetVehicleTypes: z.array(z.string()).optional(),
104105
version: z.string().optional(),
105106
})
106107

src/types/joystick.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ export interface JoystickMapSuggestionGroup {
581581
* List of button mapping suggestions in this group
582582
*/
583583
buttonMappingSuggestions: JoystickMapSuggestion[]
584+
/**
585+
* Optional list of joystick profile hashes this group targets
586+
*/
587+
targetVehicleTypes?: string[]
584588
}
585589

586590
/**

0 commit comments

Comments
 (0)