feat: switch to a string instead of enum

This commit is contained in:
Xyphyn committed 2023-08-02 14:22:27 -07:00
1 parent aeb727ae3b
commit 87612d6507
23 files changed
+92 -128

No files matched your search

@@ -16,7 +16,7 @@
import CommentActions from '$lib/components/lemmy/comment/CommentActions.svelte'
import Modal from '$lib/components/ui/modal/Modal.svelte'
import { getClient } from '$lib/lemmy.js'
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { profile } from '$lib/auth.js'
export let node: CommentNodeI
@@ -52,13 +52,13 @@
toast({
content:
'Successfully edited comment. You may need to refresh to see changes.',
type: ToastType.success,
type: 'success',
})
} catch (err) {
toast({
// @ts-ignore i hate this
content: err,
type: ToastType.error,
type: 'error',
})
}
}}
@@ -18,7 +18,7 @@
Trash,
} from 'svelte-hero-icons'
import { getClient, getInstance } from '$lib/lemmy.js'
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import Menu from '$lib/components/ui/menu/Menu.svelte'
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
import Button from '$lib/components/input/Button.svelte'
@@ -50,7 +50,7 @@
toast({
content: error as any,
type: ToastType.error,
type: 'error',
})
}
}
@@ -95,7 +95,9 @@
<MenuButton
on:click={() => {
navigator.clipboard.writeText(
`${$page.url.origin}/post/${getInstance()}/${comment.post.id}?thread=${comment.comment.path}#${comment.comment.id}`
`${$page.url.origin}/post/${getInstance()}/${
comment.post.id
}?thread=${comment.comment.path}#${comment.comment.id}`
)
}}
>
@@ -126,12 +128,12 @@
})
toast({
content: 'The comment was deleted.',
type: ToastType.success,
type: 'success',
})
} catch (error) {
toast({
content: 'Failed to delete comment',
type: ToastType.error,
type: 'error',
})
}
}}
@@ -4,11 +4,11 @@
import type { CommentResponse } from 'lemmy-js-client'
import { getClient } from '$lib/lemmy.js'
import { createEventDispatcher } from 'svelte'
import { ToastType, addToast } from '$lib/components/ui/toasts/toasts.js'
import TextArea from '$lib/components/input/TextArea.svelte'
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import { profile } from '$lib/auth.js'
import { toast } from '$lib/components/ui/toasts/toasts.js'
export let postId: number
export let parentId: number | undefined = undefined
@@ -40,18 +40,16 @@
dispatch('comment', response)
value = ''
addToast(
'Success',
'Your comment was added. You may need to refresh to see it.',
ToastType.success
)
toast({
content: 'Your comment was added. You may need to refresh to see it.',
type: 'success',
})
} catch (err) {
console.error(err)
addToast(
'Error',
'Failed to comment. (Sometimes this error appears even when successful.)',
ToastType.error
)
toast({
content: err as any,
type: 'error',
})
}
loading = false
@@ -8,7 +8,7 @@
import { getClient } from '$lib/lemmy.js'
import type { CommentView, Post } from 'lemmy-js-client'
import { fly } from 'svelte/transition'
import { toast, ToastType } from '$lib/components/ui/toasts/toasts.js'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { profile } from '$lib/auth.js'
export let nodes: CommentNodeI[]
@@ -53,7 +53,7 @@
loadingChildren = false
toast({
content: 'The API returned no comments.',
type: ToastType.error,
type: 'error',
})
return
}
@@ -77,7 +77,7 @@
console.error(error)
toast({
content: `Failed to fetch comments. ${error as any}`,
type: ToastType.error,
type: 'error',
})
}
}