mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-13 02:42:30 +00:00
improved component composition and added tests.
This commit is contained in:
@@ -11,8 +11,7 @@
|
||||
* a federated round trip is slow enough that waiting feels broken.
|
||||
*/
|
||||
import type { Status } from '$lib/api/types'
|
||||
import { session } from '$lib/stores/session.svelte'
|
||||
import { favouriteStatus, reblogStatus, deleteStatus } from '$lib/api/endpoints'
|
||||
import { useAppServices } from '$lib/app-services'
|
||||
import { displayNameOf, formatCount, fullHandle, profilePath } from '$lib/util/profile'
|
||||
import { renderDisplayName } from '$lib/util/html'
|
||||
import { isoDate, longDate, stampDate } from '$lib/util/time'
|
||||
@@ -36,6 +35,7 @@
|
||||
|
||||
let { status, onupdate, ondelete, compact = false, longFormDate = false }: Props = $props()
|
||||
|
||||
const { endpoints, session } = useAppServices()
|
||||
/** The status actually being displayed; a boost renders its target. */
|
||||
const entry = $derived(status.reblog ?? status)
|
||||
const booster = $derived(status.reblog ? status.account : null)
|
||||
@@ -73,7 +73,7 @@
|
||||
onupdate?.(applyLocal(status, { favourited: next, favourites_count: entry.favourites_count + (next ? 1 : -1) }))
|
||||
|
||||
try {
|
||||
const updated = await favouriteStatus(session.api, entry.id, next)
|
||||
const updated = await endpoints.favouriteStatus(session.api, entry.id, next)
|
||||
onupdate?.(rewrap(status, updated))
|
||||
} catch (cause) {
|
||||
onupdate?.(status)
|
||||
@@ -92,7 +92,7 @@
|
||||
onupdate?.(applyLocal(status, { reblogged: next, reblogs_count: entry.reblogs_count + (next ? 1 : -1) }))
|
||||
|
||||
try {
|
||||
const updated = await reblogStatus(session.api, entry.id, next)
|
||||
const updated = await endpoints.reblogStatus(session.api, entry.id, next)
|
||||
// Reblogging returns the *wrapper* status; unwrap to the original.
|
||||
onupdate?.(rewrap(status, updated.reblog ?? updated))
|
||||
} catch (cause) {
|
||||
@@ -108,7 +108,7 @@
|
||||
if (!confirm('Delete this entry? This cannot be undone.')) return
|
||||
busy = true
|
||||
try {
|
||||
await deleteStatus(session.api, entry.id)
|
||||
await endpoints.deleteStatus(session.api, entry.id)
|
||||
ondelete?.(status.id)
|
||||
} catch (cause) {
|
||||
actionError = cause instanceof Error ? cause.message : 'Could not delete that.'
|
||||
|
||||
Reference in New Issue
Block a user