"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"import-sort-style-module": "^6.0.0",
- "lemmy-js-client": "0.17.0-rc.39",
+ "lemmy-js-client": "0.17.0-rc.41",
"lint-staged": "^13.0.3",
"mini-css-extract-plugin": "^2.6.1",
"node-fetch": "^2.6.1",
CreateCommentLike,
CreateCommentReport,
DeleteComment,
+ EditComment,
GetComments,
ListingType,
MarkCommentReplyAsRead,
this.props.admins,
cv.creator.id
);
+ let canModOnSelf = canMod(
+ this.props.moderators,
+ this.props.admins,
+ cv.creator.id,
+ UserService.Instance.myUserInfo,
+ true
+ );
let canAdmin_ = canAdmin(this.props.admins, cv.creator.id);
+ let canAdminOnSelf = canAdmin(
+ this.props.admins,
+ cv.creator.id,
+ UserService.Instance.myUserInfo,
+ true
+ );
let isMod_ = isMod(this.props.moderators, cv.creator.id);
let isAdmin_ = isAdmin(this.props.admins, cv.creator.id);
let amCommunityCreator_ = amCommunityCreator(
>
<div
id={`comment-${cv.comment.id}`}
- className={`details comment-node py-2 ${
- !this.props.noBorder ? "border-top border-light" : ""
- } ${this.isCommentNew ? "mark" : ""}`}
+ className={classNames(`details comment-node py-2`, {
+ "border-top border-light": !this.props.noBorder,
+ mark:
+ this.isCommentNew ||
+ this.props.node.comment_view.comment.distinguished,
+ })}
style={
!this.props.noIndent &&
this.props.node.depth &&
<span class="mr-2">
<PersonListing person={cv.creator} />
</span>
-
+ {cv.comment.distinguished && (
+ <Icon icon="shield" inline classes={`text-danger mr-2`} />
+ )}
{isMod_ && (
<div className="badge badge-light d-none d-sm-inline mr-2">
{i18n.t("mod")}
}`}
/>
</button>
+
+ {(canModOnSelf || canAdminOnSelf) && (
+ <button
+ class="btn btn-link btn-animate text-muted"
+ onClick={linkEvent(
+ this,
+ this.handleDistinguishClick
+ )}
+ data-tippy-content={
+ !cv.comment.distinguished
+ ? i18n.t("distinguish")
+ : i18n.t("undistinguish")
+ }
+ aria-label={
+ !cv.comment.distinguished
+ ? i18n.t("distinguish")
+ : i18n.t("undistinguish")
+ }
+ >
+ <Icon
+ icon="shield"
+ classes={`icon-inline ${
+ cv.comment.distinguished &&
+ "text-danger"
+ }`}
+ />
+ </button>
+ )}
</>
)}
{/* Admins and mods can remove comments */}
i.setState(i.state);
}
+ handleDistinguishClick(i: CommentNode) {
+ let comment = i.props.node.comment_view.comment;
+ let form = new EditComment({
+ comment_id: comment.id,
+ form_id: None, // TODO not sure about this
+ content: None,
+ distinguished: Some(!comment.distinguished),
+ auth: auth().unwrap(),
+ });
+ WebSocketService.Instance.send(wsClient.editComment(form));
+ i.setState(i.state);
+ }
+
isPersonMentionType(
item: CommentView | PersonMentionView | CommentReplyView
): item is PersonMentionView {
export function canAdmin(
admins: Option<PersonViewSafe[]>,
creator_id: number,
- myUserInfo = UserService.Instance.myUserInfo
+ myUserInfo = UserService.Instance.myUserInfo,
+ onSelf = false
): boolean {
- return canMod(None, admins, creator_id, myUserInfo);
+ return canMod(None, admins, creator_id, myUserInfo, onSelf);
}
export function isMod(
let found = comments.find(c => c.comment.id == data.comment.id);
if (found) {
found.comment.content = data.comment.content;
+ found.comment.distinguished = data.comment.distinguished;
found.comment.updated = data.comment.updated;
found.comment.removed = data.comment.removed;
found.comment.deleted = data.comment.deleted;
dependencies:
invert-kv "^1.0.0"
-lemmy-js-client@0.17.0-rc.39:
- version "0.17.0-rc.39"
- resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.39.tgz#b17c5c0d9a0f36c90c17be99845a5703091ab306"
- integrity sha512-MsKavo5xOob6DgfjyhbmXyFvXwdW4iwftStJ7Bz3ArlHXy6zGBp+2uy2rU2c5ujivNDX72ol3TupTHBtSXLs4w==
+lemmy-js-client@0.17.0-rc.41:
+ version "0.17.0-rc.41"
+ resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.41.tgz#a72bd41b76af834d97914d3790810efa610a6e89"
+ integrity sha512-VJ0qMXaEuOvmUxWR/jWnnoWknpNSXxbz/J29ADTn9arJEbOfTQB60ILeg8wICSRI23jzU9/0lqAZ+rjgXN0p4w==
levn@^0.4.1:
version "0.4.1"