mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add offline indicator in popular boards section
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useSubplebbit } from "@plebbit/plebbit-react-hooks";
|
||||
|
||||
const BoardAvatar = ({ address }) => {
|
||||
const [avatarUrl, setAvatarUrl] = useState("assets/plebchan.png");
|
||||
const subplebbit = useSubplebbit({ subplebbitAddress: address });
|
||||
|
||||
const isOnline = subplebbit.updatedAt > Date.now() / 1000 - 60 * 20;
|
||||
|
||||
useEffect(() => {
|
||||
if (subplebbit.suggested?.avatarUrl) {
|
||||
setAvatarUrl(subplebbit.suggested.avatarUrl);
|
||||
}
|
||||
}, [subplebbit.suggested?.avatarUrl, subplebbit]);
|
||||
|
||||
return (
|
||||
<div className="board-avatar-container">
|
||||
<img
|
||||
className={isOnline ? "board-avatar" : "board-avatar offline"}
|
||||
alt="board logo"
|
||||
src={avatarUrl}
|
||||
/>
|
||||
{!isOnline && (
|
||||
<img className="offline-indicator" alt="offline" src="assets/offline.png" />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default BoardAvatar;
|
||||
Reference in New Issue
Block a user