mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-24 07:16:19 +00:00
Merge branch 'main' into nicer-error-hnadling
This commit is contained in:
commit
fe69f8ee5f
|
@ -251,5 +251,12 @@
|
||||||
<symbol id="icon-superscript" viewBox="0 0 20 20">
|
<symbol id="icon-superscript" viewBox="0 0 20 20">
|
||||||
<path d="M17.5 1h.5V0h-.5a1.49 1.49 0 0 0-1 .39 1.49 1.49 0 0 0-1-.39H15v1h.5a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-.5.5H15v1h.5a1.49 1.49 0 0 0 1-.39 1.49 1.49 0 0 0 1 .39h.5V8h-.5a.5.5 0 0 1-.5-.5v-6a.5.5 0 0 1 .5-.5zm-3.82 15h-2.42a.67.67 0 0 1-.46-.15 1.33 1.33 0 0 1-.28-.34l-2.77-4.44a2.65 2.65 0 0 1-.28.69L5 15.51a2.22 2.22 0 0 1-.29.34.58.58 0 0 1-.42.15H2l4.15-6.19L2.17 4h2.42a.81.81 0 0 1 .41.09.8.8 0 0 1 .24.26L8 8.59a2.71 2.71 0 0 1 .33-.74L10.6 4.4a.69.69 0 0 1 .6-.4h2.32l-4 5.71z" />
|
<path d="M17.5 1h.5V0h-.5a1.49 1.49 0 0 0-1 .39 1.49 1.49 0 0 0-1-.39H15v1h.5a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-.5.5H15v1h.5a1.49 1.49 0 0 0 1-.39 1.49 1.49 0 0 0 1 .39h.5V8h-.5a.5.5 0 0 1-.5-.5v-6a.5.5 0 0 1 .5-.5zm-3.82 15h-2.42a.67.67 0 0 1-.46-.15 1.33 1.33 0 0 1-.28-.34l-2.77-4.44a2.65 2.65 0 0 1-.28.69L5 15.51a2.22 2.22 0 0 1-.29.34.58.58 0 0 1-.42.15H2l4.15-6.19L2.17 4h2.42a.81.81 0 0 1 .41.09.8.8 0 0 1 .24.26L8 8.59a2.71 2.71 0 0 1 .33-.74L10.6 4.4a.69.69 0 0 1 .6-.4h2.32l-4 5.71z" />
|
||||||
</symbol>
|
</symbol>
|
||||||
|
<symbol id="icon-share" viewBox="0 0 24 24">
|
||||||
|
<path d="M21 6C21 7.65685 19.6569 9 18 9C16.3431 9 15 7.65685 15 6C15 4.34315 16.3431 3 18 3C19.6569 3 21 4.34315 21 6Z" stroke-width="2"/>
|
||||||
|
<path d="M21 18C21 19.6569 19.6569 21 18 21C16.3431 21 15 19.6569 15 18C15 16.3431 16.3431 15 18 15C19.6569 15 21 16.3431 21 18Z" stroke-width="2"/>
|
||||||
|
<path d="M9 12C9 13.6569 7.65685 15 6 15C4.34315 15 3 13.6569 3 12C3 10.3431 4.34315 9 6 9C7.65685 9 9 10.3431 9 12Z" stroke-width="2"/>
|
||||||
|
<path d="M8.72046 10.6397L14.9999 7.5" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
<path d="M8.70605 13.353L15 16.5" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</symbol>
|
||||||
</defs>
|
</defs>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
|
@ -42,6 +42,7 @@ import {
|
||||||
colorList,
|
colorList,
|
||||||
commentTreeMaxDepth,
|
commentTreeMaxDepth,
|
||||||
futureDaysToUnixTime,
|
futureDaysToUnixTime,
|
||||||
|
getCommentParentId,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
isBanned,
|
isBanned,
|
||||||
isMod,
|
isMod,
|
||||||
|
@ -282,8 +283,15 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
{this.linkBtn(true)}
|
{this.linkBtn(true)}
|
||||||
|
<span className="mx-1 badge badge-secondary">
|
||||||
|
{
|
||||||
|
this.props.allLanguages.find(
|
||||||
|
lang => lang.id === cv.comment.language_id
|
||||||
|
)?.name
|
||||||
|
}
|
||||||
|
</span>
|
||||||
{/* This is an expanding spacer for mobile */}
|
{/* This is an expanding spacer for mobile */}
|
||||||
<div className="mr-lg-5 flex-grow-1 flex-lg-grow-0 unselectable pointer mx-2"></div>
|
<div className="mr-lg-5 flex-grow-1 flex-lg-grow-0 unselectable pointer mx-2" />
|
||||||
{showScores() && (
|
{showScores() && (
|
||||||
<>
|
<>
|
||||||
<a
|
<a
|
||||||
|
@ -1044,11 +1052,14 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
? i18n.t("show_context")
|
? i18n.t("show_context")
|
||||||
: i18n.t("link");
|
: i18n.t("link");
|
||||||
|
|
||||||
|
// The context button should show the parent comment by default
|
||||||
|
const parentCommentId = getCommentParentId(cv.comment) ?? cv.comment.id;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Link
|
<Link
|
||||||
className={classnames}
|
className={classnames}
|
||||||
to={`/comment/${cv.comment.id}`}
|
to={`/comment/${parentCommentId}`}
|
||||||
title={title}
|
title={title}
|
||||||
>
|
>
|
||||||
<Icon icon="link" classes="icon-inline" />
|
<Icon icon="link" classes="icon-inline" />
|
||||||
|
|
|
@ -22,7 +22,7 @@ import {
|
||||||
SavePost,
|
SavePost,
|
||||||
TransferCommunity,
|
TransferCommunity,
|
||||||
} from "lemmy-js-client";
|
} from "lemmy-js-client";
|
||||||
import { getExternalHost } from "../../env";
|
import { getExternalHost, getHttpBase } from "../../env";
|
||||||
import { i18n } from "../../i18next";
|
import { i18n } from "../../i18next";
|
||||||
import { BanType, PostFormParams, PurgeType } from "../../interfaces";
|
import { BanType, PostFormParams, PurgeType } from "../../interfaces";
|
||||||
import { UserService, WebSocketService } from "../../services";
|
import { UserService, WebSocketService } from "../../services";
|
||||||
|
@ -32,6 +32,7 @@ import {
|
||||||
amMod,
|
amMod,
|
||||||
canAdmin,
|
canAdmin,
|
||||||
canMod,
|
canMod,
|
||||||
|
canShare,
|
||||||
futureDaysToUnixTime,
|
futureDaysToUnixTime,
|
||||||
hostname,
|
hostname,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
|
@ -46,6 +47,7 @@ import {
|
||||||
numToSI,
|
numToSI,
|
||||||
relTags,
|
relTags,
|
||||||
setupTippy,
|
setupTippy,
|
||||||
|
share,
|
||||||
showScores,
|
showScores,
|
||||||
wsClient,
|
wsClient,
|
||||||
} from "../../utils";
|
} from "../../utils";
|
||||||
|
@ -342,6 +344,13 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</li>
|
</li>
|
||||||
|
<span className="mx-1 badge badge-secondary">
|
||||||
|
{
|
||||||
|
this.props.allLanguages.find(
|
||||||
|
lang => lang.id === post_view.post.language_id
|
||||||
|
)?.name
|
||||||
|
}
|
||||||
|
</span>
|
||||||
<li className="list-inline-item">•</li>
|
<li className="list-inline-item">•</li>
|
||||||
{url && !(hostname(url) === getExternalHost()) && (
|
{url && !(hostname(url) === getExternalHost()) && (
|
||||||
<>
|
<>
|
||||||
|
@ -560,9 +569,19 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
|
|
||||||
commentsLine(mobile = false) {
|
commentsLine(mobile = false) {
|
||||||
let post = this.props.post_view.post;
|
let post = this.props.post_view.post;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="d-flex justify-content-start flex-wrap text-muted font-weight-bold mb-1">
|
<div className="d-flex justify-content-start flex-wrap text-muted font-weight-bold mb-1">
|
||||||
{this.commentsButton}
|
{this.commentsButton}
|
||||||
|
{canShare() && (
|
||||||
|
<button
|
||||||
|
className="btn btn-link"
|
||||||
|
onClick={linkEvent(this, this.handleShare)}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<Icon icon="share" inline />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
{!post.local && (
|
{!post.local && (
|
||||||
<a
|
<a
|
||||||
className="btn btn-link btn-animate text-muted py-0"
|
className="btn btn-link btn-animate text-muted py-0"
|
||||||
|
@ -1399,6 +1418,15 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
this.setState({ showEdit: false });
|
this.setState({ showEdit: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleShare(i: PostListing) {
|
||||||
|
const { name, body, id } = i.props.post_view.post;
|
||||||
|
share({
|
||||||
|
title: name,
|
||||||
|
text: body?.slice(0, 50),
|
||||||
|
url: `${getHttpBase()}/post/${id}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
handleShowReportDialog(i: PostListing) {
|
handleShowReportDialog(i: PostListing) {
|
||||||
i.setState({ showReportDialog: !i.state.showReportDialog });
|
i.setState({ showReportDialog: !i.state.showReportDialog });
|
||||||
}
|
}
|
||||||
|
|
|
@ -1591,3 +1591,13 @@ export function isAuthPath(pathname: string) {
|
||||||
pathname
|
pathname
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function canShare() {
|
||||||
|
return isBrowser() && !!navigator.canShare;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function share(shareData: ShareData) {
|
||||||
|
if (isBrowser()) {
|
||||||
|
navigator.share(shareData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue