mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-18 19:23:40 +00:00
Add support for videos
This commit is contained in:
parent
51781a4743
commit
a0cef2b13e
@ -29,6 +29,7 @@ module.exports = {
|
|||||||
"no-unused-vars": ["error", {args: "none"}],
|
"no-unused-vars": ["error", {args: "none"}],
|
||||||
"no-async-promise-executor": "off",
|
"no-async-promise-executor": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "off",
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"no-useless-escape": "off",
|
||||||
},
|
},
|
||||||
ignorePatterns: ["*.svg"],
|
ignorePatterns: ["*.svg"],
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ export const mergeParents = (notes: Array<DisplayEvent>) => {
|
|||||||
const notesById = createMap('id', notes)
|
const notesById = createMap('id', notes)
|
||||||
const childIds = []
|
const childIds = []
|
||||||
|
|
||||||
for (const note of notes) {
|
for (const note of Object.values(notesById)) {
|
||||||
const parentId = findReplyId(note)
|
const parentId = findReplyId(note)
|
||||||
|
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
|
@ -9,36 +9,45 @@
|
|||||||
let preview
|
let preview
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
try {
|
if (url.match('\.(jpg|jpeg|png|gif)')) {
|
||||||
const res = await fetch(endpoint, {
|
preview = {image: url}
|
||||||
method: 'POST',
|
} else if (url.match('\.(mov|mp4)')) {
|
||||||
body: JSON.stringify({url}),
|
preview = {video: url}
|
||||||
headers: {
|
} else {
|
||||||
'Content-Type': 'application/json',
|
try {
|
||||||
},
|
const res = await fetch(endpoint, {
|
||||||
})
|
method: 'POST',
|
||||||
|
body: JSON.stringify({url}),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const json = await res.json()
|
const json = await res.json()
|
||||||
|
|
||||||
if (json.title || json.image) {
|
if (json.title || json.image) {
|
||||||
preview = json
|
preview = json
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if preview}
|
{#if preview}
|
||||||
<div in:slide class="max-w-sm">
|
<div in:slide>
|
||||||
<Anchor
|
<Anchor
|
||||||
external
|
external
|
||||||
href={url}
|
href={url}
|
||||||
class="rounded border border-solid border-medium flex flex-col bg-white overflow-hidden">
|
class="rounded border border-solid border-medium flex flex-col bg-medium overflow-hidden">
|
||||||
{#if preview.image}
|
{#if preview.image}
|
||||||
<img alt="Link preview" src={preview.image} />
|
<img alt="Link preview" src={preview.image} class="object-center max-h-96 object-contain" />
|
||||||
<div class="h-px bg-medium" />
|
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if preview.video}
|
||||||
|
<video controls src={preview.video} class="object-center max-h-96 object-contain" />
|
||||||
|
{/if}
|
||||||
|
<div class="h-px bg-medium" />
|
||||||
{#if preview.title}
|
{#if preview.title}
|
||||||
<div class="px-4 py-2 text-black flex flex-col bg-white">
|
<div class="px-4 py-2 text-black flex flex-col bg-white">
|
||||||
<strong class="whitespace-nowrap text-ellipsis overflow-hidden">{preview.title}</strong>
|
<strong class="whitespace-nowrap text-ellipsis overflow-hidden">{preview.title}</strong>
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
$: following = find(t => t[1] === pubkey, $user?.petnames || [])
|
$: following = find(t => t[1] === pubkey, $user?.petnames || [])
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
console.log('Person', npub, person)
|
||||||
|
|
||||||
// Add all the relays we know the person uses
|
// Add all the relays we know the person uses
|
||||||
relays = relays.concat(getPubkeyRelays(pubkey))
|
relays = relays.concat(getPubkeyRelays(pubkey))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user