Fix Lemmy post links not working

Because it's self-referential
This commit is contained in:
Lim Chee Aun 2023-09-21 13:02:40 +08:00
parent b3501d158f
commit 674c99a05d
2 changed files with 12 additions and 3 deletions

View file

@ -1128,7 +1128,12 @@ function Status({
lang={language}
dir="auto"
class="inner-content"
onClick={handleContentLinks({ mentions, instance, previewMode })}
onClick={handleContentLinks({
mentions,
instance,
previewMode,
statusURL: url,
})}
dangerouslySetInnerHTML={{
__html: enhanceContent(content, {
emojis,

View file

@ -1,7 +1,7 @@
import states from './states';
function handleContentLinks(opts) {
const { mentions = [], instance, previewMode } = opts || {};
const { mentions = [], instance, previewMode, statusURL } = opts || {};
return (e) => {
let { target } = e;
target = target.closest('a');
@ -50,7 +50,11 @@ function handleContentLinks(opts) {
const hashURL = instance ? `#/${instance}/t/${tag}` : `#/t/${tag}`;
console.log({ hashURL });
location.hash = hashURL;
} else if (states.unfurledLinks[target.href]?.url) {
} else if (
states.unfurledLinks[target.href]?.url &&
statusURL !== target.href
) {
// If unfurled AND not self-referential
e.preventDefault();
e.stopPropagation();
states.prevLocation = {