Skip to content

Commit

Permalink
Fix hide blocked resources (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonic16x authored Nov 1, 2024
1 parent b81a245 commit 6a1a59d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 66 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "interslavic",
"version": "1.20.4",
"version": "1.21.0",
"license": "MIT",
"description": "Interslavic Dictionary",
"author": "Sergey Cherebedov",
Expand Down
8 changes: 2 additions & 6 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from 'classnames';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useCallback, useEffect, useRef, useState } from 'react';
import { useDispatch } from 'react-redux';

import { t } from 'translations';
Expand All @@ -12,8 +12,6 @@ import { useInterfaceLang } from 'hooks/useInterfaceLang';
import { usePage } from 'hooks/usePage';
import { defaultPages, pages } from 'routing';

import { useCookie } from "../../hooks/useCookie";

import './Header.scss';

import LogoIcon from './images/logo-icon.svg';
Expand All @@ -31,8 +29,6 @@ export const Header =
const enabledPages = useEnabledPages();
const navRef = useRef<HTMLDivElement>();
const logoRef = useRef<HTMLDivElement>();
const countryCode = useCookie('country')
const isRU = useMemo(() => countryCode === 'RU', [countryCode])

const onResize = useCallback(() => {
if (navRef && navRef.current && logoRef && logoRef.current) {
Expand Down Expand Up @@ -94,7 +90,7 @@ export const Header =
>
{pages
.filter(({ value }) => {
if (value === 'community' && isRU) {
if (value === 'community' && IS_COM) {
return false
}

Expand Down
43 changes: 11 additions & 32 deletions src/components/Link/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import classNames from 'classnames';
import { useEffect, useState } from 'react';

import './Link.scss';

Expand All @@ -23,36 +22,16 @@ export const Link = (
}: ILinkProps,
) => {
const clsName = classNames(['link', className]);
const [isAvailable, setAvailable] = useState(false);

useEffect(() => {
try {
fetch(href, {
mode: 'no-cors',
cache: 'no-cache',
}).then((res) => {
if (res) {
setAvailable(true);
}
});
} catch (err) {

}
}, [href, setAvailable]);

if (isAvailable) {
return (
<a
className={clsName}
href={href}
title={title}
target={target}
rel={rel}
>
{children}
</a>
);
}

return null;
return (
<a
className={clsName}
href={href}
title={title}
target={target}
rel={rel}
>
{children}
</a>
);
};
17 changes: 6 additions & 11 deletions src/components/Pages/About/About.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { useMemo } from "react";

import { tablesData } from 'consts';

import { t } from 'translations';

import { useCookie } from "hooks/useCookie";
import { getTablePublicUrl } from 'utils/getTablePublicUrl';

import { Link } from 'components/Link';
Expand All @@ -14,8 +11,6 @@ import './About.scss';
export const About =
() => {
const worksheetUrl = getTablePublicUrl(tablesData[0].spreadsheetId, tablesData[0].sheetId);
const countryCode = useCookie('country')
const isRU = useMemo(() => countryCode === 'RU', [countryCode])
const email = '[email protected]';
const github = 'https://github.com/sonic16x/interslavic';
const source = 'http://steen.free.fr/interslavic';
Expand All @@ -42,11 +37,11 @@ export const About =
<div className="about-page__author">
{t('aboutAuthorSergeyCherebedov')}:
<a target="_blank" rel="noreferrer" href="https://github.com/sonic16x">GitHub</a>
{!isRU && (
{IS_COM && (
<a target="_blank" rel="noreferrer"
href="https://www.linkedin.com/in/scherebedov/">LinkedIn</a>
)}
{!isRU && (
{IS_COM && (
<Link
href="https://www.facebook.com/profile.php?id=100009366550621"
target="_blank"
Expand All @@ -61,7 +56,7 @@ export const About =
<div className="about-page__author">
{t('aboutAuthorDenisShabalin')}:
<a target="_blank" rel="noreferrer" href="https://github.com/ru-danko">GitHub</a>
{!isRU && (
{IS_COM && (
<Link
href="https://www.facebook.com/d.y.shabalin"
target="_blank"
Expand All @@ -85,7 +80,7 @@ export const About =
<hr/>
<h6>{t('aboutOurFriends')}</h6>
<div className="about-page__community-links">
{!isRU && (
{IS_COM && (
<Link
title="Interslavic Facebook"
href="https://www.facebook.com/groups/interslavic"
Expand All @@ -95,7 +90,7 @@ export const About =
Facebook community
</Link>
)}
{!isRU && (
{IS_COM && (
<a
title="Interslavic Discord"
href="https://discord.com/invite/n3saqm27QW"
Expand Down Expand Up @@ -138,7 +133,7 @@ export const About =
/>
</a>*/}

{!isRU && (
{IS_COM && (
<a
href="https://discord.com/invite/n3saqm27QW"
title="Get it on Discord"
Expand Down
1 change: 1 addition & 0 deletions src/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ declare const GOOGLE_WORD_ERRORS_TABLE_ID: string;
declare const GOOGLE_SERVICE_ACCOUNT_EMAIL: string;
declare const GOOGLE_PRIVATE_KEY: string;
declare const FB: any;
declare const IS_COM: boolean;
14 changes: 0 additions & 14 deletions src/hooks/useCookie.ts

This file was deleted.

0 comments on commit 6a1a59d

Please sign in to comment.