From d30bb56e75d26e471b30e637c35c91b5d8a2929c Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Tue, 12 Nov 2024 13:33:43 +0500 Subject: [PATCH] web: remove unused modules & components --- .../src/components/install-notice/index.jsx | 129 ------------------ .../src/components/loaders/view-loader.tsx | 39 ------ .../src/components/text-scramble/index.tsx | 116 ---------------- 3 files changed, 284 deletions(-) delete mode 100644 apps/web/src/components/install-notice/index.jsx delete mode 100644 apps/web/src/components/loaders/view-loader.tsx delete mode 100644 apps/web/src/components/text-scramble/index.tsx diff --git a/apps/web/src/components/install-notice/index.jsx b/apps/web/src/components/install-notice/index.jsx deleted file mode 100644 index 2398a0003..000000000 --- a/apps/web/src/components/install-notice/index.jsx +++ /dev/null @@ -1,129 +0,0 @@ -/* -This file is part of the Notesnook project (https://notesnook.com/) - -Copyright (C) 2023 Streetwriters (Private) Limited - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -import ReactDOM from "react-dom"; -import { Box, Button, Flex, Text } from "@theme-ui/components"; -import Config from "../../utils/config"; -import { getDownloadLink, getPlatform } from "../../utils/platform"; -import DropdownButton from "../dropdown-button"; -import { BaseThemeProvider } from "../theme-provider"; -import { strings } from "@notesnook/intl"; - -const platform = getPlatform(); -const isMobile = platform === "Android" || platform === "iOS"; -function getOptions(onClose) { - return getDownloadLink(platform).map((item) => ({ - key: item.type || item.link, - title: () => { - return `${item.type}`; - }, - onClick: () => { - window.open(item.link, "_blank"); - onClose(); - Config.set("installNotice", false); - } - })); -} - -export default function InstallNotice({ onClose }) { - return ( - - {strings.installNotesnook()} - {strings.installNotesnookDesc(platform)}. - {isMobile && ( - - {strings.nativeFeatures().map((feature) => ( - - - {feature} - - - ))} - - )} - - - - - - - ); -} - -export function showInstallNotice() { - if (!Config.get("installNotice", true)) return; - - const root = document.getElementById("floatingViewContainer"); - - if (root) { - return new Promise((resolve) => { - const perform = (result) => { - ReactDOM.unmountComponentAtNode(root); - resolve(result); - }; - ReactDOM.render( - - - , - root - ); - }); - } - return Promise.reject("No element with id 'floatingViewContainer'"); -} diff --git a/apps/web/src/components/loaders/view-loader.tsx b/apps/web/src/components/loaders/view-loader.tsx deleted file mode 100644 index 38a6becc7..000000000 --- a/apps/web/src/components/loaders/view-loader.tsx +++ /dev/null @@ -1,39 +0,0 @@ -/* -This file is part of the Notesnook project (https://notesnook.com/) - -Copyright (C) 2023 Streetwriters (Private) Limited - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -import { memo } from "react"; -import Skeleton from "react-loading-skeleton"; -import { Box, Flex } from "@theme-ui/components"; -import "react-loading-skeleton/dist/skeleton.css"; -import { ListLoader } from "./list-loader"; - -export const ViewLoader = memo(function ViewLoader() { - return ( - - - - - - - - - - - ); -}); diff --git a/apps/web/src/components/text-scramble/index.tsx b/apps/web/src/components/text-scramble/index.tsx deleted file mode 100644 index 3eddad327..000000000 --- a/apps/web/src/components/text-scramble/index.tsx +++ /dev/null @@ -1,116 +0,0 @@ -/* -This file is part of the Notesnook project (https://notesnook.com/) - -Copyright (C) 2023 Streetwriters (Private) Limited - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -import { useState, useEffect } from "react"; - -type TextScrambleProps = { - text: string; - className?: string; - letterSpeed?: number; - nextLetterSpeed?: number; - paused?: boolean; - pauseTime?: number; -}; - -const randomItem = (array: Array) => - array[Math.floor(Math.random() * array.length)]; - -const nextItem = (array: Array, currentItem: any) => { - const currentIndex = array.indexOf(currentItem); - const bound = array.length; - const nextIndex = (currentIndex + bound + 1) % bound; - return array[nextIndex]; -}; - -const symbols: string[] = "-=_+/.,<>;'!@#$%^&*()".split(""); - -export function TextScramble(props: TextScrambleProps) { - const { - text, - className, - letterSpeed = 5, - nextLetterSpeed = 100, - paused = false, - pauseTime = 1500 - } = props; - - const initSymbols: string[] = Array(text.length) - .fill(0) - .map(() => randomItem(symbols)); - - const [displayedText, setDisplayedText] = useState(initSymbols); - - const leftIndexes: number[] = []; - - const defaultLeftIndexes = (): void => { - text.split("").forEach((_, i) => { - leftIndexes.push(i); - }); - }; - - let bakeLetterInterval: any = 0; - let bakeTextInterval: any = 0; - - const bakeLetter = () => { - bakeLetterInterval = setInterval(() => { - if (!paused) { - const updatedText: string[] = []; - - text.split("").forEach((_, i) => { - if (!leftIndexes.includes(i)) { - updatedText[i] = text[i]; - return; - } - - const randomSymbol = randomItem(symbols); - updatedText[i] = randomSymbol; - }); - - setDisplayedText(updatedText); - } - }, letterSpeed); - }; - - const bakeText = () => { - defaultLeftIndexes(); - bakeLetter(); - - bakeTextInterval = setInterval(() => { - if (!paused) { - if (leftIndexes.length === 0) { - clearInterval(bakeLetterInterval); - clearInterval(bakeTextInterval); - - setTimeout(() => { - // setCurrentText(text); - defaultLeftIndexes(); - }, pauseTime); - } - - leftIndexes.shift(); - } - }, nextLetterSpeed); - }; - - useEffect(() => { - if (!paused) bakeText(); - }, [text, paused]); // eslint-disable-line react-hooks/exhaustive-deps - - return
{displayedText}
; -}