mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-24 06:16:25 +02:00
Updated links model and poll page (#206)
* Improved sharing * Updated desktop poll
This commit is contained in:
parent
c4cbf2f6bb
commit
2ead375b42
50 changed files with 955 additions and 1848 deletions
|
@ -27,9 +27,9 @@ interface CommentForm {
|
|||
const Discussion: React.VoidFunctionComponent = () => {
|
||||
const { locale } = usePreferences();
|
||||
const queryClient = trpc.useContext();
|
||||
const {
|
||||
poll: { pollId },
|
||||
} = usePoll();
|
||||
const { poll } = usePoll();
|
||||
|
||||
const pollId = poll.id;
|
||||
|
||||
const { data: comments } = trpc.useQuery(
|
||||
["polls.comments.list", { pollId }],
|
||||
|
@ -53,8 +53,6 @@ const Discussion: React.VoidFunctionComponent = () => {
|
|||
},
|
||||
});
|
||||
|
||||
const { poll } = usePoll();
|
||||
|
||||
const deleteComment = trpc.useMutation("polls.comments.delete", {
|
||||
onMutate: ({ commentId }) => {
|
||||
queryClient.setQueryData(
|
||||
|
@ -96,9 +94,7 @@ const Discussion: React.VoidFunctionComponent = () => {
|
|||
<AnimatePresence initial={false}>
|
||||
{comments.map((comment) => {
|
||||
const canDelete =
|
||||
poll.role === "admin" ||
|
||||
session.ownsObject(comment) ||
|
||||
isUnclaimed(comment);
|
||||
poll.admin || session.ownsObject(comment) || isUnclaimed(comment);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
|
@ -135,23 +131,22 @@ const Discussion: React.VoidFunctionComponent = () => {
|
|||
)}
|
||||
</span>
|
||||
</div>
|
||||
{canDelete ? (
|
||||
<Dropdown
|
||||
placement="bottom-start"
|
||||
trigger={<CompactButton icon={DotsHorizontal} />}
|
||||
>
|
||||
<DropdownItem
|
||||
icon={Trash}
|
||||
label="Delete comment"
|
||||
onClick={() => {
|
||||
deleteComment.mutate({
|
||||
commentId: comment.id,
|
||||
pollId,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Dropdown>
|
||||
) : null}
|
||||
<Dropdown
|
||||
placement="bottom-start"
|
||||
trigger={<CompactButton icon={DotsHorizontal} />}
|
||||
>
|
||||
<DropdownItem
|
||||
icon={Trash}
|
||||
label="Delete comment"
|
||||
disabled={!canDelete}
|
||||
onClick={() => {
|
||||
deleteComment.mutate({
|
||||
commentId: comment.id,
|
||||
pollId,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Dropdown>
|
||||
</div>
|
||||
<div className="w-fit whitespace-pre-wrap">
|
||||
<TruncatedLinkify>{comment.content}</TruncatedLinkify>
|
||||
|
@ -187,11 +182,7 @@ const Discussion: React.VoidFunctionComponent = () => {
|
|||
)}
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
htmlType="submit"
|
||||
loading={formState.isSubmitting}
|
||||
type="primary"
|
||||
>
|
||||
<Button htmlType="submit" loading={formState.isSubmitting}>
|
||||
Comment
|
||||
</Button>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue