From 7fa0bf940e3352d058df2329cbd7190a1c06e343 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Chlo=C3=A9=20JACOB?= <chloe.jacob4@etu.unistra.fr>
Date: Tue, 28 Feb 2023 09:41:52 +0100
Subject: [PATCH] =?UTF-8?q?(try=20r=C3=A9parer=20l'intersection=20observer?=
 =?UTF-8?q?=20->=20permet=20de=20charger=20=C3=A9tape=20par=20=C3=A9tape?=
 =?UTF-8?q?=20les=20posts)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/App.tsx                      |  2 ++
 src/hooks/useAuthInterceptors.ts |  5 +++--
 src/views/DiscoverView.tsx       |  9 +++++++++
 src/views/FeedView.tsx           | 10 ++++++++++
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/App.tsx b/src/App.tsx
index 4c3ff93..ccf1767 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -14,6 +14,8 @@ import './i18n';
 
 
 function App() {
+  useAuthInterceptors();
+
   return (
     <Routes>
       <Route path="login" element={<LoginView />} />
diff --git a/src/hooks/useAuthInterceptors.ts b/src/hooks/useAuthInterceptors.ts
index dae92be..9a2e3d0 100644
--- a/src/hooks/useAuthInterceptors.ts
+++ b/src/hooks/useAuthInterceptors.ts
@@ -1,9 +1,9 @@
 import { AxiosError } from 'axios';
 import { useEffect } from 'react';
+import instalikeApi from '../instalikeApi';
 
+// AUTRES FICHIERS
 import { logoutAsync } from '../redux/auth/thunks';
-
-import instalikeApi from '../instalikeApi';
 import useAppDispatch from './useAppDispatch';
 
 const useAuthInterceptors = () => {
@@ -18,6 +18,7 @@ const useAuthInterceptors = () => {
             dispatch(logoutAsync());
           }
         }
+        //return Promise.reject(e);
       }
     );
 
diff --git a/src/views/DiscoverView.tsx b/src/views/DiscoverView.tsx
index 4b3a53a..197744c 100644
--- a/src/views/DiscoverView.tsx
+++ b/src/views/DiscoverView.tsx
@@ -1,5 +1,7 @@
 import { useEffect } from 'react';
 import { Instalike } from '@jmetterrothan/instalike';
+import instalikeApi from '../instalikeApi';
+
 
 // COMPOSANTS
 import Navbar from '../components/Navbar';
@@ -14,6 +16,13 @@ import { Link } from 'react-router-dom';
 
 const DiscoverView = () => {
   const dispatch = useAppDispatch();
+
+  // useEffect(() => {
+  //   instalikeApi.posts.fetch({ cursor: null });
+  //   instalikeApi.users.me.fetch();
+  //   instalikeApi.users.find(1).fetch();
+  // }, []);
+
   useEffect(() => {
     dispatch(fetchFeedUserAsync());
   }, []);
diff --git a/src/views/FeedView.tsx b/src/views/FeedView.tsx
index f347675..72b1101 100644
--- a/src/views/FeedView.tsx
+++ b/src/views/FeedView.tsx
@@ -1,5 +1,7 @@
 import { useEffect } from 'react';
 import { Instalike } from '@jmetterrothan/instalike';
+import instalikeApi from '../instalikeApi';
+
 
 // ICONS
 import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
@@ -22,6 +24,14 @@ import { fetchSuggestionAsync } from '../redux/suggestion/thunks';
 
 const FeedView = () => {
     const dispatch = useAppDispatch();
+
+    // useEffect(() => {
+    //     console.log('fetch');
+    //     instalikeApi.posts.fetch({ cursor: null });
+    //     instalikeApi.users.me.fetch();
+    //     instalikeApi.users.find(1).fetch();
+    //   }, []);
+    
     useEffect(() => {
       dispatch(fetchFeedUserAsync());
     }, []);
-- 
GitLab