Quietly handle hashtag links
No follow/unfollow yet.
This commit is contained in:
parent
9a261470df
commit
bbb3017b2d
4 changed files with 15 additions and 8 deletions
|
@ -4,7 +4,7 @@ import { useEffect, useState } from 'preact/hooks';
|
||||||
|
|
||||||
import emojifyText from '../utils/emojify-text';
|
import emojifyText from '../utils/emojify-text';
|
||||||
import enhanceContent from '../utils/enhance-content';
|
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 shortenNumber from '../utils/shorten-number';
|
||||||
import states from '../utils/states';
|
import states from '../utils/states';
|
||||||
import store from '../utils/store';
|
import store from '../utils/store';
|
||||||
|
@ -186,7 +186,7 @@ function Account({ account, onClose }) {
|
||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
class="note"
|
class="note"
|
||||||
onClick={handleAccountLinks()}
|
onClick={handleContentLinks()}
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: enhanceContent(note, { emojis }),
|
__html: enhanceContent(note, { emojis }),
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import Loader from '../components/loader';
|
||||||
import Modal from '../components/modal';
|
import Modal from '../components/modal';
|
||||||
import NameText from '../components/name-text';
|
import NameText from '../components/name-text';
|
||||||
import enhanceContent from '../utils/enhance-content';
|
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 htmlContentLength from '../utils/html-content-length';
|
||||||
import shortenNumber from '../utils/shorten-number';
|
import shortenNumber from '../utils/shorten-number';
|
||||||
import states, { saveStatus } from '../utils/states';
|
import states, { saveStatus } from '../utils/states';
|
||||||
|
@ -346,7 +346,7 @@ function Status({
|
||||||
lang={language}
|
lang={language}
|
||||||
ref={contentRef}
|
ref={contentRef}
|
||||||
data-read-more={readMoreText}
|
data-read-more={readMoreText}
|
||||||
onClick={handleAccountLinks({ mentions })}
|
onClick={handleContentLinks({ mentions })}
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: enhanceContent(content, {
|
__html: enhanceContent(content, {
|
||||||
emojis,
|
emojis,
|
||||||
|
|
|
@ -91,8 +91,7 @@ function Timeline({
|
||||||
<Icon icon="home" size="l" />
|
<Icon icon="home" size="l" />
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
{uiState !== 'loading' &&
|
{title && (titleComponent ? titleComponent : <h1>{title}</h1>)}
|
||||||
(titleComponent ? titleComponent : <h1>{title}</h1>)}
|
|
||||||
<div class="header-side">
|
<div class="header-side">
|
||||||
<Loader hidden={uiState !== 'loading'} />
|
<Loader hidden={uiState !== 'loading'} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import states from './states';
|
import states from './states';
|
||||||
|
|
||||||
function handleAccountLinks(opts) {
|
function handleContentLinks(opts) {
|
||||||
const { mentions = [] } = opts || {};
|
const { mentions = [] } = opts || {};
|
||||||
return (e) => {
|
return (e) => {
|
||||||
let { target } = e;
|
let { target } = e;
|
||||||
|
@ -33,8 +33,16 @@ function handleAccountLinks(opts) {
|
||||||
const href = target.getAttribute('href');
|
const href = target.getAttribute('href');
|
||||||
states.showAccount = 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;
|
Loading…
Add table
Reference in a new issue