Fix Lemmy post links not working

Because it's self-referential
pull/228/head
Lim Chee Aun 2023-09-21 13:02:40 +08:00
rodzic b3501d158f
commit 674c99a05d
2 zmienionych plików z 12 dodań i 3 usunięć

Wyświetl plik

@ -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,

Wyświetl plik

@ -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 = {