Skip to content

Commit

Permalink
settings-sync: Add workaround to fix the widgets profile editing afte…
Browse files Browse the repository at this point in the history
…r a import sync
  • Loading branch information
rafaellehmkuhl authored and ArturoManzoli committed Aug 14, 2024
1 parent 6f22b1c commit 9e4d882
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/composables/settingsSyncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import {
NoPathInBlueOsErrorName,
setKeyDataOnCockpitVehicleStorage,
} from '@/libs/blueos'
import { isEqual } from '@/libs/utils'
import { isEqual, reloadCockpit } from '@/libs/utils'
import { useDevelopmentStore } from '@/stores/development'
import { useMainVehicleStore } from '@/stores/mainVehicle'
import { useMissionStore } from '@/stores/mission'
import { savedProfilesKey } from '@/stores/widgetManager'

import { useInteractionDialog } from './interactionDialog'
import { openSnackbar } from './snackbar'
Expand Down Expand Up @@ -184,6 +185,20 @@ export function useBlueOsStorage<T>(key: string, defaultValue: MaybeRef<T>): Rem
currentValue.value = valueOnBlueOS as T
const message = `Fetched remote value of key ${key} from the vehicle.`
openSnackbar({ message, duration: 3000, variant: 'success' })

// TODO: This is a workaround to make the profiles work after an import.
// We need to find a better way to handle this, without reloading.
if (key === savedProfilesKey) {
await showDialog({
title: 'Widget profiles imported',
message: `The widget profiles have been imported from the vehicle. We need to reload the page to apply the
changes.`,
variant: 'warning',
actions: [{ text: 'OK', action: closeDialog }],
timer: 3000,
})
reloadCockpit()
}
} else {
await updateValueOnBlueOS(currentValue.value)
const message = `Pushed local value of key ${key} to the vehicle.`
Expand Down
2 changes: 1 addition & 1 deletion src/stores/widgetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {

const { showDialog } = useInteractionDialog()

const savedProfilesKey = 'cockpit-saved-profiles-v8'
export const savedProfilesKey = 'cockpit-saved-profiles-v8'

export const useWidgetManagerStore = defineStore('widget-manager', () => {
const editingMode = ref(false)
Expand Down

0 comments on commit 9e4d882

Please sign in to comment.