fix: handle login expirary

This commit is contained in:
2026-03-10 12:12:37 -04:00
Unverified
parent 40fc5c1de6
commit 5c7031725c
5 changed files with 121 additions and 30 deletions

View File

@@ -23,6 +23,12 @@ import api from '../../src/services/api';
import { syncDevicesToWidget } from '../../src/services/widgetSync';
import { Device } from '../../src/types';
const isAuthError = (error: unknown) =>
typeof error === 'object' &&
error !== null &&
'isAuthError' in error &&
(error as { isAuthError?: boolean }).isAuthError === true;
export default function DeviceListScreen() {
const colorScheme = useColorScheme() ?? 'light';
const isDark = colorScheme === 'dark';
@@ -44,6 +50,11 @@ export default function DeviceListScreen() {
// Sync devices to iOS widget
syncDevicesToWidget(data);
} catch (error: any) {
if (isAuthError(error)) {
setDevices([]);
return;
}
// For background/periodic refreshes, avoid interruptive alerts
if (showLoading) {
Alert.alert('Error', error.message || 'Failed to load devices');