aboutsummaryrefslogtreecommitdiff
path: root/src/hooks/useInstalledApps.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-09-28 22:19:31 +0530
committerAkshay Nair <phenax5@gmail.com>2024-09-29 16:16:39 +0530
commit34b8c1f962a5c835351dc6f4369757259998af16 (patch)
tree6f836fdaaedfec125b1202f3b5f9ce24e6277f11 /src/hooks/useInstalledApps.ts
parenta1143f3696a0b272018f7eea43ee23a674c618e1 (diff)
downloaddaft-launcher-34b8c1f962a5c835351dc6f4369757259998af16.tar.gz
daft-launcher-34b8c1f962a5c835351dc6f4369757259998af16.zip
Finish up app menu + fix drag interaction
Diffstat (limited to 'src/hooks/useInstalledApps.ts')
-rw-r--r--src/hooks/useInstalledApps.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/hooks/useInstalledApps.ts b/src/hooks/useInstalledApps.ts
new file mode 100644
index 0000000..32290e5
--- /dev/null
+++ b/src/hooks/useInstalledApps.ts
@@ -0,0 +1,19 @@
+import {atom, useAtom} from 'jotai';
+import {InstalledApps} from 'react-native-launcher-kit';
+import {AppDetail} from 'react-native-launcher-kit/typescript/Interfaces/InstalledApps';
+import {useStableCallback} from './useStableCallback';
+
+const installedAppsAtom = atom<AppDetail[]>(InstalledApps.getSortedApps());
+
+export const useInstalledApps = () => {
+ const [apps, setApps] = useAtom(installedAppsAtom);
+
+ const refreshApps = useStableCallback(() =>
+ setApps(InstalledApps.getSortedApps()),
+ );
+
+ return {
+ apps,
+ refreshApps,
+ };
+};