mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 19:07:06 +00:00
Handle deleted threads
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -18,10 +18,9 @@ vite.config.js.timestamp-*
|
|||||||
vite.config.ts.timestamp-*
|
vite.config.ts.timestamp-*
|
||||||
|
|
||||||
# Generated assets
|
# Generated assets
|
||||||
static/favicons
|
|
||||||
static/apple-touch-icon-180x180.png
|
|
||||||
static/favicon.ico
|
static/favicon.ico
|
||||||
static/maskable-icon-512x512.png
|
|
||||||
static/pwa-64x64.png
|
static/pwa-64x64.png
|
||||||
static/pwa-192x192.png
|
static/pwa-192x192.png
|
||||||
static/pwa-512x512.png
|
static/pwa-512x512.png
|
||||||
|
static/apple-touch-icon-180x180.png
|
||||||
|
static/maskable-icon-512x512.png
|
||||||
|
|||||||
12
src/app.html
12
src/app.html
@@ -15,12 +15,12 @@
|
|||||||
<meta name="twitter:description" content="{DESCRIPTION}" />
|
<meta name="twitter:description" content="{DESCRIPTION}" />
|
||||||
<meta name="twitter:image" content="/maskable-icon-512x512.png" />
|
<meta name="twitter:image" content="/maskable-icon-512x512.png" />
|
||||||
<link rel="icon" href="/favicon.ico" sizes="48x48" />
|
<link rel="icon" href="/favicon.ico" sizes="48x48" />
|
||||||
<link rel="icon" href="/pwa-64x64.ico" sizes="any" type="image/png" />
|
<link rel="icon" href="/pwa-64x64.png" sizes="any" type="image/png" />
|
||||||
<link rel="icon" href="/pwa-192x192.ico" sizes="any" type="image/png" />
|
<link rel="icon" href="/pwa-192x192.png" sizes="any" type="image/png" />
|
||||||
<link rel="icon" href="/pwa-512x512.ico" sizes="any" type="image/png" />
|
<link rel="icon" href="/pwa-512x512.png" sizes="any" type="image/png" />
|
||||||
<link rel="icon" href="/pwa-64x64.ico" sizes="64x64" type="image/png" />
|
<link rel="icon" href="/pwa-64x64.png" sizes="64x64" type="image/png" />
|
||||||
<link rel="icon" href="/pwa-192x192.ico" sizes="192x192" type="image/png" />
|
<link rel="icon" href="/pwa-192x192.png" sizes="192x192" type="image/png" />
|
||||||
<link rel="icon" href="/pwa-512x512.ico" sizes="512x512" type="image/png" />
|
<link rel="icon" href="/pwa-512x512.png" sizes="512x512" type="image/png" />
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon-180x180.png" />
|
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon-180x180.png" />
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
loading = false
|
loading = false
|
||||||
}, 3000)
|
}, 5000)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="relative flex h-full w-full flex-col">
|
<div class="relative flex h-full w-full flex-col">
|
||||||
|
|||||||
@@ -11,28 +11,28 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="column menu gap-2">
|
<div class="column menu gap-2">
|
||||||
<Link href="/settings/profile">
|
<Link replaceState href="/settings/profile">
|
||||||
<CardButton>
|
<CardButton>
|
||||||
<div slot="icon"><Icon icon="user-rounded" size={7} /></div>
|
<div slot="icon"><Icon icon="user-rounded" size={7} /></div>
|
||||||
<div slot="title">Profile</div>
|
<div slot="title">Profile</div>
|
||||||
<div slot="info">Customize your user profile</div>
|
<div slot="info">Customize your user profile</div>
|
||||||
</CardButton>
|
</CardButton>
|
||||||
</Link>
|
</Link>
|
||||||
<Link href="/settings/relays">
|
<Link replaceState href="/settings/relays">
|
||||||
<CardButton>
|
<CardButton>
|
||||||
<div slot="icon"><Icon icon="server" size={7} /></div>
|
<div slot="icon"><Icon icon="server" size={7} /></div>
|
||||||
<div slot="title">Relays</div>
|
<div slot="title">Relays</div>
|
||||||
<div slot="info">Control how {PLATFORM_NAME} talks to the network</div>
|
<div slot="info">Control how {PLATFORM_NAME} talks to the network</div>
|
||||||
</CardButton>
|
</CardButton>
|
||||||
</Link>
|
</Link>
|
||||||
<Link href="/settings">
|
<Link replaceState href="/settings">
|
||||||
<CardButton>
|
<CardButton>
|
||||||
<div slot="icon"><Icon icon="settings" size={7} /></div>
|
<div slot="icon"><Icon icon="settings" size={7} /></div>
|
||||||
<div slot="title">Settings</div>
|
<div slot="title">Settings</div>
|
||||||
<div slot="info">Get into the details about how {PLATFORM_NAME} works</div>
|
<div slot="info">Get into the details about how {PLATFORM_NAME} works</div>
|
||||||
</CardButton>
|
</CardButton>
|
||||||
</Link>
|
</Link>
|
||||||
<Link href="/settings/about">
|
<Link replaceState href="/settings/about">
|
||||||
<CardButton>
|
<CardButton>
|
||||||
<div slot="icon"><Icon icon="code-2" size={7} /></div>
|
<div slot="icon"><Icon icon="code-2" size={7} /></div>
|
||||||
<div slot="title">About</div>
|
<div slot="title">About</div>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<div class="column menu gap-2">
|
<div class="column menu gap-2">
|
||||||
{#if PLATFORM_RELAY}
|
{#if PLATFORM_RELAY}
|
||||||
<Link href={makeSpacePath(PLATFORM_RELAY)}>
|
<Link replaceState href={makeSpacePath(PLATFORM_RELAY)}>
|
||||||
<CardButton>
|
<CardButton>
|
||||||
<div slot="icon"><SpaceAvatar url={PLATFORM_RELAY} /></div>
|
<div slot="icon"><SpaceAvatar url={PLATFORM_RELAY} /></div>
|
||||||
<div slot="title"><RelayName url={PLATFORM_RELAY} /></div>
|
<div slot="title"><RelayName url={PLATFORM_RELAY} /></div>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<Divider />
|
<Divider />
|
||||||
{:else if getMembershipUrls($userMembership).length > 0}
|
{:else if getMembershipUrls($userMembership).length > 0}
|
||||||
{#each getMembershipUrls($userMembership) as url (url)}
|
{#each getMembershipUrls($userMembership) as url (url)}
|
||||||
<Link href={makeSpacePath(url)}>
|
<Link replaceState href={makeSpacePath(url)}>
|
||||||
<CardButton>
|
<CardButton>
|
||||||
<div slot="icon"><SpaceAvatar {url} /></div>
|
<div slot="icon"><SpaceAvatar {url} /></div>
|
||||||
<div slot="title"><RelayName {url} /></div>
|
<div slot="title"><RelayName {url} /></div>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import {type Instance} from "tippy.js"
|
import {type Instance} from "tippy.js"
|
||||||
import type {NativeEmoji} from "emoji-picker-element/shared"
|
import type {NativeEmoji} from "emoji-picker-element/shared"
|
||||||
import {max} from "@welshman/lib"
|
import {max} from "@welshman/lib"
|
||||||
import {deriveEvents} from "@welshman/store"
|
import {deriveEvents, deriveIsDeleted} from "@welshman/store"
|
||||||
import type {TrustedEvent} from "@welshman/util"
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
import {pubkey, repository, formatTimestampRelative} from "@welshman/app"
|
import {pubkey, repository, formatTimestampRelative} from "@welshman/app"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
@@ -18,6 +18,8 @@
|
|||||||
export let event
|
export let event
|
||||||
export let showActivity = false
|
export let showActivity = false
|
||||||
|
|
||||||
|
const deleted = deriveIsDeleted(repository, event)
|
||||||
|
|
||||||
const replies = deriveEvents(repository, {filters: [{kinds: [REPLY], "#E": [event.id]}]})
|
const replies = deriveEvents(repository, {filters: [{kinds: [REPLY], "#E": [event.id]}]})
|
||||||
|
|
||||||
const showPopover = () => popover.show()
|
const showPopover = () => popover.show()
|
||||||
@@ -47,6 +49,11 @@
|
|||||||
<ReactionSummary {event} {onReactionClick} />
|
<ReactionSummary {event} {onReactionClick} />
|
||||||
</Button>
|
</Button>
|
||||||
<div class="flex flex-grow justify-end gap-2">
|
<div class="flex flex-grow justify-end gap-2">
|
||||||
|
{#if $deleted}
|
||||||
|
<div class="btn btn-error btn-xs rounded-full">
|
||||||
|
Deleted
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{#if showActivity}
|
{#if showActivity}
|
||||||
<div class="flex-inline btn btn-neutral btn-xs gap-1 rounded-full">
|
<div class="flex-inline btn btn-neutral btn-xs gap-1 rounded-full">
|
||||||
<Icon icon="reply" />
|
<Icon icon="reply" />
|
||||||
|
|||||||
@@ -18,10 +18,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onMouseMove = throttle(300, ({clientX, clientY}: any) => {
|
const onMouseMove = throttle(300, ({clientX, clientY}: any) => {
|
||||||
const {x, y, width, height} = popover.popper.getBoundingClientRect()
|
if (popover) {
|
||||||
|
const {x, y, width, height} = popover.popper.getBoundingClientRect()
|
||||||
|
|
||||||
if (!between([x, x + width], clientX) || !between([y - 30, y + height + 30], clientY)) {
|
if (!between([x, x + width], clientX) || !between([y - 30, y + height + 30], clientY)) {
|
||||||
popover.hide()
|
popover.hide()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,13 @@
|
|||||||
|
|
||||||
export let href
|
export let href
|
||||||
export let external = false
|
export let external = false
|
||||||
|
export let replaceState = false
|
||||||
|
|
||||||
const go = (e: Event) => {
|
const go = (e: Event) => {
|
||||||
if (!external) {
|
if (!external) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
goto(href)
|
goto(href, {replaceState})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,20 +1,26 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import {load} from "@welshman/app"
|
import {subscribe} from "@welshman/app"
|
||||||
|
import {DELETE, NOTE} from "@welshman/util"
|
||||||
import Page from "@lib/components/Page.svelte"
|
import Page from "@lib/components/Page.svelte"
|
||||||
import Delay from "@lib/components/Delay.svelte"
|
import Delay from "@lib/components/Delay.svelte"
|
||||||
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
||||||
import MenuSpace from "@app/components/MenuSpace.svelte"
|
import MenuSpace from "@app/components/MenuSpace.svelte"
|
||||||
import {decodeRelay, MEMBERSHIPS} from "@app/state"
|
import {decodeRelay, MEMBERSHIPS, MESSAGE, REPLY} from "@app/state"
|
||||||
|
|
||||||
$: url = decodeRelay($page.params.relay)
|
$: url = decodeRelay($page.params.relay)
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
load({
|
const sub = subscribe({
|
||||||
filters: [{kinds: [MEMBERSHIPS], "#r": [url]}],
|
filters: [
|
||||||
|
{kinds: [DELETE], "#k": [NOTE, REPLY, MESSAGE].map(String)},
|
||||||
|
{kinds: [MEMBERSHIPS], "#r": [url]},
|
||||||
|
],
|
||||||
relays: [url],
|
relays: [url],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return () => sub.close()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -13,15 +13,18 @@
|
|||||||
import MenuSpace from "@app/components/MenuSpace.svelte"
|
import MenuSpace from "@app/components/MenuSpace.svelte"
|
||||||
import ThreadItem from "@app/components/ThreadItem.svelte"
|
import ThreadItem from "@app/components/ThreadItem.svelte"
|
||||||
import ThreadCreate from "@app/components/ThreadCreate.svelte"
|
import ThreadCreate from "@app/components/ThreadCreate.svelte"
|
||||||
import {deriveEventsForUrl, decodeRelay} from "@app/state"
|
import {REPLY, deriveEventsForUrl, decodeRelay} from "@app/state"
|
||||||
import {pushModal, pushDrawer} from "@app/modal"
|
import {pushModal, pushDrawer} from "@app/modal"
|
||||||
|
|
||||||
const url = decodeRelay($page.params.relay)
|
const url = decodeRelay($page.params.relay)
|
||||||
const kinds = [NOTE]
|
const events = deriveEventsForUrl(url, [NOTE])
|
||||||
const feed = makeIntersectionFeed(makeRelayFeed(url), feedFromFilter({kinds}))
|
|
||||||
const events = deriveEventsForUrl(url, kinds)
|
|
||||||
const loader = feedLoader.getLoader(feed, {})
|
|
||||||
const mutedPubkeys = getPubkeyTagValues(getListTags($userMutes))
|
const mutedPubkeys = getPubkeyTagValues(getListTags($userMutes))
|
||||||
|
const feed = makeIntersectionFeed(makeRelayFeed(url), feedFromFilter({kinds: [NOTE, REPLY]}))
|
||||||
|
const loader = feedLoader.getLoader(feed, {
|
||||||
|
onExhausted: () => {
|
||||||
|
loading = false
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const openMenu = () => pushDrawer(MenuSpace, {url})
|
const openMenu = () => pushDrawer(MenuSpace, {url})
|
||||||
|
|
||||||
@@ -32,22 +35,21 @@
|
|||||||
let element: Element
|
let element: Element
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const scroller = createScroller({
|
// Why is element not defined sometimes? SVELTEKIT
|
||||||
element,
|
if (element) {
|
||||||
onScroll: async () => {
|
const scroller = createScroller({
|
||||||
const $loader = await loader
|
element,
|
||||||
|
onScroll: async () => {
|
||||||
|
const $loader = await loader
|
||||||
|
|
||||||
await $loader(5)
|
await $loader(5)
|
||||||
limit += 5
|
limit += 5
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return () => scroller.stop()
|
return () => scroller.stop()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
loading = false
|
|
||||||
}, 3000)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="relative flex h-screen flex-col">
|
<div class="relative flex h-screen flex-col">
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
loading = false
|
loading = false
|
||||||
}, 3000)
|
}, 5000)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="relative flex h-full flex-col">
|
<div class="relative flex h-full flex-col">
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
loading = false
|
loading = false
|
||||||
}, 3000)
|
}, 5000)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="relative flex h-screen flex-col">
|
<div class="relative flex h-screen flex-col">
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {sortBy} from "@welshman/lib"
|
import {onMount} from 'svelte'
|
||||||
|
import {sortBy, sleep} from "@welshman/lib"
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import {repository} from "@welshman/app"
|
import {repository, subscribe} from "@welshman/app"
|
||||||
import type {Thunk} from "@welshman/app"
|
import type {Thunk} from "@welshman/app"
|
||||||
import {deriveEvents} from "@welshman/store"
|
import {deriveEvents} from "@welshman/store"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
|
import Spinner from "@lib/components/Spinner.svelte"
|
||||||
import Button from "@lib/components/Button.svelte"
|
import Button from "@lib/components/Button.svelte"
|
||||||
import Content from "@app/components/Content.svelte"
|
import Content from "@app/components/Content.svelte"
|
||||||
import NoteCard from "@app/components/NoteCard.svelte"
|
import NoteCard from "@app/components/NoteCard.svelte"
|
||||||
@@ -15,7 +17,8 @@
|
|||||||
const {relay, id} = $page.params
|
const {relay, id} = $page.params
|
||||||
const url = decodeRelay(relay)
|
const url = decodeRelay(relay)
|
||||||
const event = deriveEvent(id)
|
const event = deriveEvent(id)
|
||||||
const replies = deriveEvents(repository, {filters: [{kinds: [REPLY], "#E": [id]}]})
|
const filters = [{kinds: [REPLY], "#E": [id]}]
|
||||||
|
const replies = deriveEvents(repository, {filters})
|
||||||
|
|
||||||
const back = () => history.back()
|
const back = () => history.back()
|
||||||
|
|
||||||
@@ -30,32 +33,46 @@
|
|||||||
const onReplySubmit = (thunk: Thunk) => {}
|
const onReplySubmit = (thunk: Thunk) => {}
|
||||||
|
|
||||||
let showReply = false
|
let showReply = false
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const sub = subscribe({filters, relays: [url]})
|
||||||
|
|
||||||
|
return () => sub.close()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="relative flex flex-col-reverse gap-3 p-2">
|
<div class="relative flex flex-col-reverse gap-3 p-2">
|
||||||
<div class="absolute left-[51px] top-20 h-[calc(100%-200px)] w-[2px] bg-neutral" />
|
<div class="absolute left-[51px] top-20 h-[calc(100%-200px)] w-[2px] bg-neutral" />
|
||||||
{#if !showReply}
|
{#if $event}
|
||||||
<div class="flex justify-end p-2">
|
{#if !showReply}
|
||||||
<Button class="btn btn-primary" on:click={openReply}>
|
<div class="flex justify-end p-2">
|
||||||
<Icon icon="reply" />
|
<Button class="btn btn-primary" on:click={openReply}>
|
||||||
Reply to thread
|
<Icon icon="reply" />
|
||||||
</Button>
|
Reply to thread
|
||||||
</div>
|
</Button>
|
||||||
{/if}
|
|
||||||
{#each sortBy(e => -e.created_at, $replies) as reply (reply.id)}
|
|
||||||
<NoteCard event={reply} class="card2 bg-alt z-feature w-full">
|
|
||||||
<div class="ml-12">
|
|
||||||
<Content event={reply} />
|
|
||||||
</div>
|
</div>
|
||||||
<ThreadActions event={reply} {url} />
|
{/if}
|
||||||
|
{#each sortBy(e => -e.created_at, $replies) as reply (reply.id)}
|
||||||
|
<NoteCard event={reply} class="card2 bg-alt z-feature w-full">
|
||||||
|
<div class="ml-12">
|
||||||
|
<Content event={reply} />
|
||||||
|
</div>
|
||||||
|
<ThreadActions event={reply} {url} />
|
||||||
|
</NoteCard>
|
||||||
|
{/each}
|
||||||
|
<NoteCard event={$event} class="card2 bg-alt z-feature w-full">
|
||||||
|
<div class="ml-12">
|
||||||
|
<Content event={$event} />
|
||||||
|
</div>
|
||||||
|
<ThreadActions event={$event} {url} />
|
||||||
</NoteCard>
|
</NoteCard>
|
||||||
{/each}
|
{:else}
|
||||||
<NoteCard event={$event} class="card2 bg-alt z-feature w-full">
|
{#await sleep(5000)}
|
||||||
<div class="ml-12">
|
<Spinner loading>Loading thread...</Spinner>
|
||||||
<Content event={$event} />
|
{:then}
|
||||||
</div>
|
<p>Failed to load thread.</p>
|
||||||
<ThreadActions event={$event} {url} />
|
{/await}
|
||||||
</NoteCard>
|
{/if}
|
||||||
<Button class="mb-2 mt-5 flex items-center gap-2" on:click={back}>
|
<Button class="mb-2 mt-5 flex items-center gap-2" on:click={back}>
|
||||||
<Icon icon="alt-arrow-left" />
|
<Icon icon="alt-arrow-left" />
|
||||||
Go back
|
Go back
|
||||||
|
|||||||
Reference in New Issue
Block a user