Unverified Commit dd17bd3b authored by benguedj's avatar benguedj Committed by GitHub
Browse files

feat: 馃幐 Change la gestion du cache au niveau des requ锚tes (#537)

parent e4b2e87d
......@@ -33,7 +33,8 @@ const ErrorMessage: React.FC<Props> = ({ error }) => {
try {
const response = await fetch(
`${process.env.API_URL}/.well-known/apollo/server-health`
`${process.env.API_URL}/.well-known/apollo/server-health`,
{ cache: "no-cache" }
);
reportError(`${Labels.errorMsg} : ${apolloError.message}`);
......
......@@ -82,7 +82,7 @@ const ArticleDetail: FC<Props> = ({ route, navigation }) => {
}
`;
const { loading, error, data } = useQuery(ARTICLE_DETAIL, {
fetchPolicy: "no-cache",
fetchPolicy: "cache-and-network",
});
const setInShortArray = (article: Article) => {
......
......@@ -53,7 +53,10 @@ const TabHomeScreen: FC<Props> = ({ navigation }) => {
string | null
>(null);
const [currentStepId, setCurrentStepId] = useState<number | null>(null);
const [loadSteps, { called, loading, error, data }] = useLazyQuery(ALL_STEPS);
const [loadSteps, { called, loading, error, data }] = useLazyQuery(
ALL_STEPS,
{ fetchPolicy: "cache-and-network" }
);
const init = async () => {
const previousStepId = await StorageUtils.getStringValue(
......
......@@ -84,20 +84,6 @@ const ListArticles: FC<Props> = ({ navigation, route }) => {
}
`;
const { loading, error, data } = useQuery(STEP_ARTICLES, {
fetchPolicy: "no-cache",
});
useEffect(() => {
if (!loading && data) {
const articles = (data as { articles: Article[] }).articles;
setFilteredArticles(articles);
}
}, [loading, data]);
if (loading) return <Loader />;
if (error) return <ErrorMessage error={error} />;
const navigateToSurvey = () => {
navigation.navigate("epdsSurvey");
};
......@@ -125,6 +111,20 @@ const ListArticles: FC<Props> = ({ navigation, route }) => {
setFilteredArticles(result);
};
const { loading, error, data } = useQuery(STEP_ARTICLES, {
fetchPolicy: "cache-and-network",
});
useEffect(() => {
if (!loading && data) {
const articles = (data as { articles: Article[] }).articles;
setFilteredArticles(articles);
}
}, [loading, data]);
if (loading) return <Loader />;
if (error) return <ErrorMessage error={error} />;
return (
<ScrollView style={styles.scrollView}>
<View style={styles.topContainer}>
......@@ -172,7 +172,7 @@ const ListArticles: FC<Props> = ({ navigation, route }) => {
<Animatable.View
key={index}
animation="fadeInUp"
duration={1500}
duration={1000}
delay={0}
>
<ListItem
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment