This commit is contained in:
parent
4c1b189ca0
commit
cff0c2880a
4 changed files with 44 additions and 111 deletions
|
@ -8,6 +8,7 @@ import {
|
|||
} from "solid-js";
|
||||
import { resolveCustomEmoji } from "../../masto/toot.js";
|
||||
import { makeAcctText, useDefaultSession } from "../../masto/clients";
|
||||
import "./TootContent.css";
|
||||
|
||||
function preventDefault(event: Event) {
|
||||
event.preventDefault();
|
||||
|
@ -19,9 +20,14 @@ export type TootContentProps = {
|
|||
mentions: mastodon.v1.StatusMention[];
|
||||
} & JSX.HTMLAttributes<HTMLDivElement>;
|
||||
|
||||
const TootContent: Component<TootContentProps> = (props) => {
|
||||
const TootContent: Component<TootContentProps> = (oprops) => {
|
||||
const session = useDefaultSession();
|
||||
const [managed, rest] = splitProps(props, ["source", "emojis", "mentions"]);
|
||||
const [props, rest] = splitProps(oprops, [
|
||||
"source",
|
||||
"emojis",
|
||||
"mentions",
|
||||
"class",
|
||||
]);
|
||||
|
||||
const clientFinder = createMemo(() =>
|
||||
session() ? makeAcctText(session()!) : undefined,
|
||||
|
@ -31,10 +37,10 @@ const TootContent: Component<TootContentProps> = (props) => {
|
|||
<div
|
||||
ref={(ref) => {
|
||||
createRenderEffect(() => {
|
||||
ref.innerHTML = managed.source
|
||||
? managed.emojis
|
||||
? resolveCustomEmoji(managed.source, managed.emojis)
|
||||
: managed.source
|
||||
ref.innerHTML = props.source
|
||||
? props.emojis
|
||||
? resolveCustomEmoji(props.source, props.emojis)
|
||||
: props.source
|
||||
: "";
|
||||
});
|
||||
|
||||
|
@ -53,9 +59,10 @@ const TootContent: Component<TootContentProps> = (props) => {
|
|||
}
|
||||
});
|
||||
}}
|
||||
class={`TootContent ${props.class || ""}`}
|
||||
{...rest}
|
||||
></div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TootContent;
|
||||
export default TootContent;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue