From 34b8c1f962a5c835351dc6f4369757259998af16 Mon Sep 17 00:00:00 2001
From: Akshay Nair <phenax5@gmail.com>
Date: Sat, 28 Sep 2024 22:19:31 +0530
Subject: Finish up app menu + fix drag interaction

---
 src/View.tsx | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

(limited to 'src/View.tsx')

diff --git a/src/View.tsx b/src/View.tsx
index c5084f2..110e3fe 100644
--- a/src/View.tsx
+++ b/src/View.tsx
@@ -1,18 +1,19 @@
-import React, {useState} from 'react';
-import {InstalledApps} from 'react-native-launcher-kit';
+import React, {useEffect, useState} from 'react';
 import Swiper from 'react-native-swiper';
 import {AppList} from './screens/AppList';
 import {Home} from './screens/Home';
+import {useInstalledApps} from './hooks/useInstalledApps';
+import {useFavorites} from './hooks/useFavorites';
 
-export const View: React.FC = () => {
-  const [apps, _setApps] = useState(() => InstalledApps.getSortedApps());
+export const View: React.FC = React.memo(() => {
+  const {refreshApps} = useInstalledApps();
+  const {refreshFavorites} = useFavorites();
   const [screenIndex, setScreenIndex] = useState(0);
 
-  // const refreshApps = () => setApps(InstalledApps.getSortedApps());
-
-  // useEffect(() => {
-  //   refreshApps();
-  // }, [screenIndex]);
+  useEffect(() => {
+    refreshApps();
+    refreshFavorites();
+  }, [screenIndex, refreshApps, refreshFavorites]);
 
   return (
     <Swiper
@@ -22,8 +23,8 @@ export const View: React.FC = () => {
       dot={<></>}
       activeDot={<></>}
       onIndexChanged={setScreenIndex}>
-      <Home apps={apps} active={screenIndex === 0} />
-      <AppList apps={apps} active={screenIndex === 1} />
+      <Home active={screenIndex === 0} />
+      <AppList active={screenIndex === 1} />
     </Swiper>
   );
-};
+});
-- 
cgit v1.3.1

