This commit is contained in:
Shusui MOYATANI
2023-05-16 12:48:42 +09:00
parent b343e21bfb
commit 12e38f85d9
4 changed files with 30 additions and 22 deletions

View File

@@ -1,5 +1,7 @@
import { Show } from 'solid-js';
import { Kind } from 'nostr-tools';
// eslint-disable-next-line import/no-cycle
import EventDisplayById from '@/components/event/EventDisplayById';
import EventLink from '@/components/EventLink';
@@ -20,6 +22,7 @@ const MentionedEventDisplay = (props: MentionedEventDisplayProps) => {
eventId={props.mentionedEvent.eventId}
embedding={false}
actions={false}
ensureKinds={[Kind.Text]}
/>
</div>
</Show>

View File

@@ -107,9 +107,9 @@ const TextNoteContentDisplay = (props: TextNoteContentDisplayProps) => {
if (emojiUrl == null) return <span>{item.content}</span>;
return (
<img
class="inline-block h-7 max-w-[64px] align-middle"
class="inline-block h-8 max-w-[128px] align-middle"
src={emojiUrl}
alt={item.shortcode}
alt={item.content}
/>
);
}

View File

@@ -1,4 +1,4 @@
import { For, Switch, Match, type Component } from 'solid-js';
import { For, Switch, Match, type Component, Show } from 'solid-js';
import { Kind, type Event as NostrEvent } from 'nostr-tools';
@@ -6,33 +6,38 @@ import ColumnItem from '@/components/ColumnItem';
import Reaction from '@/components/event/Reaction';
import Repost from '@/components/event/Repost';
import TextNote from '@/components/event/TextNote';
import useConfig from '@/core/useConfig';
export type NotificationProps = {
events: NostrEvent[];
};
const Notification: Component<NotificationProps> = (props) => {
const { shouldMuteEvent } = useConfig();
return (
<For each={props.events}>
{(event) => (
<Switch fallback={<div>unknown event</div>}>
<Match when={event.kind === Kind.Text}>
<ColumnItem>
<TextNote event={event} />
</ColumnItem>
</Match>
<Match when={event.kind === Kind.Reaction}>
<ColumnItem>
<Reaction event={event} />
</ColumnItem>
</Match>
{/* TODO ちゃんとnotification用のコンポーネント使う */}
<Match when={(event.kind as number) === 6}>
<ColumnItem>
<Repost event={event} />
</ColumnItem>
</Match>
</Switch>
<Show when={!shouldMuteEvent(event)}>
<Switch fallback={<div>unknown event</div>}>
<Match when={event.kind === Kind.Text}>
<ColumnItem>
<TextNote event={event} />
</ColumnItem>
</Match>
<Match when={event.kind === Kind.Reaction}>
<ColumnItem>
<Reaction event={event} />
</ColumnItem>
</Match>
{/* TODO ちゃんとnotification用のコンポーネント使う */}
<Match when={(event.kind as number) === 6}>
<ColumnItem>
<Repost event={event} />
</ColumnItem>
</Match>
</Switch>
</Show>
)}
</For>
);

View File

@@ -1,7 +1,7 @@
export const isImageUrl = (urlString: string): boolean => {
try {
const url = new URL(urlString);
return /\.(jpeg|jpg|png|gif|webp|apng)$/i.test(url.pathname);
return /\.(jpeg|jpg|png|gif|webp|apng|svg)$/i.test(url.pathname);
} catch {
return false;
}