This commit is contained in:
parent
f56b92fff0
commit
5d6eb7282a
9 changed files with 48 additions and 110 deletions
|
@ -20,17 +20,6 @@ export function resolveCustomEmoji(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function appliedCustomEmoji(
|
|
||||||
target: { innerHTML: string },
|
|
||||||
content: string,
|
|
||||||
emojis?: mastodon.v1.CustomEmoji[],
|
|
||||||
) {
|
|
||||||
createRenderEffect(() => {
|
|
||||||
const result = emojis ? resolveCustomEmoji(content, emojis) : content;
|
|
||||||
target.innerHTML = result;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function hasCustomEmoji(s: string) {
|
export function hasCustomEmoji(s: string) {
|
||||||
return CUSTOM_EMOJI_REGEX.test(s);
|
return CUSTOM_EMOJI_REGEX.test(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,10 +171,6 @@ const Profile: Component = () => {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
const useSessionDisplayName = (e: HTMLElement) => {
|
|
||||||
createRenderEffect(() => (e.innerHTML = sessionDisplayName()));
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleSubscribeHome = async (event: Event) => {
|
const toggleSubscribeHome = async (event: Event) => {
|
||||||
const client = session().client;
|
const client = session().client;
|
||||||
if (!session().account) return;
|
if (!session().account) return;
|
||||||
|
@ -218,9 +214,7 @@ const Profile: Component = () => {
|
||||||
style={{
|
style={{
|
||||||
visibility: scrolledPastBanner() ? undefined : "hidden",
|
visibility: scrolledPastBanner() ? undefined : "hidden",
|
||||||
}}
|
}}
|
||||||
ref={(e: HTMLElement) =>
|
innerHTML={displayName()}
|
||||||
createRenderEffect(() => (e.innerHTML = displayName()))
|
|
||||||
}
|
|
||||||
></Title>
|
></Title>
|
||||||
|
|
||||||
<IconButton
|
<IconButton
|
||||||
|
@ -253,7 +247,7 @@ const Profile: Component = () => {
|
||||||
<Avatar src={session().account?.inf?.avatar} />
|
<Avatar src={session().account?.inf?.avatar} />
|
||||||
</ListItemAvatar>
|
</ListItemAvatar>
|
||||||
<ListItemText secondary={"Default account"}>
|
<ListItemText secondary={"Default account"}>
|
||||||
<span ref={useSessionDisplayName}></span>
|
<span innerHTML={sessionDisplayName()}></span>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
{/* <ArrowRight /> // for future */}
|
{/* <ArrowRight /> // for future */}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
@ -384,7 +378,7 @@ const Profile: Component = () => {
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<span ref={useSessionDisplayName}></span>
|
<span innerHTML={sessionDisplayName()}></span>
|
||||||
<span>'s Home</span>
|
<span>'s Home</span>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
|
|
||||||
|
@ -419,9 +413,7 @@ const Profile: Component = () => {
|
||||||
</Show>
|
</Show>
|
||||||
<Body2
|
<Body2
|
||||||
component="span"
|
component="span"
|
||||||
ref={(e: HTMLElement) =>
|
innerHTML={displayName()}
|
||||||
createRenderEffect(() => (e.innerHTML = displayName()))
|
|
||||||
}
|
|
||||||
aria-label="Display name"
|
aria-label="Display name"
|
||||||
></Body2>
|
></Body2>
|
||||||
</div>
|
</div>
|
||||||
|
@ -464,9 +456,7 @@ const Profile: Component = () => {
|
||||||
<section
|
<section
|
||||||
class="description"
|
class="description"
|
||||||
aria-label={`${profile()?.displayName || "the user"}'s description`}
|
aria-label={`${profile()?.displayName || "the user"}'s description`}
|
||||||
ref={(e) =>
|
innerHTML={description() || ""}
|
||||||
createRenderEffect(() => (e.innerHTML = description() || ""))
|
|
||||||
}
|
|
||||||
></section>
|
></section>
|
||||||
|
|
||||||
<table
|
<table
|
||||||
|
@ -484,11 +474,7 @@ const Profile: Component = () => {
|
||||||
<Verified />
|
<Verified />
|
||||||
</Show>
|
</Show>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td innerHTML={item.value}></td>
|
||||||
ref={(e) => {
|
|
||||||
createRenderEffect(() => (e.innerHTML = item.value));
|
|
||||||
}}
|
|
||||||
></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -66,9 +66,7 @@ export function findRootToot(element: HTMLElement) {
|
||||||
current = current.parentElement;
|
current = current.parentElement;
|
||||||
}
|
}
|
||||||
if (!current) {
|
if (!current) {
|
||||||
throw Error(
|
throw Error(`the element must be placed under a element with .RegularToot`);
|
||||||
`the element must be placed under a element with .RegularToot`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
@ -145,8 +143,8 @@ const RegularToot: Component<RegularTootProps> = (oprops) => {
|
||||||
<>
|
<>
|
||||||
<article
|
<article
|
||||||
classList={{
|
classList={{
|
||||||
"RegularToot": true,
|
RegularToot: true,
|
||||||
"expanded": props.evaluated,
|
expanded: props.evaluated,
|
||||||
"thread-top": props.thread === "top",
|
"thread-top": props.thread === "top",
|
||||||
"thread-mid": props.thread === "middle",
|
"thread-mid": props.thread === "middle",
|
||||||
"thread-btm": props.thread === "bottom",
|
"thread-btm": props.thread === "bottom",
|
||||||
|
@ -160,14 +158,10 @@ const RegularToot: Component<RegularTootProps> = (oprops) => {
|
||||||
<div class="retoot-grp">
|
<div class="retoot-grp">
|
||||||
<BoostIcon />
|
<BoostIcon />
|
||||||
<Body2
|
<Body2
|
||||||
ref={(e: { innerHTML: string }) => {
|
innerHTML={resolveCustomEmoji(
|
||||||
createRenderEffect(() => {
|
|
||||||
e.innerHTML = resolveCustomEmoji(
|
|
||||||
status().account.displayName,
|
status().account.displayName,
|
||||||
toot().emojis,
|
toot().emojis,
|
||||||
);
|
)}
|
||||||
});
|
|
||||||
}}
|
|
||||||
></Body2>
|
></Body2>
|
||||||
<span>boosts</span>
|
<span>boosts</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -261,13 +261,7 @@ const TootBottomSheet: Component = (props) => {
|
||||||
>
|
>
|
||||||
<BackButton color="inherit" />
|
<BackButton color="inherit" />
|
||||||
<Title component="div" class="name" use:solid-styled>
|
<Title component="div" class="name" use:solid-styled>
|
||||||
<span
|
<span innerHTML={tootDisplayName() ?? "Someone"}></span>
|
||||||
ref={(e: HTMLElement) =>
|
|
||||||
createRenderEffect(
|
|
||||||
() => (e.innerHTML = tootDisplayName() ?? "Someone"),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
></span>
|
|
||||||
<span>'s toot</span>
|
<span>'s toot</span>
|
||||||
</Title>
|
</Title>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
|
|
|
@ -349,15 +349,10 @@ const TootComposer: Component<{
|
||||||
</ListItemAvatar>
|
</ListItemAvatar>
|
||||||
<ListItemText secondary={"Default account"}>
|
<ListItemText secondary={"Default account"}>
|
||||||
<span
|
<span
|
||||||
ref={(e) => {
|
innerHTML={resolveCustomEmoji(
|
||||||
createRenderEffect(() => {
|
session()?.account.inf?.displayName || "",
|
||||||
const inf = session()?.account.inf;
|
session()?.account.inf?.emojis ?? [],
|
||||||
return (e.innerHTML = resolveCustomEmoji(
|
)}
|
||||||
inf?.displayName || "",
|
|
||||||
inf?.emojis ?? [],
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
></span>
|
></span>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
|
@ -31,14 +31,10 @@ function TootAuthorGroup(
|
||||||
</Show>
|
</Show>
|
||||||
<Body2
|
<Body2
|
||||||
component="span"
|
component="span"
|
||||||
ref={(e: { innerHTML: string }) => {
|
innerHTML={resolveCustomEmoji(
|
||||||
createRenderEffect(() => {
|
|
||||||
e.innerHTML = resolveCustomEmoji(
|
|
||||||
toot().account.displayName,
|
toot().account.displayName,
|
||||||
toot().account.emojis,
|
toot().account.emojis,
|
||||||
);
|
)}
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<time datetime={toot().createdAt}>
|
<time datetime={toot().createdAt}>
|
||||||
|
|
|
@ -81,15 +81,13 @@ const TootContent: Component<TootContentProps> = (oprops) => {
|
||||||
<Show when={props.sensitive}>
|
<Show when={props.sensitive}>
|
||||||
<div>
|
<div>
|
||||||
<span
|
<span
|
||||||
ref={(ref) => {
|
innerHTML={
|
||||||
createRenderEffect(() => {
|
props.spoilerText
|
||||||
ref.innerHTML = props.spoilerText
|
|
||||||
? props.emojis
|
? props.emojis
|
||||||
? resolveCustomEmoji(props.spoilerText, props.emojis)
|
? resolveCustomEmoji(props.spoilerText, props.emojis)
|
||||||
: props.spoilerText
|
: props.spoilerText
|
||||||
: "";
|
: ""
|
||||||
});
|
}
|
||||||
}}
|
|
||||||
></span>
|
></span>
|
||||||
<Button onClick={props.onToggleReveal}>{t("cw")}</Button>
|
<Button onClick={props.onToggleReveal}>{t("cw")}</Button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -97,14 +95,12 @@ const TootContent: Component<TootContentProps> = (oprops) => {
|
||||||
<Show when={shouldRevealContent()}>
|
<Show when={shouldRevealContent()}>
|
||||||
<div
|
<div
|
||||||
class="content"
|
class="content"
|
||||||
ref={(ref) =>
|
innerHTML={
|
||||||
createRenderEffect(() => {
|
props.source
|
||||||
ref.innerHTML = props.source
|
|
||||||
? props.emojis
|
? props.emojis
|
||||||
? resolveCustomEmoji(props.source, props.emojis)
|
? resolveCustomEmoji(props.source, props.emojis)
|
||||||
: props.source
|
: props.source
|
||||||
: "";
|
: ""
|
||||||
})
|
|
||||||
}
|
}
|
||||||
></div>
|
></div>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
|
@ -20,10 +20,7 @@ import {
|
||||||
ListItemText,
|
ListItemText,
|
||||||
Radio,
|
Radio,
|
||||||
} from "@suid/material";
|
} from "@suid/material";
|
||||||
import {
|
import { formatDistance, isBefore } from "date-fns";
|
||||||
formatDistance,
|
|
||||||
isBefore,
|
|
||||||
} from "date-fns";
|
|
||||||
import { useTimeSource } from "~platform/timesrc";
|
import { useTimeSource } from "~platform/timesrc";
|
||||||
import { useDateFnLocale } from "~platform/i18n";
|
import { useDateFnLocale } from "~platform/i18n";
|
||||||
import TootPollDialog from "./TootPollDialog";
|
import TootPollDialog from "./TootPollDialog";
|
||||||
|
@ -31,13 +28,13 @@ import { ANIM_CURVE_STD } from "~material/theme";
|
||||||
import { useTootEnv } from "../RegularToot";
|
import { useTootEnv } from "../RegularToot";
|
||||||
|
|
||||||
type TootPollProps = {
|
type TootPollProps = {
|
||||||
value: mastodon.v1.Poll
|
value: mastodon.v1.Poll;
|
||||||
status: mastodon.v1.Status
|
status: mastodon.v1.Status;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TootPoll: Component<TootPollProps> = (props) => {
|
const TootPoll: Component<TootPollProps> = (props) => {
|
||||||
let list: HTMLUListElement;
|
let list: HTMLUListElement;
|
||||||
const {vote}= useTootEnv()
|
const { vote } = useTootEnv();
|
||||||
|
|
||||||
const now = useTimeSource();
|
const now = useTimeSource();
|
||||||
const dateFnLocale = useDateFnLocale();
|
const dateFnLocale = useDateFnLocale();
|
||||||
|
@ -46,7 +43,7 @@ const TootPoll: Component<TootPollProps> = (props) => {
|
||||||
|
|
||||||
const [initialVote, setInitialVote] = createSignal(0);
|
const [initialVote, setInitialVote] = createSignal(0);
|
||||||
|
|
||||||
const poll = () => props.value
|
const poll = () => props.value;
|
||||||
|
|
||||||
const isShowResult = () => {
|
const isShowResult = () => {
|
||||||
const n = mustShowResult();
|
const n = mustShowResult();
|
||||||
|
@ -118,14 +115,10 @@ const TootPoll: Component<TootPollProps> = (props) => {
|
||||||
>
|
>
|
||||||
<ListItemText>
|
<ListItemText>
|
||||||
<span
|
<span
|
||||||
ref={(e) =>
|
innerHTML={resolveCustomEmoji(
|
||||||
createRenderEffect(() => {
|
|
||||||
e.innerHTML = resolveCustomEmoji(
|
|
||||||
option().title,
|
option().title,
|
||||||
option().emojis,
|
option().emojis,
|
||||||
);
|
)}
|
||||||
})
|
|
||||||
}
|
|
||||||
></span>
|
></span>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
|
|
||||||
|
|
|
@ -96,15 +96,10 @@ const TootPollDialog: Component<TootPollDialogPoll> = (props) => {
|
||||||
>
|
>
|
||||||
<ListItemText>
|
<ListItemText>
|
||||||
<span
|
<span
|
||||||
ref={(e) =>
|
innerHTML={resolveCustomEmoji(
|
||||||
createRenderEffect(
|
|
||||||
() =>
|
|
||||||
(e.innerHTML = resolveCustomEmoji(
|
|
||||||
option().title,
|
option().title,
|
||||||
option().emojis,
|
option().emojis,
|
||||||
)),
|
)}
|
||||||
)
|
|
||||||
}
|
|
||||||
></span>
|
></span>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue