Skip to content

Commit

Permalink
fix: silence TS strict null check errors
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
  • Loading branch information
jerome-benoit committed Aug 2, 2024
1 parent 8bd8050 commit df60841
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions ui/web/src/components/actions/AddChargingStations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
Please select a template
</option>
<option
v-for="template in $templates.value"
v-show="Array.isArray($templates.value) && $templates.value.length > 0"
v-for="template in $templates!.value"
v-show="Array.isArray($templates?.value) && $templates.value.length > 0"
:key="template"
>
{{ template }}
Expand Down Expand Up @@ -85,7 +85,7 @@
@click="
() => {
$uiClient
.addChargingStations(state.template, state.numberOfStations, {
?.addChargingStations(state.template, state.numberOfStations, {
supervisionUrls: state.supervisionUrl.length > 0 ? state.supervisionUrl : undefined,
autoStart: convertToBoolean(state.autoStart),
persistentConfiguration: convertToBoolean(state.persistentConfiguration),
Expand Down Expand Up @@ -135,7 +135,7 @@ const state = ref<{
enableStatistics: false,
})
watch(getCurrentInstance()!.appContext.config.globalProperties.$templates, () => {
watch(getCurrentInstance()!.appContext.config.globalProperties!.$templates, () => {
state.value.renderTemplates = randomUUID()
})
</script>
Expand Down
2 changes: 1 addition & 1 deletion ui/web/src/components/actions/SetSupervisionUrl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@click="
() => {
$uiClient
.setSupervisionUrl(hashId, state.supervisionUrl)
?.setSupervisionUrl(hashId, state.supervisionUrl)
.then(() => {
$toast.success('Supervision url successfully set')
})
Expand Down
2 changes: 1 addition & 1 deletion ui/web/src/components/actions/StartTransaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@click="
() => {
$uiClient
.startTransaction(hashId, convertToInt(connectorId), state.idTag)
?.startTransaction(hashId, convertToInt(connectorId), state.idTag)
.then(() => {
$toast.success('Transaction successfully started')
})
Expand Down
28 changes: 14 additions & 14 deletions ui/web/src/views/ChargingStationsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
if (
getFromLocalStorage<number>('uiServerConfigurationIndex', 0) !== state.uiServerIndex
) {
$uiClient.setConfiguration(
($configuration.value.uiServer as UIServerConfigurationSection[])[
$uiClient?.setConfiguration(
($configuration!.value.uiServer as UIServerConfigurationSection[])[
state.uiServerIndex
]
)
registerWSEventListeners()
$uiClient.registerWSEventListener(
$uiClient?.registerWSEventListener(
'open',
() => {
setToLocalStorage<number>('uiServerConfigurationIndex', state.uiServerIndex)
Expand All @@ -29,15 +29,15 @@
},
{ once: true }
)
$uiClient.registerWSEventListener(
$uiClient?.registerWSEventListener(
'error',
() => {
state.uiServerIndex = getFromLocalStorage<number>(
'uiServerConfigurationIndex',
0
)
$uiClient.setConfiguration(
($configuration.value.uiServer as UIServerConfigurationSection[])[
$uiClient?.setConfiguration(
($configuration!.value.uiServer as UIServerConfigurationSection[])[
getFromLocalStorage<number>('uiServerConfigurationIndex', 0)
]
)
Expand Down Expand Up @@ -99,9 +99,9 @@
/>
</Container>
<CSTable
v-show="Array.isArray($chargingStations.value) && $chargingStations.value.length > 0"
v-show="Array.isArray($chargingStations?.value) && $chargingStations.value.length > 0"
:key="state.renderChargingStations"
:charging-stations="$chargingStations.value"
:charging-stations="$chargingStations!.value"
@need-refresh="
() => {
state.renderAddChargingStations = randomUUID()
Expand Down Expand Up @@ -177,7 +177,7 @@ const clearToggleButtons = (): void => {
const app = getCurrentInstance()
watch(app!.appContext.config.globalProperties.$chargingStations, () => {
watch(app!.appContext.config.globalProperties!.$chargingStations, () => {
state.value.renderChargingStations = randomUUID()
})
Expand All @@ -187,13 +187,13 @@ watch(simulatorState, () => {
const clearTemplates = (): void => {
if (app != null) {
app.appContext.config.globalProperties.$templates.value = []
app.appContext.config.globalProperties.$templates!.value = []
}
}
const clearChargingStations = (): void => {
if (app != null) {
app.appContext.config.globalProperties.$chargingStations.value = []
app.appContext.config.globalProperties.$chargingStations!.value = []
}
}
Expand Down Expand Up @@ -227,7 +227,7 @@ const getTemplates = (): void => {
.listTemplates()
.then((response: ResponsePayload) => {
if (app != null) {
app.appContext.config.globalProperties.$templates.value = response.templates as string[]
app.appContext.config.globalProperties.$templates!.value = response.templates as string[]
}
return undefined
})
Expand All @@ -249,7 +249,7 @@ const getChargingStations = (): void => {
.listChargingStations()
.then((response: ResponsePayload) => {
if (app != null) {
app.appContext.config.globalProperties.$chargingStations.value =
app.appContext.config.globalProperties.$chargingStations!.value =
response.chargingStations as ChargingStationData[]
}
return undefined
Expand Down Expand Up @@ -295,7 +295,7 @@ const uiServerConfigurations: {
index: number
configuration: UIServerConfigurationSection
}[] = (
app?.appContext.config.globalProperties.$configuration.value
app!.appContext.config.globalProperties.$configuration!.value
.uiServer as UIServerConfigurationSection[]
).map((configuration: UIServerConfigurationSection, index: number) => ({
index,
Expand Down

0 comments on commit df60841

Please sign in to comment.