diff --git a/src/components/settings/InactiveSettingsCard.tsx b/src/components/settings/InactiveSettingsCard.tsx
index 6aba75f2..19efab5d 100644
--- a/src/components/settings/InactiveSettingsCard.tsx
+++ b/src/components/settings/InactiveSettingsCard.tsx
@@ -31,7 +31,7 @@ const InactiveSettingsCard: FC = () => {
)
}
- if (error || data === undefined) {
+ if (error || data === undefined || data.status === 'error') {
return Unable to fetch inactive settings from server.
}
diff --git a/src/components/settings/RefreshIntervalCard.tsx b/src/components/settings/RefreshIntervalCard.tsx
index 040f7a1b..4272ff82 100644
--- a/src/components/settings/RefreshIntervalCard.tsx
+++ b/src/components/settings/RefreshIntervalCard.tsx
@@ -22,7 +22,7 @@ const RefreshIntervalCard: FC = () => {
)
}
- if (error || data === undefined) {
+ if (error || data === undefined || data.status === 'error') {
return (
Unable to fetch refresh interval setting from server.
diff --git a/src/components/useAuth.tsx b/src/components/useAuth.tsx
index bbcf9265..4684fac4 100644
--- a/src/components/useAuth.tsx
+++ b/src/components/useAuth.tsx
@@ -55,7 +55,14 @@ export function AuthProvider({
return
}
- const user = decode(token) as User
+ let user: User
+ try {
+ user = decode(token) as User
+ } catch (error) {
+ setError(error)
+ setLoadingInitial(false)
+ return
+ }
const now = Math.floor(new Date().getTime() / 1000)
if (user.exp > now) {
diff --git a/src/components/useFeature.tsx b/src/components/useFeature.tsx
index fbb72ec6..be959bcd 100644
--- a/src/components/useFeature.tsx
+++ b/src/components/useFeature.tsx
@@ -27,15 +27,22 @@ export function FeatureProvider({
const { getFeatures } = useFeatureApi(token)
useEffect(() => {
+ if (token === '') {
+ setLoadingInitial(false)
+ return
+ }
+
getFeatures()
.then(response => {
- setFeatures(response.data.features)
+ if (response.status === 'success') {
+ setFeatures(response.data.features)
+ }
})
.finally(() => {
setLoadingInitial(false)
})
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [])
+ }, [token])
const memoedValue = useMemo(
() => ({
diff --git a/src/components/user/UserList.tsx b/src/components/user/UserList.tsx
index 05afcd41..756c2529 100644
--- a/src/components/user/UserList.tsx
+++ b/src/components/user/UserList.tsx
@@ -20,7 +20,7 @@ const UserList: FC = () => {
)
}
- if (error || data === undefined) {
+ if (error || data === undefined || data.status === 'error') {
return Unable to fetch users from server.
}
diff --git a/src/views/HomeView.tsx b/src/views/HomeView.tsx
index 5755078d..ef21da7e 100644
--- a/src/views/HomeView.tsx
+++ b/src/views/HomeView.tsx
@@ -29,7 +29,7 @@ const HomeView: FC = () => {
)
}
- if (error || data === undefined) {
+ if (error || data === undefined || data.status === 'error') {
return (
Unable to fetch tickers from server.
diff --git a/src/views/TickerView.tsx b/src/views/TickerView.tsx
index 12e87a2e..cc713f2a 100644
--- a/src/views/TickerView.tsx
+++ b/src/views/TickerView.tsx
@@ -26,7 +26,7 @@ const TickerView: FC = () => {
return
}
- if (error || data === undefined) {
+ if (error || data === undefined || data.status === 'error') {
return Unable to fetch the ticker from server.
}