MediaAttachmentGrid: fix element type misuse
This commit is contained in:
parent
0e33be020d
commit
8b69968b8f
1 changed files with 15 additions and 17 deletions
|
@ -3,6 +3,8 @@ import {
|
||||||
type Component,
|
type Component,
|
||||||
For,
|
For,
|
||||||
Index,
|
Index,
|
||||||
|
Match,
|
||||||
|
Switch,
|
||||||
createMemo,
|
createMemo,
|
||||||
createRenderEffect,
|
createRenderEffect,
|
||||||
createSignal,
|
createSignal,
|
||||||
|
@ -147,9 +149,10 @@ const MediaAttachmentGrid: Component<{
|
||||||
>
|
>
|
||||||
<Index each={props.attachments}>
|
<Index each={props.attachments}>
|
||||||
{(item, index) => {
|
{(item, index) => {
|
||||||
switch (item().type) {
|
const itemType = () => item().type;
|
||||||
case "image":
|
return (
|
||||||
return (
|
<Switch>
|
||||||
|
<Match when={itemType() === "image"}>
|
||||||
<img
|
<img
|
||||||
data-sort={index}
|
data-sort={index}
|
||||||
data-media-type={item().type}
|
data-media-type={item().type}
|
||||||
|
@ -161,9 +164,8 @@ const MediaAttachmentGrid: Component<{
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
style={itemStyle(item())}
|
style={itemStyle(item())}
|
||||||
></img>
|
></img>
|
||||||
);
|
</Match>
|
||||||
case "video":
|
<Match when={itemType() === "video"}>
|
||||||
return (
|
|
||||||
<video
|
<video
|
||||||
data-sort={index}
|
data-sort={index}
|
||||||
data-media-type={item().type}
|
data-media-type={item().type}
|
||||||
|
@ -176,9 +178,8 @@ const MediaAttachmentGrid: Component<{
|
||||||
height={item().meta?.small?.height}
|
height={item().meta?.small?.height}
|
||||||
style={itemStyle(item())}
|
style={itemStyle(item())}
|
||||||
/>
|
/>
|
||||||
);
|
</Match>
|
||||||
case "gifv":
|
<Match when={itemType() === "gifv"}>
|
||||||
return (
|
|
||||||
<video
|
<video
|
||||||
data-sort={index}
|
data-sort={index}
|
||||||
data-media-type={item().type}
|
data-media-type={item().type}
|
||||||
|
@ -192,20 +193,17 @@ const MediaAttachmentGrid: Component<{
|
||||||
height={item().meta?.small?.height}
|
height={item().meta?.small?.height}
|
||||||
style={itemStyle(item())}
|
style={itemStyle(item())}
|
||||||
/>
|
/>
|
||||||
);
|
</Match>
|
||||||
|
<Match when={itemType() === "audio"}>
|
||||||
case "audio":
|
|
||||||
return (
|
|
||||||
<audio
|
<audio
|
||||||
data-sort={index}
|
data-sort={index}
|
||||||
data-media-type={item().type}
|
data-media-type={item().type}
|
||||||
src={item().url || undefined}
|
src={item().url || undefined}
|
||||||
controls
|
controls
|
||||||
></audio>
|
></audio>
|
||||||
);
|
</Match>
|
||||||
case "unknown":
|
</Switch>
|
||||||
return <div></div>;
|
);
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
</Index>
|
</Index>
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in a new issue