Skip to content
Snippets Groups Projects
Commit 7cb67a1f authored by xaralis's avatar xaralis
Browse files

feat: allow editing of my posts

parent efe2a72e
No related branches found
No related tags found
No related merge requests found
...@@ -51,4 +51,4 @@ const Button = ({ ...@@ -51,4 +51,4 @@ const Button = ({
); );
}; };
export default Button; export default React.memo(Button);
...@@ -26,4 +26,4 @@ const Chip = ({ ...@@ -26,4 +26,4 @@ const Chip = ({
); );
}; };
export default Chip; export default React.memo(Chip);
...@@ -25,4 +25,4 @@ const Dropdown = ({ value, options, onChange, className }) => { ...@@ -25,4 +25,4 @@ const Dropdown = ({ value, options, onChange, className }) => {
); );
}; };
export default Dropdown; export default React.memo(Dropdown);
...@@ -9,4 +9,4 @@ const ErrorMessage = ({ className, children }) => { ...@@ -9,4 +9,4 @@ const ErrorMessage = ({ className, children }) => {
); );
}; };
export default ErrorMessage; export default React.memo(ErrorMessage);
...@@ -22,8 +22,8 @@ const Navbar = () => { ...@@ -22,8 +22,8 @@ const Navbar = () => {
}, [keycloak]); }, [keycloak]);
const connectionStateCaption = { const connectionStateCaption = {
connected: "Jste online", connected: "Jsi online",
offline: "Jste offline", offline: "Jsi offline",
connecting: "Probíhá připojování", connecting: "Probíhá připojování",
}[connectionState]; }[connectionState];
......
...@@ -20,7 +20,7 @@ const Announcement = ({ ...@@ -20,7 +20,7 @@ const Announcement = ({
onSeen, onSeen,
}) => { }) => {
const { ref, inView } = useInView({ const { ref, inView } = useInView({
threshold: 1, threshold: 0.8,
trackVisibility: true, trackVisibility: true,
delay: 1500, delay: 1500,
skip: seen, skip: seen,
......
...@@ -19,8 +19,8 @@ const Post = ({ ...@@ -19,8 +19,8 @@ const Post = ({
archived, archived,
state, state,
dimIfArchived = true, dimIfArchived = true,
currentUser,
canThumb, canThumb,
canRunActions,
onLike, onLike,
onDislike, onDislike,
onHide, onHide,
...@@ -35,7 +35,7 @@ const Post = ({ ...@@ -35,7 +35,7 @@ const Post = ({
onSeen, onSeen,
}) => { }) => {
const { ref, inView } = useInView({ const { ref, inView } = useInView({
threshold: 0.9, threshold: 0.8,
trackVisibility: true, trackVisibility: true,
delay: 1500, delay: 1500,
skip: seen, skip: seen,
...@@ -123,19 +123,37 @@ const Post = ({ ...@@ -123,19 +123,37 @@ const Post = ({
); );
} }
const isChairman = currentUser && currentUser.role === "chairman";
const showAnnounceAction = const showAnnounceAction =
type === "procedure-proposal" && state === "pending"; isChairman && type === "procedure-proposal" && state === "pending";
const showAcceptAction = const showAcceptAction =
type === "procedure-proposal" && state === "announced"; isChairman && type === "procedure-proposal" && state === "announced";
const showRejectAction = const showRejectAction =
type === "procedure-proposal" && state === "announced"; isChairman && type === "procedure-proposal" && state === "announced";
const showRejectByChairmanAction = const showRejectByChairmanAction =
type === "procedure-proposal" && ["announced", "pending"].includes(state); isChairman &&
const showEditAction = true; type === "procedure-proposal" &&
const showBanAction = !author.isBanned; ["announced", "pending"].includes(state);
const showUnbanAction = author.isBanned; const showEditAction =
const showHideAction = !archived; isChairman || (currentUser && currentUser.id === author.id);
const showArchiveAction = !archived; 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 = { const htmlContent = {
__html: content, __html: content,
...@@ -163,7 +181,7 @@ const Post = ({ ...@@ -163,7 +181,7 @@ const Post = ({
isToday(datetime) ? "H:mm" : "dd. MM. H:mm" isToday(datetime) ? "H:mm" : "dd. MM. H:mm"
)} )}
{modified && ( {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) (upraveno)
</span> </span>
)} )}
...@@ -183,7 +201,7 @@ const Post = ({ ...@@ -183,7 +201,7 @@ const Post = ({
onDislike={onDislike} onDislike={onDislike}
myVote={ranking.myVote} myVote={ranking.myVote}
/> />
{canRunActions && ( {showActions && (
<DropdownMenu right className="pl-4"> <DropdownMenu right className="pl-4">
{showAnnounceAction && ( {showAnnounceAction && (
<DropdownMenuItem <DropdownMenuItem
......
...@@ -6,8 +6,9 @@ import Post from "./Post"; ...@@ -6,8 +6,9 @@ import Post from "./Post";
const PostList = ({ const PostList = ({
className, className,
items, items,
currentUser,
canThumb, canThumb,
canRunActions, dimArchived,
onLike, onLike,
onDislike, onDislike,
onHide, onHide,
...@@ -20,7 +21,6 @@ const PostList = ({ ...@@ -20,7 +21,6 @@ const PostList = ({
onEdit, onEdit,
onArchive, onArchive,
onSeen, onSeen,
dimArchived,
}) => { }) => {
const buildHandler = (responderFn) => (post) => (evt) => { const buildHandler = (responderFn) => (post) => (evt) => {
evt.preventDefault(); evt.preventDefault();
...@@ -65,8 +65,8 @@ const PostList = ({ ...@@ -65,8 +65,8 @@ const PostList = ({
seen={item.seen} seen={item.seen}
archived={item.archived} archived={item.archived}
dimIfArchived={dimArchived} dimIfArchived={dimArchived}
currentUser={currentUser}
canThumb={canThumb} canThumb={canThumb}
canRunActions={canRunActions}
onLike={onPostLike(item)} onLike={onPostLike(item)}
onDislike={onPostDislike(item)} onDislike={onPostDislike(item)}
onHide={onPostHide(item)} onHide={onPostHide(item)}
...@@ -85,7 +85,8 @@ const PostList = ({ ...@@ -85,7 +85,8 @@ const PostList = ({
))} ))}
{!items.length && ( {!items.length && (
<p className="p-4 lg:p-0 lg:py-3"> <p className="p-4 lg:p-0 lg:py-3">
Nikdo zatím žádný příspěvek do rozpravy nepřidal. Budeš první? Nikdo zatím žádný odpovídající příspěvek do rozpravy nepřidal. Budeš
první?
</p> </p>
)} )}
</div> </div>
......
...@@ -166,12 +166,12 @@ const PostsContainer = ({ className }) => { ...@@ -166,12 +166,12 @@ const PostsContainer = ({ className }) => {
<PostList <PostList
items={windowItems.slice(sliceStart, sliceEnd)} items={windowItems.slice(sliceStart, sliceEnd)}
canThumb={isAuthenticated} canThumb={isAuthenticated}
canRunActions={isAuthenticated && user.role === "chairman"}
onLike={like.run} onLike={like.run}
onDislike={dislike.run} onDislike={dislike.run}
onSeen={markSeen} onSeen={markSeen}
className={className} className={className}
dimArchived={!showingArchivedOnly} dimArchived={!showingArchivedOnly}
currentUser={user}
onHide={setPostToHide} onHide={setPostToHide}
onBanUser={onBanUser} onBanUser={onBanUser}
onUnbanUser={onUnbanUser} onUnbanUser={onUnbanUser}
......
...@@ -205,6 +205,7 @@ const Home = () => { ...@@ -205,6 +205,7 @@ const Home = () => {
title="Video stream" title="Video stream"
controls={true} controls={true}
playing={true} playing={true}
muted={true}
width="100%" width="100%"
height="" height=""
/> />
......
...@@ -67,7 +67,11 @@ const Schedule = () => { ...@@ -67,7 +67,11 @@ const Schedule = () => {
<strong>Navrhovatel:</strong> <strong>Navrhovatel:</strong>
<span>{entry.proposer}</span> <span>{entry.proposer}</span>
</div> </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 && {isAuthenticated &&
user.role === "chairman" && user.role === "chairman" &&
entry.id !== currentId && ( entry.id !== currentId && (
......
...@@ -49,7 +49,8 @@ function Worker() { ...@@ -49,7 +49,8 @@ function Worker() {
const buildKeepalivePayload = async () => { const buildKeepalivePayload = async () => {
const { user } = AuthStore.getRawState(); const { user } = AuthStore.getRawState();
const payload = user && user.id ? user.id.toString() : ""; 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 { return {
event: "KEEPALIVE", event: "KEEPALIVE",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment