Quietly handle hashtag links

No follow/unfollow yet.
pull/49/head
Lim Chee Aun 2023-01-31 19:31:25 +08:00
rodzic 9a261470df
commit bbb3017b2d
4 zmienionych plików z 15 dodań i 8 usunięć

Wyświetl plik

@ -4,7 +4,7 @@ import { useEffect, useState } from 'preact/hooks';
import emojifyText from '../utils/emojify-text';
import enhanceContent from '../utils/enhance-content';
import handleAccountLinks from '../utils/handle-account-links';
import handleContentLinks from '../utils/handle-content-links';
import shortenNumber from '../utils/shorten-number';
import states from '../utils/states';
import store from '../utils/store';
@ -186,7 +186,7 @@ function Account({ account, onClose }) {
)}
<div
class="note"
onClick={handleAccountLinks()}
onClick={handleContentLinks()}
dangerouslySetInnerHTML={{
__html: enhanceContent(note, { emojis }),
}}

Wyświetl plik

@ -20,7 +20,7 @@ import Loader from '../components/loader';
import Modal from '../components/modal';
import NameText from '../components/name-text';
import enhanceContent from '../utils/enhance-content';
import handleAccountLinks from '../utils/handle-account-links';
import handleContentLinks from '../utils/handle-content-links';
import htmlContentLength from '../utils/html-content-length';
import shortenNumber from '../utils/shorten-number';
import states, { saveStatus } from '../utils/states';
@ -346,7 +346,7 @@ function Status({
lang={language}
ref={contentRef}
data-read-more={readMoreText}
onClick={handleAccountLinks({ mentions })}
onClick={handleContentLinks({ mentions })}
dangerouslySetInnerHTML={{
__html: enhanceContent(content, {
emojis,

Wyświetl plik

@ -91,8 +91,7 @@ function Timeline({
<Icon icon="home" size="l" />
</Link>
</div>
{uiState !== 'loading' &&
(titleComponent ? titleComponent : <h1>{title}</h1>)}
{title && (titleComponent ? titleComponent : <h1>{title}</h1>)}
<div class="header-side">
<Loader hidden={uiState !== 'loading'} />
</div>

Wyświetl plik

@ -1,6 +1,6 @@
import states from './states';
function handleAccountLinks(opts) {
function handleContentLinks(opts) {
const { mentions = [] } = opts || {};
return (e) => {
let { target } = e;
@ -33,8 +33,16 @@ function handleAccountLinks(opts) {
const href = target.getAttribute('href');
states.showAccount = href;
}
} else if (
target.tagName.toLowerCase() === 'a' &&
target.classList.contains('hashtag')
) {
e.preventDefault();
e.stopPropagation();
const tag = target.innerText.replace(/^#/, '').trim();
location.hash = `#/t/${tag}`;
}
};
}
export default handleAccountLinks;
export default handleContentLinks;