A little bit of cleanup
This commit is contained in:
+1
-1
@@ -29,4 +29,4 @@ WORKDIR /app
|
|||||||
# Copy only the built output - no source, no .env, no dev deps
|
# Copy only the built output - no source, no .env, no dev deps
|
||||||
COPY --from=builder /app/build ./build
|
COPY --from=builder /app/build ./build
|
||||||
|
|
||||||
CMD ["npx", "serve", "build"]
|
CMD ["npx", "serve", "-s", "build"]
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {Readable} from "svelte/store"
|
|
||||||
import {readable} from "svelte/store"
|
|
||||||
import cx from "classnames"
|
import cx from "classnames"
|
||||||
import {ifLet, removeUndefined} from "@welshman/lib"
|
import {removeUndefined} from "@welshman/lib"
|
||||||
import {deriveProfile} from "@welshman/app"
|
import {deriveProfile} from "@welshman/app"
|
||||||
import UserRounded from "@assets/icons/user-rounded.svg?dataurl"
|
import UserRounded from "@assets/icons/user-rounded.svg?dataurl"
|
||||||
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
pubkey?: string
|
pubkey: string
|
||||||
class?: string
|
class?: string
|
||||||
size?: number
|
size?: number
|
||||||
url?: string
|
url?: string
|
||||||
@@ -16,13 +14,11 @@
|
|||||||
|
|
||||||
const {pubkey, url, size = 7, ...props}: Props = $props()
|
const {pubkey, url, size = 7, ...props}: Props = $props()
|
||||||
|
|
||||||
const readableProfile = ifLet(pubkey, pk => deriveProfile(pk, removeUndefined([url])))
|
const profile = deriveProfile(pubkey, removeUndefined([url]))
|
||||||
const emptyProfile = readable(undefined)
|
|
||||||
const profile: Readable<{picture?: string} | undefined> = readableProfile ?? emptyProfile
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ImageIcon
|
<ImageIcon
|
||||||
{size}
|
{size}
|
||||||
alt=""
|
alt=""
|
||||||
class={cx(props.class, "rounded-full")}
|
class={cx(props.class, "rounded-full")}
|
||||||
src={$profile?.picture ?? UserRounded} />
|
src={$profile?.picture || UserRounded} />
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {get} from "svelte/store"
|
|
||||||
import type {Snippet} from "svelte"
|
import type {Snippet} from "svelte"
|
||||||
import type {RoomMeta} from "@welshman/util"
|
import type {RoomMeta} from "@welshman/util"
|
||||||
import {makeRoomMeta} from "@welshman/util"
|
import {makeRoomMeta} from "@welshman/util"
|
||||||
@@ -30,19 +29,20 @@
|
|||||||
const {url, header, footer, onsubmit, initialValues = makeRoomMeta()}: Props = $props()
|
const {url, header, footer, onsubmit, initialValues = makeRoomMeta()}: Props = $props()
|
||||||
|
|
||||||
const values = $state(initialValues)
|
const values = $state(initialValues)
|
||||||
let roomType = $state<RoomType>(getRoomType(initialValues))
|
|
||||||
const relayHasLivekit = deriveHasLivekit(url)
|
const relayHasLivekit = deriveHasLivekit(url)
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
const room = $state.snapshot(values)
|
const room = $state.snapshot(values)
|
||||||
|
|
||||||
if (roomType === RoomType.Voice && !get(relayHasLivekit)) {
|
if (roomType === RoomType.Voice && !$relayHasLivekit) {
|
||||||
return pushToast({
|
return pushToast({
|
||||||
theme: "error",
|
theme: "error",
|
||||||
message: "This relay does not support voice rooms.",
|
message: "This relay does not support voice rooms.",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
room.livekit = roomType === RoomType.Voice
|
||||||
|
|
||||||
if (imageFile) {
|
if (imageFile) {
|
||||||
const {error, result} = await uploadFile(imageFile, {
|
const {error, result} = await uploadFile(imageFile, {
|
||||||
maxWidth: 256,
|
maxWidth: 256,
|
||||||
@@ -63,10 +63,6 @@
|
|||||||
return pushToast({theme: "error", message: createMessage})
|
return pushToast({theme: "error", message: createMessage})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get(relayHasLivekit)) {
|
|
||||||
room.livekit = roomType === RoomType.Voice
|
|
||||||
room.noText = false
|
|
||||||
}
|
|
||||||
const editMessage = await waitForThunkError(editRoom(url, room))
|
const editMessage = await waitForThunkError(editRoom(url, room))
|
||||||
|
|
||||||
if (editMessage) {
|
if (editMessage) {
|
||||||
@@ -95,6 +91,7 @@
|
|||||||
let loading = $state(false)
|
let loading = $state(false)
|
||||||
let imageFile = $state<File | undefined>()
|
let imageFile = $state<File | undefined>()
|
||||||
let imagePreview = $state(initialValues.picture)
|
let imagePreview = $state(initialValues.picture)
|
||||||
|
let roomType = $state(getRoomType(initialValues))
|
||||||
|
|
||||||
const handleImageUpload = async (event: Event) => {
|
const handleImageUpload = async (event: Event) => {
|
||||||
const file = (event.target as HTMLInputElement).files?.[0]
|
const file = (event.target as HTMLInputElement).files?.[0]
|
||||||
|
|||||||
@@ -21,14 +21,13 @@
|
|||||||
const isVoiceRoomActive = $derived(
|
const isVoiceRoomActive = $derived(
|
||||||
$currentVoiceSession?.url === url && $currentVoiceSession?.h === h,
|
$currentVoiceSession?.url === url && $currentVoiceSession?.h === h,
|
||||||
)
|
)
|
||||||
const typeIconSrc = $derived(isVoiceRoomActive ? VolumeLoud : Volume)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if isVoiceRoom}
|
{#if isVoiceRoom}
|
||||||
<div class="flex shrink-0 items-center gap-1.5">
|
<div class="flex shrink-0 items-center gap-1.5">
|
||||||
<Icon
|
<Icon
|
||||||
icon={typeIconSrc}
|
|
||||||
size={size + 1}
|
size={size + 1}
|
||||||
|
icon={isVoiceRoomActive ? VolumeLoud : Volume}
|
||||||
class={isVoiceRoomActive ? "text-primary -translate-x-0.5" : ""} />
|
class={isVoiceRoomActive ? "text-primary -translate-x-0.5" : ""} />
|
||||||
{#if $room.picture}
|
{#if $room.picture}
|
||||||
<span class="text-base">/</span>
|
<span class="text-base">/</span>
|
||||||
|
|||||||
@@ -12,13 +12,12 @@
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
back?: () => unknown
|
back?: () => unknown
|
||||||
icon?: Snippet
|
|
||||||
title?: Snippet
|
title?: Snippet
|
||||||
action?: Snippet
|
action?: Snippet
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
const {back = () => goto(makeSpacePath(url)), icon, title, action, ...props}: Props = $props()
|
const {back = () => goto(makeSpacePath(url)), title, action, ...props}: Props = $props()
|
||||||
|
|
||||||
const url = decodeRelay($page.params.relay!)
|
const url = decodeRelay($page.params.relay!)
|
||||||
</script>
|
</script>
|
||||||
@@ -28,17 +27,10 @@
|
|||||||
<Button onclick={back} class="place-self-start pr-3 md:hidden">
|
<Button onclick={back} class="place-self-start pr-3 md:hidden">
|
||||||
<Icon icon={ArrowLeft} size={7} />
|
<Icon icon={ArrowLeft} size={7} />
|
||||||
</Button>
|
</Button>
|
||||||
<div class="flex min-w-0 flex-grow items-center justify-between gap-4">
|
<div class="ellipsize whitespace-nowrap flex flex-grow items-center justify-between gap-4">
|
||||||
<div class="flex min-w-0 flex-col">
|
<div class="flex flex-col">
|
||||||
<div class="flex min-w-0 items-center gap-2">
|
<div class="flex gap-2 items-center">
|
||||||
{#if icon}
|
{@render title?.()}
|
||||||
<div class="shrink-0">{@render icon?.()}</div>
|
|
||||||
<div class="ellipsize min-w-0 whitespace-nowrap">{@render title?.()}</div>
|
|
||||||
{:else}
|
|
||||||
<div class="ellipsize min-w-0 flex items-center gap-2 whitespace-nowrap">
|
|
||||||
{@render title?.()}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs text-primary md:hidden">
|
<div class="text-xs text-primary md:hidden">
|
||||||
{displayRelayUrl(url)}
|
{displayRelayUrl(url)}
|
||||||
|
|||||||
@@ -296,7 +296,8 @@
|
|||||||
<div class="h-5 flex-shrink-0"></div>
|
<div class="h-5 flex-shrink-0"></div>
|
||||||
</div>
|
</div>
|
||||||
</SecondaryNavSection>
|
</SecondaryNavSection>
|
||||||
<div class="flex flex-shrink-0 flex-col gap-2 p-2 pt-0 -mt-4 pb-[calc(var(--saib)+3.5rem)] z-nav">
|
<div
|
||||||
|
class="flex flex-shrink-0 flex-col gap-2 p-2 pt-0 -mt-4 pb-[calc(var(--saib)+3rem)] sm:pb-2 z-nav">
|
||||||
<VoiceWidget />
|
<VoiceWidget />
|
||||||
<Button class="btn btn-neutral btn-sm h-10" onclick={showDetail}>
|
<Button class="btn btn-neutral btn-sm h-10" onclick={showDetail}>
|
||||||
<SocketStatusIndicator {url} />
|
<SocketStatusIndicator {url} />
|
||||||
|
|||||||
+2
-12
@@ -125,6 +125,7 @@ import type {
|
|||||||
RelayProfile,
|
RelayProfile,
|
||||||
PublishedList,
|
PublishedList,
|
||||||
PublishedRoomMeta,
|
PublishedRoomMeta,
|
||||||
|
RoomMeta,
|
||||||
List,
|
List,
|
||||||
Filter,
|
Filter,
|
||||||
} from "@welshman/util"
|
} from "@welshman/util"
|
||||||
@@ -578,7 +579,7 @@ export type Room = PublishedRoomMeta & {
|
|||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getRoomType = (room: {livekit?: boolean}): RoomType =>
|
export const getRoomType = (room: RoomMeta): RoomType =>
|
||||||
room.livekit ? RoomType.Voice : RoomType.Text
|
room.livekit ? RoomType.Voice : RoomType.Text
|
||||||
|
|
||||||
export const makeRoomId = (url: string, h: string) => `${url}'${h}`
|
export const makeRoomId = (url: string, h: string) => `${url}'${h}`
|
||||||
@@ -683,17 +684,6 @@ export const deriveVoiceRooms = (url: string) =>
|
|||||||
return set
|
return set
|
||||||
})
|
})
|
||||||
|
|
||||||
export const deriveRoomsNoText = (url: string) =>
|
|
||||||
derived(roomsById, $roomsById => {
|
|
||||||
const set = new Set<string>()
|
|
||||||
for (const room of $roomsById.values()) {
|
|
||||||
if (room.url === url && room.noText) {
|
|
||||||
set.add(room.h)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return set
|
|
||||||
})
|
|
||||||
|
|
||||||
export const deriveOtherVoiceRooms = (url: string) =>
|
export const deriveOtherVoiceRooms = (url: string) =>
|
||||||
derived([deriveVoiceRooms(url), deriveUserRooms(url)], ([$roomsWithLivekit, $userRooms]) => {
|
derived([deriveVoiceRooms(url), deriveUserRooms(url)], ([$roomsWithLivekit, $userRooms]) => {
|
||||||
const rooms: string[] = []
|
const rooms: string[] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user