Skip to content

Commit bf4fb71

Browse files
core: frontend: store: Use new isBackendOffline
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
1 parent 5706b50 commit bf4fb71

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

core/frontend/src/store/bag.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { StatusCodes } from 'http-status-codes'
22

33
import Notifier from '@/libs/notifier'
44
import { bag_of_holding_service } from '@/types/frontend_services'
5-
import back_axios, { backend_offline_error } from '@/utils/api'
5+
import back_axios, { isBackendOffline } from '@/utils/api'
66

77
const notifier = new Notifier(bag_of_holding_service)
88

@@ -27,7 +27,7 @@ class BagOfHoldingStore {
2727
})
2828
.then(() => true)
2929
.catch((error) => {
30-
if (error === backend_offline_error) {
30+
if (isBackendOffline(error)) {
3131
return false
3232
}
3333
const message = `Could not overwrite database: ${error.message ?? error.response?.data}.`
@@ -45,7 +45,7 @@ class BagOfHoldingStore {
4545
})
4646
.then(() => true)
4747
.catch((error) => {
48-
if (error === backend_offline_error) {
48+
if (isBackendOffline(error)) {
4949
return false
5050
}
5151
const message = `Could not set data: ${error.message ?? error.response?.data}.`
@@ -70,7 +70,7 @@ class BagOfHoldingStore {
7070
return null
7171
}
7272

73-
if (error === backend_offline_error) {
73+
if (isBackendOffline(error)) {
7474
return undefined
7575
}
7676
const message = `Could not get (${path}) data: ${error.response?.data ?? error.message}.`

core/frontend/src/store/beacon.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { OneMoreTime } from '@/one-more-time'
88
import store from '@/store'
99
import { Domain } from '@/types/beacon'
1010
import { beacon_service } from '@/types/frontend_services'
11-
import back_axios, { backend_offline_error } from '@/utils/api'
11+
import back_axios, { isBackendOffline } from '@/utils/api'
1212

1313
const notifier = new Notifier(beacon_service)
1414

@@ -115,7 +115,7 @@ class BeaconStore extends VuexModule {
115115
return true
116116
})
117117
.catch((error) => {
118-
if (error === backend_offline_error) {
118+
if (isBackendOffline(error)) {
119119
return false
120120
}
121121
const message = `Could not set hostname: ${error.message ?? error.response?.data}.`
@@ -140,7 +140,7 @@ class BeaconStore extends VuexModule {
140140
return true
141141
})
142142
.catch((error) => {
143-
if (error === backend_offline_error) {
143+
if (isBackendOffline(error)) {
144144
return false
145145
}
146146
const message = `Could not set vehicle name: ${error.response?.data ?? error.message}.`

core/frontend/src/store/commander.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Notifier from '@/libs/notifier'
22
import { ReturnStruct, ShutdownType } from '@/types/commander'
33
import { commander_service } from '@/types/frontend_services'
4-
import back_axios, { backend_offline_error } from '@/utils/api'
4+
import back_axios, { isBackendOffline } from '@/utils/api'
55

66
const notifier = new Notifier(commander_service)
77

@@ -31,7 +31,7 @@ class CommanderStore {
3131
})
3232
.then((response) => response.data)
3333
.catch((error) => {
34-
if (error === backend_offline_error) {
34+
if (isBackendOffline(error)) {
3535
return undefined
3636
}
3737
const message = `Could not send command to host: ${error.response?.data ?? error.message}.`
@@ -52,7 +52,7 @@ class CommanderStore {
5252
})
5353
.then((response) => response.data)
5454
.catch((error) => {
55-
if (error === backend_offline_error) {
55+
if (isBackendOffline(error)) {
5656
return
5757
}
5858
const message = `Could not set time: ${error.response?.data ?? error.message}.`
@@ -72,7 +72,7 @@ class CommanderStore {
7272
})
7373
.then((response) => response.data)
7474
.catch((error) => {
75-
if (error === backend_offline_error) {
75+
if (isBackendOffline(error)) {
7676
return
7777
}
7878

@@ -94,7 +94,7 @@ class CommanderStore {
9494
})
9595
.then((response) => response.data?.enabled)
9696
.catch((error) => {
97-
if (error === backend_offline_error) {
97+
if (isBackendOffline(error)) {
9898
return undefined
9999
}
100100
const message = 'Could not get Raspberry legacy camera configuration:'
@@ -116,7 +116,7 @@ class CommanderStore {
116116
})
117117
.then(() => true)
118118
.catch((error) => {
119-
if (error === backend_offline_error) {
119+
if (isBackendOffline(error)) {
120120
return false
121121
}
122122
const message = 'Could not set Raspberry legacy camera configuration:'
@@ -137,7 +137,7 @@ class CommanderStore {
137137
})
138138
.then((response) => response.data)
139139
.catch((error) => {
140-
if (error === backend_offline_error) {
140+
if (isBackendOffline(error)) {
141141
return undefined
142142
}
143143
const message = `Could not get vcgencmd data: ${error.response?.data ?? error.message}.`
@@ -160,7 +160,7 @@ class CommanderStore {
160160
return response.data
161161
})
162162
.catch((error) => {
163-
if (error === backend_offline_error) {
163+
if (isBackendOffline(error)) {
164164
return undefined
165165
}
166166
const message = `Could not get environment variables: ${error.response?.data ?? error.message}.`
@@ -180,7 +180,7 @@ class CommanderStore {
180180
})
181181
.then((response) => response.data)
182182
.catch((error) => {
183-
if (error === backend_offline_error) {
183+
if (isBackendOffline(error)) {
184184
return undefined
185185
}
186186
const message = `Could not get Raspi EEPROM information: ${error.response?.data ?? error.message}.`
@@ -200,7 +200,7 @@ class CommanderStore {
200200
})
201201
.then((response) => response.data)
202202
.catch((error) => {
203-
if (error === backend_offline_error) {
203+
if (isBackendOffline(error)) {
204204
return undefined
205205
}
206206
const message = `Could not update Raspi EEPROM: ${error.response?.data ?? error.message}.`

core/frontend/src/store/helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { OneMoreTime } from '@/one-more-time'
88
import store from '@/store'
99
import { helper_service } from '@/types/frontend_services'
1010
import { Service, SpeedTestResult } from '@/types/helper'
11-
import back_axios, { backend_offline_error } from '@/utils/api'
11+
import back_axios, { isBackendOffline } from '@/utils/api'
1212

1313
const notifier = new Notifier(helper_service)
1414

@@ -131,7 +131,7 @@ class PingStore extends VuexModule {
131131
})
132132
.then((response) => response.data as Service[])
133133
.catch((error) => {
134-
if (error === backend_offline_error) { throw new Error(error) }
134+
if (isBackendOffline(error)) { throw new Error(error) }
135135
const message = `Error scanning for services: ${error}`
136136
notifier.pushError('SERVICE_SCAN_FAIL', message)
137137
throw new Error(error)

core/frontend/src/store/system-information.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Serial } from '@/types/system-information/serial'
1717
import {
1818
CPU, Disk, Info, Memory, Network, Process, System, Temperature,
1919
} from '@/types/system-information/system'
20-
import back_axios, { backend_offline_error } from '@/utils/api'
20+
import back_axios, { isBackendOffline } from '@/utils/api'
2121

2222
export enum FetchType {
2323
KernelType = 'kernel_buffer',
@@ -257,7 +257,7 @@ class SystemInformationStore extends VuexModule {
257257
}
258258
})
259259
.catch((error) => {
260-
if (error === backend_offline_error) { return }
260+
if (isBackendOffline(error)) { return }
261261
const message = `Could not fetch system information '${type}': ${error.message}`
262262
notifier.pushError('SYSTEM_FETCH_FAIL', message)
263263
})

core/frontend/src/store/video.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { video_manager_service } from '@/types/frontend_services'
1111
import {
1212
CreatedStream, Device, StreamStatus,
1313
} from '@/types/video'
14-
import back_axios, { backend_offline_error } from '@/utils/api'
14+
import back_axios, { isBackendOffline } from '@/utils/api'
1515

1616
export interface Thumbnail {
1717
source: string | undefined
@@ -108,7 +108,7 @@ class VideoStore extends VuexModule {
108108
})
109109
.then(() => true)
110110
.catch((error) => {
111-
if (error === backend_offline_error) {
111+
if (isBackendOffline(error)) {
112112
return false
113113
}
114114
const message = `Could not create video stream: ${error.response?.data ?? error.message}.`
@@ -131,7 +131,7 @@ class VideoStore extends VuexModule {
131131
})
132132
.catch((error) => {
133133
this.setAvailableDevices([])
134-
if (error === backend_offline_error) {
134+
if (isBackendOffline(error)) {
135135
return
136136
}
137137

@@ -155,7 +155,7 @@ class VideoStore extends VuexModule {
155155
})
156156
.catch((error) => {
157157
this.setAvailableStreams([])
158-
if (error === backend_offline_error) {
158+
if (isBackendOffline(error)) {
159159
return
160160
}
161161
const message = `Could not fetch video streams: ${error.message}`

0 commit comments

Comments
 (0)