From 61bb02110ccebbbd78119dd490716637ec86419b Mon Sep 17 00:00:00 2001
From: sowgro <tpoke.ferrari@gmail.com>
Date: Wed, 16 Oct 2024 00:02:25 -0400
Subject: Refactor

---
 extension/src/main.tsx | 37 ++++---------------------------------
 1 file changed, 4 insertions(+), 33 deletions(-)

(limited to 'extension/src/main.tsx')

diff --git a/extension/src/main.tsx b/extension/src/main.tsx
index 36df6f6..0aaf551 100644
--- a/extension/src/main.tsx
+++ b/extension/src/main.tsx
@@ -1,41 +1,12 @@
 import { createRoot } from 'react-dom/client'
 import './index.css'
 import Folder from "./Folder.tsx";
-import BookmarkTreeNode = chrome.bookmarks.BookmarkTreeNode;
-import Bookmark from "./Bookmark.tsx";
 
-chrome.bookmarks.getTree((tree) => {
-    createRoot(document.getElementById('root')!).render(createFolder(tree[0]))
-});
-
-function createFolder(lev: BookmarkTreeNode) {
-    return (
-        <Folder name={lev.title}>
-            {
-                lev.children ? lev.children.map(item => {
-                    if (item.children) {
-                        return createFolder(item)
-                    } else {
-                        return <Bookmark name={item.title} url={item.url ? item.url : ""} icon={faviconURL(item.url)} />
-                    }
-                }) : <span>err</span>
-            }
-        </Folder>
+chrome.bookmarks.getTree(tree => {
+    createRoot(document.getElementById('root')!).render(
+        <Folder data={tree[0]} />
     )
-}
-
-function faviconURL(u: string | undefined) {
-    if (!u) {
-        return "";
-    }
-    u = new URL(u).origin.toString();
-    const url = new URL(chrome.runtime.getURL("/_favicon/"));
-    url.searchParams.set("pageUrl", u);
-    url.searchParams.set("size", "32");
-    console.log(u)
-    return url.toString();
-}
-
+});
 
 // chrome.bookmarks.create(
 //     {'parentId': '0', 'title': 'Bookmarks Extension'},
-- 
cgit v1.2.3

