diff --git a/src/views/home/home.module.css b/src/views/home/home.module.css index c01eb15a..b67a9550 100644 --- a/src/views/home/home.module.css +++ b/src/views/home/home.module.css @@ -135,6 +135,18 @@ font-size: smaller; } +.offlineIcon { + background-image: url('/public/assets/icons/offline.png'); + display: inline-block; + vertical-align: text-top; + margin-left: 2px; + width: 13px; + height: 13px; + background-repeat: no-repeat; + background-size: contain; + image-rendering: pixelated; +} + .boardsBoxContent { font-size: 93%; padding: 0.5em; diff --git a/src/views/home/home.tsx b/src/views/home/home.tsx index 9feb42c4..90a38175 100644 --- a/src/views/home/home.tsx +++ b/src/views/home/home.tsx @@ -73,7 +73,21 @@ const InfoBox = () => { ); }; -const Boards = ({ multisub }: { multisub: Subplebbit[] }) => { +const Board = ({ isOffline, subplebbit }: { isOffline: boolean; subplebbit: Subplebbit }) => { + const { t } = useTranslation(); + const { address, title, tags } = subplebbit; + const isSubNsfw = tags.includes('porn') || tags.includes('gore') || tags.includes('violence') || tags.includes('vulgar'); + + return ( +
+ {title || address} + {isSubNsfw && ({t('nsfw')})} + {isOffline && } +
+ ); +}; + +const Boards = ({ multisub, subplebbits }: { multisub: Subplebbit[]; subplebbits: any }) => { const { t } = useTranslation(); const account = useAccount(); const subscriptions = account?.subscriptions || []; @@ -88,8 +102,10 @@ const Boards = ({ multisub }: { multisub: Subplebbit[] }) => { const internationalSubs = multisub.filter((sub) => sub.tags.includes('international') || sub.tags.includes('country')); const projectsSubs = multisub.filter((sub) => sub.tags.includes('project') && !sub.tags.includes('plebbit') && !sub.tags.includes('topic')); - const isSubNsfw = (sub: Subplebbit) => { - return sub.tags.includes('porn') || sub.tags.includes('gore') || sub.tags.includes('violence') || sub.tags.includes('vulgar'); + const isSubOffline = (address: string) => { + const subplebbit = subplebbits && subplebbits.find((sub: Subplebbit) => sub?.address === address); + const isOffline = subplebbit?.updatedAt && subplebbit.updatedAt < Date.now() / 1000 - 60 * 30; + return isOffline; }; return ( @@ -103,19 +119,13 @@ const Boards = ({ multisub }: { multisub: Subplebbit[] }) => {

Plebbit

{plebbitSubs.map((sub) => ( -
- {sub.title || sub.address} - {isSubNsfw(sub) && ({t('nsfw')})} -
+ ))}

Projects

{projectsSubs.map((sub) => ( -
- {sub.title || sub.address} - {isSubNsfw(sub) && ({t('nsfw')})} -
+ ))}
@@ -123,10 +133,7 @@ const Boards = ({ multisub }: { multisub: Subplebbit[] }) => {

Interests

{interestsSubs.map((sub) => ( -
- {sub.title || sub.address} - {isSubNsfw(sub) && ({t('nsfw')})} -
+ ))}
@@ -134,19 +141,13 @@ const Boards = ({ multisub }: { multisub: Subplebbit[] }) => {

Random

{randomSubs.map((sub) => ( -
- {sub.title || sub.address} - {isSubNsfw(sub) && ({t('nsfw')})} -
+ ))}

International

{internationalSubs.map((sub) => ( -
- {sub.title || sub.address} - {isSubNsfw(sub) && ({t('nsfw')})} -
+ ))}
@@ -484,7 +485,7 @@ const Home = () => { - +