From 21244c267f64d759a6526027cdaf8ccc4c3ec2f4 Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Mon, 9 Jan 2023 02:35:22 +0100 Subject: [PATCH] Remove unused old LocaleSwitcher component. --- frontend/components/___LocaleSwitcher.jsx | 107 ---------------------- 1 file changed, 107 deletions(-) delete mode 100644 frontend/components/___LocaleSwitcher.jsx diff --git a/frontend/components/___LocaleSwitcher.jsx b/frontend/components/___LocaleSwitcher.jsx deleted file mode 100644 index fa3f506..0000000 --- a/frontend/components/___LocaleSwitcher.jsx +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Copyright (C) 2019-2021 Carl Kittelberger - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import React, { useEffect } from 'react'; -// import useSWR from 'swr'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { - Button, - // Spinner -} from 'react-bootstrap'; -import useSWR from 'swr'; -import { FormattedMessage } from 'react-intl'; -import { fetchJson } from '../util/api'; - -let darkToggleAnimationTimer = null; - -function triggerDarkToggleAnimation() { - document.documentElement.setAttribute('data-toggled-dark', 'true'); - if (darkToggleAnimationTimer !== null) { - clearTimeout(darkToggleAnimationTimer); - } - darkToggleAnimationTimer = setTimeout(() => { - document.documentElement.removeAttribute('data-toggled-dark'); - }, 1200); -} - -export default function DarkToggler() { - const { - data, error, isValidating, mutate, - } = useSWR('/api/user'); - - let enableDark = false; - let isLoading = false; - - if (isValidating || !data) { - isLoading = true; - } - if (error) { - console.warn(error); - isLoading = false; - } else if (data) { - enableDark = data.enableDark; - } - - useEffect(() => { - if (!isLoading) { - console.info('enable dark:', enableDark); - if (enableDark) { - document.documentElement.setAttribute('data-enable-dark', 'true'); - } else { - document.documentElement.removeAttribute('data-enable-dark'); - } - } - }); - - return ( - <> - - - ); -}