Skip to content

Commit

Permalink
defaults: Fix once and for all (?) the global address
Browse files Browse the repository at this point in the history
This solves the case of the electron app (which has "localhost" as hostname) not automatically connecting.

It also automatically removes the protocol part of the address if for some reason it got there.
  • Loading branch information
rafaellehmkuhl authored and ArturoManzoli committed Oct 17, 2024
1 parent a02192a commit 287a709
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/assets/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const defaultMiniWidgetManagerVars: MiniWidgetManagerVars = {

const hostname = window.location.hostname
export const defaultBlueOsAddress = 'http://blueos-avahi.local'
export const defaultGlobalAddress = hostname == '' || hostname == undefined ? defaultBlueOsAddress : hostname
export const defaultGlobalAddress = !hostname || hostname == 'localhost' ? defaultBlueOsAddress : hostname
export const defaultUIGlassColor = { opacity: 0.8, bgColor: '#4F4F4F1A', fontColor: '#FFFFFF', blur: 25 }
export const widgetProfiles: Profile[] = [
{
Expand Down
13 changes: 12 additions & 1 deletion src/stores/mainVehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,18 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
const ws_protocol = location?.protocol === 'https:' ? 'wss' : 'ws'

const cpuLoad = ref<number>()
const globalAddress = useStorage('cockpit-vehicle-address', defaultGlobalAddress)
const rawGlobalAddress = useStorage('cockpit-vehicle-address', defaultGlobalAddress)
const globalAddress = computed({
get() {
if (rawGlobalAddress.value.includes('://')) {
return rawGlobalAddress.value.split('://')[1]
}
return rawGlobalAddress.value
},
set(newValue) {
rawGlobalAddress.value = newValue
},
})

const defaultMainConnectionURI = computed(() => `${ws_protocol}://${globalAddress.value}/mavlink2rest/ws/mavlink`)
const defaultWebRTCSignallingURI = computed(() => `${ws_protocol}://${globalAddress.value}:6021/`)
Expand Down

0 comments on commit 287a709

Please sign in to comment.