mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-24 16:58:47 +01:00
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 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 }),
|
||||
}}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
Loading…
Reference in a new issue