misc: Improve error handling

This commit is contained in:
Xyphyn committed 2023-07-03 12:33:04 -07:00
1 parent 98b5e4b5c1
commit a5460a03b4
23 files changed
+285 -202

No files matched your search

-19
View File
@@ -1,19 +0,0 @@
<script lang="ts">
import type { Community } from 'lemmy-js-client'
export let community: Community
function linkFromCommunity(community: Community) {
const local = community.local
if (local) {
return `/c/${community.name}`
} else {
const domain = new URL(community.actor_id).hostname
return `/c/${community.name}@${domain}`
}
}
</script>
<a href={linkFromCommunity(community)}>{community.title}</a>
+3 -4
View File
@@ -1,8 +1,7 @@
<script lang="ts">
import Link from '$lib/components/Link.svelte'
import Logo from '$lib/components/Logo.svelte'
export let instance_url: string | undefined
import { instance_url } from '$lib/lemmy.js'
</script>
<nav
@@ -14,13 +13,13 @@
<Logo width={40} />
<div class="flex flex-col">
<span class="font-bold">Xylemmy</span>
{#if instance_url}
{#if $instance_url}
<a
class="text-xs opacity-50 hover:opacity-100 hover:underline
transition-opacity"
href="/instance"
>
{new URL(`https://${instance_url}`).hostname}
{new URL(`https://${$instance_url}`).hostname}
</a>
{/if}
</div>
@@ -0,0 +1,32 @@
<script lang="ts">
import type { Community } from 'lemmy-js-client'
export let community: Community
export let avatar: boolean = false
function linkFromCommunity(community: Community) {
const local = community.local
if (local) {
return `/c/${community.name}`
} else {
const domain = new URL(community.actor_id).hostname
return `/c/${community.name}@${domain}`
}
}
</script>
<a class="items-center flex flex-row gap-2" href={linkFromCommunity(community)}>
{#if avatar}
<img
src={community.icon ??
`https://api.dicebear.com/6.x/initials/svg?seed=${community.name}`}
alt=""
width={24}
height={24}
class="rounded-full aspect-square object-cover"
/>
{/if}
{community.title}
</a>
+4 -1
View File
@@ -2,7 +2,10 @@ import { LemmyHttp, type LoginResponse } from 'lemmy-js-client'
import { writable } from 'svelte/store'
import { PUBLIC_PROXY_URL } from '$env/static/public'
export let instance_url = 'lemmy.world'
export const DEFAULT_INSTANCE_URL = 'lemmy.world'
export let instance_url = writable(DEFAULT_INSTANCE_URL)
export function getClient(instance: string = `lemmy.world`): LemmyHttp {
return new LemmyHttp(`${PUBLIC_PROXY_URL}/cors/${instance}`)
}