Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Convert everything to TypeScript #121

Merged
merged 43 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4385d36
Start ts
amaury1093 Jul 1, 2019
2ba71ab
Convert all files to TS
amaury1093 Jul 1, 2019
c911747
Make search work
amaury1093 Jul 6, 2019
1a02aaf
Make png import work
amaury1093 Jul 6, 2019
4805930
Add retry
amaury1093 Jul 6, 2019
e41774b
Make api call work
amaury1093 Jul 7, 2019
957ebaa
Add long waiting on Loading
amaury1093 Jul 7, 2019
8f8abe1
Make screens work
amaury1093 Jul 7, 2019
156a810
Make cigarettes work
amaury1093 Jul 7, 2019
3fa011d
Make header work
amaury1093 Jul 7, 2019
7d1db03
Reverse geocoding
amaury1093 Jul 7, 2019
7e3b3b8
Make details work
amaury1093 Jul 7, 2019
e137e0b
Make search work
amaury1093 Jul 7, 2019
4bcc494
Fix reload app
amaury1093 Jul 7, 2019
8f992fe
Make tests pass
amaury1093 Jul 7, 2019
0fcf5e3
Run eslint
amaury1093 Jul 7, 2019
5edd500
AqiHistory
amaury1093 Jul 9, 2019
f05a927
Add History manager back
amaury1093 Jul 9, 2019
704bb62
Start getting background location
amaury1093 Jul 9, 2019
9784aa1
Remove circular dependency
amaury1093 Jul 10, 2019
28b334c
Fix isSaveNeeded
amaury1093 Jul 10, 2019
2e54f5e
Add getData for testing
amaury1093 Jul 10, 2019
8462eeb
Add clearTable
amaury1093 Jul 10, 2019
60874bd
Fix tests
amaury1093 Jul 10, 2019
50af1ec
Update README
amaury1093 Jul 10, 2019
2a03a7f
Remove vs code settings
amaury1093 Jul 10, 2019
6135652
Fix too many requests
amaury1093 Jul 12, 2019
9886b4f
Add task to save to AsyncStorage
amaury1093 Jul 13, 2019
9206856
Return correct background fetch response
amaury1093 Jul 13, 2019
cf203ab
Refactor a bit the components
amaury1093 Jul 13, 2019
b1eed90
Make scroll work nicely
amaury1093 Jul 13, 2019
5fd5ccb
Add shadow on buttons
amaury1093 Jul 13, 2019
40f8848
Make stuff work
amaury1093 Jul 13, 2019
a516044
Weekly monthly
amaury1093 Jul 13, 2019
86d52a0
Calculate cigarettes
amaury1093 Jul 13, 2019
c1fed0b
Small fixes
amaury1093 Jul 13, 2019
bce6ecb
Small fixes
amaury1093 Jul 13, 2019
b12ee31
Small tweaks with icons
amaury1093 Jul 14, 2019
eb862cb
Add more dev info
amaury1093 Jul 16, 2019
050761c
Reverse geocode in search
amaury1093 Jul 16, 2019
d7ba1fd
Small tweaks
amaury1093 Jul 16, 2019
8c029ed
Small tweaks
amaury1093 Jul 17, 2019
d44d40b
Update icons
amaury1093 Jul 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make screens work
  • Loading branch information
amaury1093 committed Jul 7, 2019
commit 8f8abe1eaffdc7a277c3510fb550454061e74e0e
14 changes: 11 additions & 3 deletions App/Screens/Loading/Loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ import * as theme from '../../utils/theme';
// The variable returned by setTimeout for longWaiting
let longWaitingTimeout: NodeJS.Timeout | null = null;

function clearLongWaiting() {
if (longWaitingTimeout) {
clearTimeout(longWaitingTimeout);
longWaitingTimeout = null;
}
}

export function Loading() {
const api = useContext(ApiContext);
const gps = useContext(GpsLocationContext);
Expand All @@ -38,12 +45,13 @@ export function Loading() {
console.log('<Loading> - Long waiting');
setLongWaiting(true);
}, 2000);

return clearLongWaiting;
}, []);

useEffect(() => {
if (api && longWaitingTimeout) {
clearTimeout(longWaitingTimeout);
longWaitingTimeout = null;
if (api) {
clearLongWaiting();
}
}, [api]);

Expand Down
60 changes: 17 additions & 43 deletions App/Screens/Screens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Sh**t! I Smoke. If not, see <http:https://www.gnu.org/licenses/>.

import React from 'react';
import React, { useContext } from 'react';
import { View } from 'react-native';
import {
createAppContainer,
createStackNavigator,
createSwitchNavigator,
StackNavigatorConfig
} from 'react-navigation';

Expand All @@ -29,6 +28,7 @@ import { ErrorScreen } from './ErrorScreen';
// import { Home } from './Home';
import { Loading } from './Loading';
import { Search } from './Search';
import { Api, ApiContext, ErrorContext } from '../stores';
import * as theme from '../utils/theme';

function stackNavigatorOptions(initialRouteName: string) {
Expand Down Expand Up @@ -84,50 +84,24 @@ const ErrorStack = createAppContainer(
)
);

// @inject('stores')
// @observer
// export class Screens extends Component {
// componentDidCatch(error) {
// this.props.stores.setError(error.message);
// }

// render() {
// return <View style={theme.fullScreen}>{this.renderScreen()}</View>;
// }
export function Screens() {
const api = useContext(ApiContext);
const { error } = useContext(ErrorContext);

// renderScreen = () => {
// const {
// stores: { api, error, location }
// } = this.props;
const stack = renderScreen(api, error);

// if (error) {
// return <ErrorStack />;
// }
return <View style={theme.fullScreen}>{stack}</View>;
}

// if (!api || !location.current) {
// return <Loading />;
// }
function renderScreen(api?: Api, error?: string) {
if (error) {
return <ErrorStack />;
}

// return <RootStack />;
// };
// }
if (!api) {
return <Loading />;
}

const RootNavigator = createAppContainer(
createSwitchNavigator(
{
Error: ErrorStack,
Loading: Loading
},
{
initialRouteName: 'Loading'
}
)
);

export function Screens() {
return (
<View style={theme.fullScreen}>
<RootNavigator />
</View>
);
return null;
// return <RootStack />;
}