Skip to content

Commit

Permalink
fix: Use Maybe<User> for getUser endpoint (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 authored Mar 16, 2020
1 parent dc08859 commit 8c247ac
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ export function SelectNotifications(
): React.ReactElement {
const { style, ...rest } = props;
const { api } = useContext(ApiContext);
const { data: getUserData, error: queryError } = useQuery<
{ getUser: DeepPartial<User> },
const { data: getUserData } = useQuery<
{ getUser: DeepPartial<User> | null },
QueryGetUserArgs
>(GET_USER, {
fetchPolicy: 'cache-and-network',
Expand All @@ -147,20 +147,20 @@ export function SelectNotifications(
// If we have optimistic UI, show it
optimisticNotif ||
// If we have up-to-date data from backend, take that
updateUserData?.updateUser.notifications?.frequency ||
createUserData?.createUser.notifications?.frequency ||
updateUserData?.updateUser?.notifications?.frequency ||
createUserData?.createUser?.notifications?.frequency ||
// At the beginning, before anything happens, query from backend
getUserData?.getUser.notifications?.frequency ||
getUserData?.getUser?.notifications?.frequency ||
// If the getUserData is still loading, just show `never`
'never';

useEffect(() => {
if (queryError?.message.includes('No user with expoInstallationId')) {
if (getUserData?.getUser === null) {
createUser({
variables: { input: { expoInstallationId: Constants.installationId } }
}).catch(sentryError('SelectNotifications'));
}
}, [createUser, queryError]);
}, [createUser, getUserData]);

useEffect(() => {
// If we receive new updateUserData, then our optimistic UI is obsolete
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ This app is bootstrapped with [Expo](https://expo.io), you can download the Expo

| Release Channel | Version | Description | Url |
| --------------------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| [Production](https://exp.host/@amaurymartiny/shoot-i-smoke?release-channel=production-v1.5.1) | v1.5.1 | Same version as Sh\*\*t! I Smoke on the App Store and Play Store. | `https://exp.host/@amaurymartiny/shoot-i-smoke?release-channel=production-v1.5.1` |
| [Staging](https://exp.host/@amaurymartiny/shoot-i-smoke) | v1.5.1 | Latest version currently in development: newest features, may contain bugs. | `https://exp.host/@amaurymartiny/shoot-i-smoke` |
| [Production](https://exp.host/@amaurymartiny/shoot-i-smoke?release-channel=production-v1.5.2) | v1.5.2 | Same version as Sh\*\*t! I Smoke on the App Store and Play Store. | `https://exp.host/@amaurymartiny/shoot-i-smoke?release-channel=production-v1.5.2` |
| [Staging](https://exp.host/@amaurymartiny/shoot-i-smoke) | v1.5.2 | Latest version currently in development: newest features, may contain bugs. | `https://exp.host/@amaurymartiny/shoot-i-smoke` |

## :hammer: Build it yourself

Expand Down
6 changes: 3 additions & 3 deletions app.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"icon": "assets/logos/android/playstore-icon.png",
"package": "com.shitismoke.app",
"permissions": ["ACCESS_FINE_LOCATION"],
"versionCode": 12
"versionCode": 13
},
"assetBundlePatterns": ["assets/**/*"],
"backgroundColor": "#FAFAFC",
Expand All @@ -34,7 +34,7 @@
},
"icon": "assets/logos/ios/iTunesArtwork@3x.png",
"ios": {
"buildNumber": "1.5.1",
"buildNumber": "1.5.2",
"bundleIdentifier": "com.shitismoke.app",
"config": {
"googleMapsApiKey": "YOUR_OPTIONAL_KEY"
Expand All @@ -56,6 +56,6 @@
"backgroundColor": "#EBE7DD",
"image": "assets/logos/splash.png"
},
"version": "1.5.1"
"version": "1.5.2"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shootismoke",
"version": "1.5.1",
"version": "1.5.2",
"author": "Amaury Martiny <amaury.martiny@protonmail.com>",
"contributors": [
"Marcelo S. Coelho"
Expand All @@ -23,7 +23,7 @@
"@hapi/hawk": "^8.0.0",
"@shootismoke/convert": "^0.2.8",
"@shootismoke/dataproviders": "^0.2.17",
"@shootismoke/graphql": "^0.2.18",
"@shootismoke/graphql": "^0.2.19",
"@types/haversine": "^1.1.4",
"@types/i18n-js": "^3.0.1",
"@types/p-any": "^1.1.3",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1887,10 +1887,10 @@
fp-ts "^2.1.1"
io-ts "^2.0.1"

"@shootismoke/graphql@^0.2.18":
version "0.2.18"
resolved "https://registry.yarnpkg.com/@shootismoke/graphql/-/graphql-0.2.18.tgz#7d551a920147d985e7a1e4af3bfdd8f727c8d438"
integrity sha512-bIyegbsAytNT0mWYMC5XeJX85SHPTjmX8tO/PTBvhOKW8US00H6pSAZWHvQyv9ajo719uQBACL2STMWuWDdrnA==
"@shootismoke/graphql@^0.2.19":
version "0.2.19"
resolved "https://registry.yarnpkg.com/@shootismoke/graphql/-/graphql-0.2.19.tgz#0a7fd0ac073e5bf0f12860d3a0ac5dd37b6437be"
integrity sha512-eYmubirdyj8RkAyxpyH9sBVqPETmPHTw1wf3oBOgJqXXiGI3Kyn6zOn9OqzWUtVolahUQ28eV/BCVkpYvA9MRg==

"@types/babel__core@^7.1.0":
version "7.1.2"
Expand Down

0 comments on commit 8c247ac

Please sign in to comment.