diff --git a/src/components/Button.jsx b/src/components/Button.jsx index e99c8a78db24ae459e1d45f258170421de09d70e..b965282cf8aa61a0c5906ec447f9eaaaaf7be1bd 100644 --- a/src/components/Button.jsx +++ b/src/components/Button.jsx @@ -51,4 +51,4 @@ const Button = ({ ); }; -export default Button; +export default React.memo(Button); diff --git a/src/components/Chip.jsx b/src/components/Chip.jsx index 4e9895cc1f8d2aa00d0a80658882f2fe9d0ad0a0..0ac201fa9a563b22c352c14801c25be79fb5defd 100644 --- a/src/components/Chip.jsx +++ b/src/components/Chip.jsx @@ -26,4 +26,4 @@ const Chip = ({ ); }; -export default Chip; +export default React.memo(Chip); diff --git a/src/components/Dropdown.jsx b/src/components/Dropdown.jsx index f7e1a49e0d0bdf8ad1f7bac134c2ba373462be34..f2b295d36852493cb3d650125a40f42454de458a 100644 --- a/src/components/Dropdown.jsx +++ b/src/components/Dropdown.jsx @@ -25,4 +25,4 @@ const Dropdown = ({ value, options, onChange, className }) => { ); }; -export default Dropdown; +export default React.memo(Dropdown); diff --git a/src/components/ErrorMessage.jsx b/src/components/ErrorMessage.jsx index 9c08d7ebd931ef453af9e74a0a3df88be5a9c32d..1dae2e9cd75a08eb97aae7986dd6fe41b9fcd737 100644 --- a/src/components/ErrorMessage.jsx +++ b/src/components/ErrorMessage.jsx @@ -9,4 +9,4 @@ const ErrorMessage = ({ className, children }) => { ); }; -export default ErrorMessage; +export default React.memo(ErrorMessage); diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index da09c99fd64e2601fc3dfcb637328020bdef763d..9c6298aa1eae93bfa0fc464a8251bde768f8d7e9 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -22,8 +22,8 @@ const Navbar = () => { }, [keycloak]); const connectionStateCaption = { - connected: "Jste online", - offline: "Jste offline", + connected: "Jsi online", + offline: "Jsi offline", connecting: "Probíhá připojování", }[connectionState]; diff --git a/src/components/annoucements/Announcement.jsx b/src/components/annoucements/Announcement.jsx index 728af7616405a15deb6a673e64882d3a824e6fcc..0d9f9c1db37ffd5729ade4d18d5591f9b9d89dff 100644 --- a/src/components/annoucements/Announcement.jsx +++ b/src/components/annoucements/Announcement.jsx @@ -20,7 +20,7 @@ const Announcement = ({ onSeen, }) => { const { ref, inView } = useInView({ - threshold: 1, + threshold: 0.8, trackVisibility: true, delay: 1500, skip: seen, diff --git a/src/components/posts/Post.jsx b/src/components/posts/Post.jsx index 207ed7835ea41651243a4289ab90ccc63da7f35c..e1b5c28627bf1de4106eeb125a9a46137ea59cd9 100644 --- a/src/components/posts/Post.jsx +++ b/src/components/posts/Post.jsx @@ -19,8 +19,8 @@ const Post = ({ archived, state, dimIfArchived = true, + currentUser, canThumb, - canRunActions, onLike, onDislike, onHide, @@ -35,7 +35,7 @@ const Post = ({ onSeen, }) => { const { ref, inView } = useInView({ - threshold: 0.9, + threshold: 0.8, trackVisibility: true, delay: 1500, skip: seen, @@ -123,19 +123,37 @@ const Post = ({ ); } + const isChairman = currentUser && currentUser.role === "chairman"; + const showAnnounceAction = - type === "procedure-proposal" && state === "pending"; + isChairman && type === "procedure-proposal" && state === "pending"; const showAcceptAction = - type === "procedure-proposal" && state === "announced"; + isChairman && type === "procedure-proposal" && state === "announced"; const showRejectAction = - type === "procedure-proposal" && state === "announced"; + isChairman && type === "procedure-proposal" && state === "announced"; const showRejectByChairmanAction = - type === "procedure-proposal" && ["announced", "pending"].includes(state); - const showEditAction = true; - const showBanAction = !author.isBanned; - const showUnbanAction = author.isBanned; - const showHideAction = !archived; - const showArchiveAction = !archived; + isChairman && + type === "procedure-proposal" && + ["announced", "pending"].includes(state); + const showEditAction = + isChairman || (currentUser && currentUser.id === author.id); + const showBanAction = isChairman && !author.isBanned; + const showUnbanAction = isChairman && author.isBanned; + const showHideAction = isChairman && !archived; + const showArchiveAction = isChairman && !archived; + + // Show actions dropdown if any of actions is available. + const showActions = [ + showAnnounceAction, + showAcceptAction, + showRejectAction, + showRejectByChairmanAction, + showEditAction, + showBanAction, + showUnbanAction, + showHideAction, + showArchiveAction, + ].some((item) => !!item); const htmlContent = { __html: content, @@ -163,7 +181,7 @@ const Post = ({ isToday(datetime) ? "H:mm" : "dd. MM. H:mm" )} {modified && ( - <span className="text-grey-200 text-sm block md:inline md:ml-2 underline"> + <span className="text-grey-200 text-sm block md:inline md:ml-2"> (upraveno) </span> )} @@ -183,7 +201,7 @@ const Post = ({ onDislike={onDislike} myVote={ranking.myVote} /> - {canRunActions && ( + {showActions && ( <DropdownMenu right className="pl-4"> {showAnnounceAction && ( <DropdownMenuItem diff --git a/src/components/posts/PostList.jsx b/src/components/posts/PostList.jsx index 23ba693e4badcb2ddea850cbcec1e0fe52696782..ccfa7212899e270d7f40209caa144f67a3b4bfaa 100644 --- a/src/components/posts/PostList.jsx +++ b/src/components/posts/PostList.jsx @@ -6,8 +6,9 @@ import Post from "./Post"; const PostList = ({ className, items, + currentUser, canThumb, - canRunActions, + dimArchived, onLike, onDislike, onHide, @@ -20,7 +21,6 @@ const PostList = ({ onEdit, onArchive, onSeen, - dimArchived, }) => { const buildHandler = (responderFn) => (post) => (evt) => { evt.preventDefault(); @@ -65,8 +65,8 @@ const PostList = ({ seen={item.seen} archived={item.archived} dimIfArchived={dimArchived} + currentUser={currentUser} canThumb={canThumb} - canRunActions={canRunActions} onLike={onPostLike(item)} onDislike={onPostDislike(item)} onHide={onPostHide(item)} @@ -84,8 +84,9 @@ const PostList = ({ /> ))} {!items.length && ( - <p className="p-4 lg:p-0 lg:py-3 "> - Nikdo zatím žádný příspěvek do rozpravy nepřidal. Budeš první? + <p className="p-4 lg:p-0 lg:py-3"> + Nikdo zatím žádný odpovídající příspěvek do rozpravy nepřidal. Budeš + první? </p> )} </div> diff --git a/src/containers/PostsContainer.jsx b/src/containers/PostsContainer.jsx index 863c9155960308d7baa1be862cfbb040bdbb0475..fdfb5157e12fcd19e742f173900ab98b1f2609d9 100644 --- a/src/containers/PostsContainer.jsx +++ b/src/containers/PostsContainer.jsx @@ -166,12 +166,12 @@ const PostsContainer = ({ className }) => { <PostList items={windowItems.slice(sliceStart, sliceEnd)} canThumb={isAuthenticated} - canRunActions={isAuthenticated && user.role === "chairman"} onLike={like.run} onDislike={dislike.run} onSeen={markSeen} className={className} dimArchived={!showingArchivedOnly} + currentUser={user} onHide={setPostToHide} onBanUser={onBanUser} onUnbanUser={onUnbanUser} diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index d494ce94c6c1ebc24c070fadfb2b521c11941401..415224dec7db6f0a1a40c298ed7c9b530fbe79d0 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -205,6 +205,7 @@ const Home = () => { title="Video stream" controls={true} playing={true} + muted={true} width="100%" height="" /> diff --git a/src/pages/Program.jsx b/src/pages/Program.jsx index b9c17a66ffb285486e58afa9f74dcb24428df4ae..8cceb31274b1f61e53903ab38027ec3cb1f82920 100644 --- a/src/pages/Program.jsx +++ b/src/pages/Program.jsx @@ -67,7 +67,11 @@ const Schedule = () => { <strong>Navrhovatel:</strong> <span>{entry.proposer}</span> </div> - {entry.description && <p className="mt-2 leading-tight max-w-3xl">{entry.description}</p>} + {entry.description && ( + <p className="mt-2 leading-tight max-w-3xl"> + {entry.description} + </p> + )} {isAuthenticated && user.role === "chairman" && entry.id !== currentId && ( diff --git a/src/ws/connection.js b/src/ws/connection.js index 7a759346f4306f93363be40dfad96016df6e157e..04f274337f81ed1b7a12a3ab0874db151b197ac4 100644 --- a/src/ws/connection.js +++ b/src/ws/connection.js @@ -49,7 +49,8 @@ function Worker() { const buildKeepalivePayload = async () => { const { user } = AuthStore.getRawState(); const payload = user && user.id ? user.id.toString() : ""; - const signature = !!user.secret ? hmacSHA1(payload, user.secret) : null; + const signature = + user && !!user.secret ? hmacSHA1(payload, user.secret) : null; return { event: "KEEPALIVE",