Skip to content

Commit b0dd71c

Browse files
Merge pull request #44 from OpenDTU-App/cleanup
2 parents 21e93a3 + 224896e commit b0dd71c

26 files changed

+1827
-988
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ There are signed .apk files inside the "Releases" tab. As of now, the is no plan
1111
![IzzyOnDroid Badge](https://img.shields.io/endpoint?url=https://apt.izzysoft.de/fdroid/api/v1/shield/xyz.commanderred.opendtuapp)
1212

1313
## Development
14-
There are two branches. `main` is the stable branch, `dev` is the development branch. If you want to contribute, please create a pull request to `dev`.
14+
There are two branches. `main` is the stable branch, `develop` is the development branch. If you want to contribute, please create a pull request to `develop`.
1515

1616
## Translations
1717
Translations are inside a [submodule](https://github.com/OpenDTU-App/opendtu-react-native-translations) located in `src/translations/translation-files`.
@@ -48,7 +48,12 @@ Stuff that I cannot test myself
4848
- [ ] Multi-Inverter per DTU
4949

5050
### Devnotes
51-
- Use `yarn version --patch --no-commit-hooks --no-git-tag-version` to bump version
51+
- Creating new release
52+
- Use `yarn version --patch --no-commit-hooks --no-git-tag-version` to bump version
53+
- Push to GitHub
54+
- Tag the commit with `vX.Y.Z`
55+
- Push the tag to GitHub
56+
- Merge `develop` into `main`
5257

5358
### Early Screenshots
5459
<img alt="Screenshot_1702075921" src="https://github.com/OpenDTU-App/opendtu-react-native/assets/43087936/1475799f-881d-4eb4-8b1f-1065c64a85c1" width="250">

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"ios": "react-native run-ios",
1717
"lint": "eslint .",
1818
"lint:fix": "eslint . --fix",
19-
"typecheck": "tsc --noEmit",
19+
"typecheck": "tsc --project tsconfig.json --pretty --noEmit --skipLibCheck",
2020
"start": "react-native start",
2121
"test": "jest --passWithNoTests",
2222
"postinstall": "yarn run npm-license-crawler -onlyDirectDependencies -json licenses.json && patch-package",

src/App.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import moment from 'moment';
44
import { PersistGate as ReduxPersistGate } from 'redux-persist/integration/react';
55

66
import type { FC } from 'react';
7-
import React, { useEffect, useMemo, useState } from 'react';
7+
import { StrictMode, useEffect, useMemo, useState } from 'react';
88
import { useTranslation } from 'react-i18next';
99
import { Appearance, StatusBar } from 'react-native';
1010
import type { MD3Theme } from 'react-native-paper';
@@ -34,24 +34,26 @@ const App = () => {
3434
}, []);*/
3535

3636
return (
37-
<SafeAreaProvider>
38-
<ReduxProvider store={store}>
39-
<ReduxPersistGate
40-
persistor={persistor}
41-
loading={null}
42-
// onBeforeLift={onBeforeLift}
43-
>
44-
<GithubProvider>
45-
<ApiProvider>
46-
<DatabaseProvider>
47-
<_App />
48-
<FetchHandler />
49-
</DatabaseProvider>
50-
</ApiProvider>
51-
</GithubProvider>
52-
</ReduxPersistGate>
53-
</ReduxProvider>
54-
</SafeAreaProvider>
37+
<StrictMode>
38+
<SafeAreaProvider>
39+
<ReduxProvider store={store}>
40+
<ReduxPersistGate
41+
persistor={persistor}
42+
loading={null}
43+
// onBeforeLift={onBeforeLift}
44+
>
45+
<GithubProvider>
46+
<ApiProvider>
47+
<DatabaseProvider>
48+
<_App />
49+
<FetchHandler />
50+
</DatabaseProvider>
51+
</ApiProvider>
52+
</GithubProvider>
53+
</ReduxPersistGate>
54+
</ReduxProvider>
55+
</SafeAreaProvider>
56+
</StrictMode>
5557
);
5658
};
5759

src/api/opendtuapi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class OpenDtuApi {
174174
return { deviceState: DeviceState.NotInstance };
175175
// eslint-disable-next-line @typescript-eslint/no-explicit-any
176176
} catch (error: any) {
177-
log.error('getSystemStatusFromUrl error', error);
177+
log.error('getSystemStatusFromUrl error', error, error.name);
178178

179179
if (error.name === 'AbortError') {
180180
return { deviceState: DeviceState.Unreachable };

src/components/devices/MDNSScan.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ const MDNSScan: FC<MDNSScanProps> = ({ setError, setLoading, loading }) => {
6666
};
6767
}, []);
6868

69-
console.log('services', services);
70-
7169
if (discovering && services.length === 0) {
7270
return (
7371
<Box

src/components/styled/SettingsSurface.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styled from 'styled-components';
33
import { Surface } from 'react-native-paper';
44

55
const SettingsSurface = styled(Surface)`
6-
margin: 4px;
6+
margin: 4px 8px 12px;
77
border-radius: 16px;
88
`;
99

src/hooks/useHasLiveData.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import moment from 'moment';
2-
31
import ago from '@/utils/ago';
42

53
import { useAppSelector } from '@/store';
@@ -39,7 +37,6 @@ const useHasLiveData = (): boolean => {
3937
}
4038

4139
if (lastUpdateAgo >= 30000) {
42-
console.log('lastUpdateAgo', moment(lastUpdate).fromNow());
4340
console.log('lastUpdateAgo older than 30000 ms');
4441
return false;
4542
}

src/slices/settings.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ const settingsSlice = createSlice({
5353
state.selectedDtuConfig = action.payload.index;
5454
},
5555
addDtuConfig: (state, action: AddDtuConfigAction) => {
56+
if (
57+
state.dtuConfigs.find(
58+
config => config.baseUrl === action.payload.config.baseUrl,
59+
)
60+
) {
61+
log.warn(
62+
`addDtuConfig: dtuConfigs.find(config => config.baseUrl === ${action.payload.config.baseUrl})`,
63+
);
64+
return;
65+
}
66+
5667
state.dtuConfigs.push(action.payload.config);
5768
state.selectedDtuConfig = state.dtuConfigs.length - 1;
5869
},

src/views/navigation/NavigationStack.tsx

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,21 @@ const NavigationStack: FC = () => {
4141
<Stack.Navigator
4242
initialRouteName={hasConfigs ? 'MainScreen' : 'SetupAddOpenDTUScreen'}
4343
screenOptions={{
44+
headerShown: false,
4445
headerBackVisible: false,
4546
headerTitle: '',
4647
headerTransparent: true,
4748
}}
4849
>
49-
<Stack.Screen
50-
name="MainScreen"
51-
component={MainScreen}
52-
options={{ headerShown: false }}
53-
/>
54-
<Stack.Screen
55-
name="DeviceListScreen"
56-
component={DeviceListScreen}
57-
options={{ headerShown: false }}
58-
/>
50+
<Stack.Screen name="MainScreen" component={MainScreen} />
51+
<Stack.Screen name="DeviceListScreen" component={DeviceListScreen} />
5952
<Stack.Screen
6053
name="SetupAddOpenDTUScreen"
6154
component={SetupAddOpenDTUScreen}
62-
options={{ headerShown: false }}
6355
/>
6456
<Stack.Screen
6557
name="SetupAuthenticateOpenDTUInstanceScreen"
6658
component={SetupAuthenticateOpenDTUInstanceScreen}
67-
options={{ headerBackVisible: true }}
6859
/>
6960
<Stack.Screen
7061
name="SetupOpenDTUCompleteScreen"
@@ -73,58 +64,38 @@ const NavigationStack: FC = () => {
7364
<Stack.Screen
7465
name="DeviceSettingsScreen"
7566
component={DeviceSettingsScreen}
76-
options={{ headerShown: false }}
7767
/>
7868
<Stack.Screen
7969
name="SelectDatabaseScreen"
8070
component={SelectDatabaseScreen}
81-
options={{ headerShown: false }}
8271
/>
8372
<Stack.Screen
8473
name="ManageDatabasesScreen"
8574
component={ManageDatabasesScreen}
86-
options={{ headerShown: false }}
8775
/>
8876
<Stack.Screen
8977
name="AboutSettingsScreen"
9078
component={AboutSettingsScreen}
91-
options={{ headerShown: false }}
9279
/>
9380
<Stack.Screen
9481
name="ConfigureGraphsScreen"
9582
component={ConfigureGraphsScreen}
96-
options={{ headerShown: false }}
97-
/>
98-
<Stack.Screen
99-
name="AboutOpenDTUScreen"
100-
component={AboutOpenDTUScreen}
101-
options={{ headerShown: false }}
10283
/>
84+
<Stack.Screen name="AboutOpenDTUScreen" component={AboutOpenDTUScreen} />
10385
<Stack.Screen
10486
name="NetworkInformationScreen"
10587
component={NetworkInformationScreen}
106-
options={{ headerShown: false }}
10788
/>
10889
<Stack.Screen
10990
name="NtpInformationScreen"
11091
component={NtpInformationScreen}
111-
options={{ headerShown: false }}
11292
/>
11393
<Stack.Screen
11494
name="MqttInformationScreen"
11595
component={MqttInformationScreen}
116-
options={{ headerBackVisible: true }}
117-
/>
118-
<Stack.Screen
119-
name="LicensesScreen"
120-
component={LicensesScreen}
121-
options={{ headerBackVisible: true }}
122-
/>
123-
<Stack.Screen
124-
name="DebugScreen"
125-
component={DebugScreen}
126-
options={{ headerBackVisible: true }}
12796
/>
97+
<Stack.Screen name="LicensesScreen" component={LicensesScreen} />
98+
<Stack.Screen name="DebugScreen" component={DebugScreen} />
12899
</Stack.Navigator>
129100
);
130101
};

src/views/navigation/screens/AboutOpenDTUScreen.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { NavigationProp, ParamListBase } from '@react-navigation/native';
2-
import { useNavigation } from '@react-navigation/native';
31
import { compare } from 'compare-versions';
42
import moment from 'moment';
53

@@ -19,17 +17,12 @@ import percentage from '@/utils/percentage';
1917

2018
import { useAppSelector } from '@/store';
2119
import { StyledSafeAreaView } from '@/style';
20+
import type { PropsWithNavigation } from '@/views/navigation/NavigationStack';
2221

23-
const AboutOpenDTUScreen: FC = () => {
22+
const AboutOpenDTUScreen: FC<PropsWithNavigation> = ({ navigation }) => {
2423
const theme = useTheme();
2524
const { t } = useTranslation();
2625

27-
const navigation = useNavigation() as NavigationProp<ParamListBase>;
28-
29-
const handleBack = useCallback(() => {
30-
navigation.goBack();
31-
}, [navigation]);
32-
3326
const systemStatus = useDtuState(state => state?.systemStatus);
3427

3528
const latestVersion = useAppSelector(
@@ -70,11 +63,8 @@ const AboutOpenDTUScreen: FC = () => {
7063
return (
7164
<>
7265
<Appbar.Header>
73-
<Appbar.BackAction onPress={handleBack} />
74-
<Appbar.Content
75-
title={t('opendtu.systemInformation')}
76-
onPress={handleBack}
77-
/>
66+
<Appbar.BackAction onPress={() => navigation.goBack()} />
67+
<Appbar.Content title={t('opendtu.systemInformation')} />
7868
</Appbar.Header>
7969
<StyledSafeAreaView theme={theme}>
8070
<Box style={{ width: '100%', flex: 1 }}>

0 commit comments

Comments
 (0)