From 29068fd72e2f3b7f86c55d47b57d103811aa9e8a Mon Sep 17 00:00:00 2001 From: susonthapa <33973551+susonthapa@users.noreply.github.com> Date: Tue, 11 Jul 2023 18:56:07 +0545 Subject: [PATCH 1/2] fixed config being out of sync if updated from functions --- .../react-native-carplay/src/templates/InformationTemplate.ts | 2 ++ packages/react-native-carplay/src/templates/ListTemplate.ts | 2 ++ packages/react-native-carplay/src/templates/MapTemplate.ts | 2 ++ packages/react-native-carplay/src/templates/TabBarTemplate.ts | 1 + 4 files changed, 7 insertions(+) diff --git a/packages/react-native-carplay/src/templates/InformationTemplate.ts b/packages/react-native-carplay/src/templates/InformationTemplate.ts index 55d40e83..e6358fde 100644 --- a/packages/react-native-carplay/src/templates/InformationTemplate.ts +++ b/packages/react-native-carplay/src/templates/InformationTemplate.ts @@ -31,10 +31,12 @@ export class InformationTemplate extends Template { } public updateInformationTemplateItems = (items: InformationItem[]) => { + this.config.items = items return CarPlay.bridge.updateInformationTemplateItems(this.id, this.parseConfig(items)); }; public updateInformationTemplateActions = (actions: InformationAction[]) => { + this.config.actions = actions return CarPlay.bridge.updateInformationTemplateActions(this.id, this.parseConfig(actions)); }; } diff --git a/packages/react-native-carplay/src/templates/ListTemplate.ts b/packages/react-native-carplay/src/templates/ListTemplate.ts index 0d8f121b..47baa498 100644 --- a/packages/react-native-carplay/src/templates/ListTemplate.ts +++ b/packages/react-native-carplay/src/templates/ListTemplate.ts @@ -98,10 +98,12 @@ export class ListTemplate extends Template { } public updateSections = (sections: ListSection[]) => { + this.config.sections = sections return CarPlay.bridge.updateListTemplateSections(this.id, this.parseConfig(sections)); }; public updateListTemplateItem = (config: ListItemUpdate) => { + this.config.sections[config.sectionIndex].items[config.itemIndex] = config return CarPlay.bridge.updateListTemplateItem(this.id, this.parseConfig(config)); }; diff --git a/packages/react-native-carplay/src/templates/MapTemplate.ts b/packages/react-native-carplay/src/templates/MapTemplate.ts index 66198284..e45a5404 100644 --- a/packages/react-native-carplay/src/templates/MapTemplate.ts +++ b/packages/react-native-carplay/src/templates/MapTemplate.ts @@ -119,10 +119,12 @@ export class MapTemplate extends Template { * Update MapTemplate configuration */ public updateConfig(config: MapTemplateConfig) { + this.config = config CarPlay.bridge.updateMapTemplateConfig(this.id, this.parseConfig(config)); } public updateMapButtons(mapButtons: MapButton[]) { + this.config.mapButtons = mapButtons CarPlay.bridge.updateMapTemplateMapButtons(this.id, this.parseConfig(mapButtons)); } diff --git a/packages/react-native-carplay/src/templates/TabBarTemplate.ts b/packages/react-native-carplay/src/templates/TabBarTemplate.ts index 9433f41a..c61ea054 100644 --- a/packages/react-native-carplay/src/templates/TabBarTemplate.ts +++ b/packages/react-native-carplay/src/templates/TabBarTemplate.ts @@ -46,6 +46,7 @@ export class TabBarTemplate extends Template { } public updateTemplates = (config: TabBarTemplateConfig) => { + this.config = config return CarPlay.bridge.updateTabBarTemplates(this.id, this.parseConfig(config)); }; } From 6e1017eeef4a667a6370e32c21b1739868ffa4d7 Mon Sep 17 00:00:00 2001 From: susonthapa <33973551+susonthapa@users.noreply.github.com> Date: Tue, 11 Jul 2023 19:16:34 +0545 Subject: [PATCH 2/2] fixed lint issues --- .../react-native-carplay/src/templates/InformationTemplate.ts | 4 ++-- packages/react-native-carplay/src/templates/ListTemplate.ts | 4 ++-- packages/react-native-carplay/src/templates/MapTemplate.ts | 4 ++-- packages/react-native-carplay/src/templates/TabBarTemplate.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/react-native-carplay/src/templates/InformationTemplate.ts b/packages/react-native-carplay/src/templates/InformationTemplate.ts index e6358fde..71fc453b 100644 --- a/packages/react-native-carplay/src/templates/InformationTemplate.ts +++ b/packages/react-native-carplay/src/templates/InformationTemplate.ts @@ -31,12 +31,12 @@ export class InformationTemplate extends Template { } public updateInformationTemplateItems = (items: InformationItem[]) => { - this.config.items = items + this.config.items = items; return CarPlay.bridge.updateInformationTemplateItems(this.id, this.parseConfig(items)); }; public updateInformationTemplateActions = (actions: InformationAction[]) => { - this.config.actions = actions + this.config.actions = actions; return CarPlay.bridge.updateInformationTemplateActions(this.id, this.parseConfig(actions)); }; } diff --git a/packages/react-native-carplay/src/templates/ListTemplate.ts b/packages/react-native-carplay/src/templates/ListTemplate.ts index 47baa498..3123a389 100644 --- a/packages/react-native-carplay/src/templates/ListTemplate.ts +++ b/packages/react-native-carplay/src/templates/ListTemplate.ts @@ -98,12 +98,12 @@ export class ListTemplate extends Template { } public updateSections = (sections: ListSection[]) => { - this.config.sections = sections + this.config.sections = sections; return CarPlay.bridge.updateListTemplateSections(this.id, this.parseConfig(sections)); }; public updateListTemplateItem = (config: ListItemUpdate) => { - this.config.sections[config.sectionIndex].items[config.itemIndex] = config + this.config.sections[config.sectionIndex].items[config.itemIndex] = config; return CarPlay.bridge.updateListTemplateItem(this.id, this.parseConfig(config)); }; diff --git a/packages/react-native-carplay/src/templates/MapTemplate.ts b/packages/react-native-carplay/src/templates/MapTemplate.ts index e45a5404..a8e75e83 100644 --- a/packages/react-native-carplay/src/templates/MapTemplate.ts +++ b/packages/react-native-carplay/src/templates/MapTemplate.ts @@ -119,12 +119,12 @@ export class MapTemplate extends Template { * Update MapTemplate configuration */ public updateConfig(config: MapTemplateConfig) { - this.config = config + this.config = config; CarPlay.bridge.updateMapTemplateConfig(this.id, this.parseConfig(config)); } public updateMapButtons(mapButtons: MapButton[]) { - this.config.mapButtons = mapButtons + this.config.mapButtons = mapButtons; CarPlay.bridge.updateMapTemplateMapButtons(this.id, this.parseConfig(mapButtons)); } diff --git a/packages/react-native-carplay/src/templates/TabBarTemplate.ts b/packages/react-native-carplay/src/templates/TabBarTemplate.ts index c61ea054..674f521f 100644 --- a/packages/react-native-carplay/src/templates/TabBarTemplate.ts +++ b/packages/react-native-carplay/src/templates/TabBarTemplate.ts @@ -46,7 +46,7 @@ export class TabBarTemplate extends Template { } public updateTemplates = (config: TabBarTemplateConfig) => { - this.config = config + this.config = config; return CarPlay.bridge.updateTabBarTemplates(this.id, this.parseConfig(config)); }; }