From 359ec6a68ea92b3d1eecf020742157eb3be90b9f Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sun, 9 Aug 2020 21:17:33 +0300
Subject: feat: add useFeed hook

---
 src/pages/FeedPage/FeedPage.tsx | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

(limited to 'src/pages/FeedPage/FeedPage.tsx')

diff --git a/src/pages/FeedPage/FeedPage.tsx b/src/pages/FeedPage/FeedPage.tsx
index 0b7d44a..8e7fb55 100644
--- a/src/pages/FeedPage/FeedPage.tsx
+++ b/src/pages/FeedPage/FeedPage.tsx
@@ -1,32 +1,24 @@
-import React, { useState, useEffect } from 'react';
+import React from 'react';
 import { Poll } from 'which-types';
 import { Container } from '@material-ui/core/';
 
 import Feed from '../../components/Feed/Feed';
-import { get } from '../../requests';
 import PollSubmission from './PollSubmission';
 import { useAuth } from '../../hooks/useAuth';
+import { useFeed } from '../../hooks/APIClient';
 
 const FeedPage: React.FC = () => {
-  const [polls, setPolls] = useState<Poll[]>([]);
+  const { data, mutate } = useFeed();
   const { isAuthenticated } = useAuth();
 
-  useEffect(() => {
-    get('/feed').then(response => {
-      setPolls(response.data);
-    });
-  }, []);
-
   const addPoll = (poll: Poll): void => {
-    polls.unshift(poll);
-    setPolls([]);
-    setPolls(polls);
+    mutate([poll, ...data], true);
   };
 
   return (
     <Container maxWidth="sm" disableGutters>
       {isAuthenticated() && <PollSubmission addPoll={addPoll} />}
-      <Feed polls={polls} />
+      <Feed polls={data} />
     </Container>
   );
 };
-- 
cgit v1.2.3


From fd6e663a1bcc43cfc49bda99ccbfab380489324b Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Mon, 10 Aug 2020 00:02:24 +0300
Subject: feat!: add useLocalStorage hook

---
 src/pages/FeedPage/FeedPage.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/pages/FeedPage/FeedPage.tsx')

diff --git a/src/pages/FeedPage/FeedPage.tsx b/src/pages/FeedPage/FeedPage.tsx
index 8e7fb55..da0fb2a 100644
--- a/src/pages/FeedPage/FeedPage.tsx
+++ b/src/pages/FeedPage/FeedPage.tsx
@@ -17,7 +17,7 @@ const FeedPage: React.FC = () => {
 
   return (
     <Container maxWidth="sm" disableGutters>
-      {isAuthenticated() && <PollSubmission addPoll={addPoll} />}
+      {isAuthenticated && <PollSubmission addPoll={addPoll} />}
       <Feed polls={data} />
     </Container>
   );
-- 
cgit v1.2.3


From 7ba15a22d1bd57e7c26ff2d5fccf5505aaf8619e Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Mon, 10 Aug 2020 00:28:39 +0300
Subject: refactor: move pages -> containers

---
 src/pages/FeedPage/FeedPage.tsx | 27 ---------------------------
 1 file changed, 27 deletions(-)
 delete mode 100644 src/pages/FeedPage/FeedPage.tsx

(limited to 'src/pages/FeedPage/FeedPage.tsx')

diff --git a/src/pages/FeedPage/FeedPage.tsx b/src/pages/FeedPage/FeedPage.tsx
deleted file mode 100644
index da0fb2a..0000000
--- a/src/pages/FeedPage/FeedPage.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import React from 'react';
-import { Poll } from 'which-types';
-import { Container } from '@material-ui/core/';
-
-import Feed from '../../components/Feed/Feed';
-import PollSubmission from './PollSubmission';
-import { useAuth } from '../../hooks/useAuth';
-import { useFeed } from '../../hooks/APIClient';
-
-const FeedPage: React.FC = () => {
-  const { data, mutate } = useFeed();
-  const { isAuthenticated } = useAuth();
-
-  const addPoll = (poll: Poll): void => {
-    mutate([poll, ...data], true);
-  };
-
-  return (
-    <Container maxWidth="sm" disableGutters>
-      {isAuthenticated && <PollSubmission addPoll={addPoll} />}
-      <Feed polls={data} />
-    </Container>
-  );
-};
-
-export default FeedPage;
-
-- 
cgit v1.2.3

