Skip to content

Commit

Permalink
fix: App crash when wrong camera info came from frigate server
Browse files Browse the repository at this point in the history
  • Loading branch information
piwko28 committed Oct 14, 2024
1 parent 13e06bd commit 1aad7a6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion firebase.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"react-native": {
"crashlytics_debug_enabled": true
"crashlytics_debug_enabled": false
}
}
4 changes: 4 additions & 0 deletions helpers/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export const get = async <T>(
},
},
);
if (!response.ok) {
crashlytics().log(`HTTP/${response.status}: GET ${endpoint}`);
}
if (response.status === 401) {
crashlytics().log(`Unauthorized`);
throw new Error(`Wrong credentials when tried to reach ${endpoint}`);
}
return response[json === false ? 'text' : 'json']();
Expand Down
2 changes: 2 additions & 0 deletions views/menu/menuHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useEffect} from 'react';
import {Navigation, OptionsTopBarButton} from 'react-native-navigation';
import crashlytics from '@react-native-firebase/crashlytics';

export type MenuId =
| 'camerasList'
Expand All @@ -21,6 +22,7 @@ export const useSelectedMenuItem = (current?: MenuId) => {
};

export const useMenu = (componentId: string, current?: MenuId) => {
crashlytics().log(`View change: ${current}`);
useSelectedMenuItem(current);

useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions views/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const Settings: NavigationFunctionComponent = () => {

const save = useCallback(
(settings: ISettings) => {
crashlytics().log(`Save settings`);
crashlytics().setCrashlyticsCollectionEnabled(
settings.app.sendCrashReports,
);
Expand Down
6 changes: 3 additions & 3 deletions views/system/CameraInfoChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ export const CameraInfoChart: FC<ICameraInfoChartProps> = ({cameraInfos}) => {
() => [
{
data: Object.values(cameraInfos)
.map(info => info.ffmpeg.cpu!)
.map(info => info.ffmpeg.cpu! || 0)
.filter(v => v !== undefined),
svg: {fill: getColor(0)},
},
{
data: Object.values(cameraInfos)
.map(info => info.capture.cpu!)
.map(info => info.capture.cpu! || 0)
.filter(v => v !== undefined),
svg: {fill: getColor(1)},
},
{
data: Object.values(cameraInfos)
.map(info => info.detect.cpu!)
.map(info => info.detect.cpu! || 0)
.filter(v => v !== undefined),
svg: {fill: getColor(2)},
},
Expand Down

0 comments on commit 1aad7a6

Please sign in to comment.