Skip to content

Commit

Permalink
fix(front): [#29] similars error fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaras committed Jul 12, 2020
1 parent a700c4f commit 89a3020
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/src/screens/picture/Picture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ function PictureScreen({ route, navigation }: Props) {
},
});

const [getAllPictures, { data: allPicturesData }] = useLazyQuery(GET_ALL_PICTURES, {
const { data: allPicturesData } = useQuery(GET_ALL_PICTURES, {
onError: () => {
setError(true);
},
});

const { data: lastPictureData } = useQuery(GET_LAST_PICTURE, {
onCompleted: async () => {
getAllPictures();
await getPicture();
},
onError: () => {
Expand Down Expand Up @@ -125,7 +124,7 @@ function PictureScreen({ route, navigation }: Props) {

useEffect(() => {
(async () => {
if (similars.length === 0 && JSON.stringify(response) !== JSON.stringify({})) {
if (allPicturesData && similars.length === 0 && JSON.stringify(response) !== JSON.stringify({})) {
await getSimilars();
setLoading(false);
}
Expand Down

0 comments on commit 89a3020

Please sign in to comment.