diff --git a/src/components/Popup/index.jsx b/src/components/Popup/index.jsx index 48d6152..060c4e7 100644 --- a/src/components/Popup/index.jsx +++ b/src/components/Popup/index.jsx @@ -1,8 +1,7 @@ import { render, Fragment } from "preact"; import { useState, useEffect } from "preact/hooks"; -// Popup component styling. -import "./popup.scss"; +import "./popup.scss"; // Popup component styling. /** * The Spotify Friend Activity extension's popup. @@ -10,28 +9,20 @@ import "./popup.scss"; * @returns {JSX.Element} The popup. */ const Popup = () => { - // Keep track of the FriendActivity component's display state. - const [isDisplayed, setIsDisplayed] = useState(); + const [isDisplayed, setIsDisplayed] = useState(); // Keep track of the FriendActivity component's display state. useEffect(() => { - // Get isDisplayed from chrome local storage. chrome.storage.sync.get("isDisplayed", (store) => { - // If isDisplayed has never been set. (The user hasn't clicked the "Show friend activity" toggle yet) - if (store.isDisplayed === undefined) { - setIsDisplayed(true); - } else { - setIsDisplayed(store.isDisplayed); - } + // If the user hasn't clicked the "Show friend activity" toggle yet... + if (store.isDisplayed === undefined) { setIsDisplayed(true); } + else { setIsDisplayed(store.isDisplayed); } }); }, []); // "Show friend activity" toggle handler. const handleToggleChange = (e) => { const isDisplayed = e.target.checked; - - // Set isDisplayed in chrome local storage. chrome.storage.sync.set({ isDisplayed }); - setIsDisplayed(isDisplayed); }; @@ -40,65 +31,36 @@ const Popup = () => {

Spotify Friend Activity

{isDisplayed !== undefined && ( )}
-
+ {/*
*/} ); }; -// Inject Popup into popup.html. render(, document.getElementById("popup"));