diff --git a/src/components/chat/ChatEditor.vue b/src/components/chat/ChatEditor.vue index fea8242..2fefc53 100644 --- a/src/components/chat/ChatEditor.vue +++ b/src/components/chat/ChatEditor.vue @@ -103,9 +103,6 @@ Uploading your media, please stand by... - - - Something went wrong... {{ error }} @@ -114,15 +111,15 @@ import { reactive, ref, watch } from "vue" import { request } from "@/scripts/request" import { getAtk } from "@/stores/userinfo" import { useChannels } from "@/stores/channels" +import { useUI } from "@/stores/ui" import Attachments from "@/components/chat/parts/ChatAttachments.vue" -import Media from "@/components/publish/parts/PublishMedia.vue" const emits = defineEmits(["sent"]) const chat = ref() const channels = useChannels() -const error = ref(null) +const { showErrorSnackbar } = useUI() const uploading = ref(false) const loading = ref(false) @@ -156,11 +153,10 @@ async function sendMessage() { body: JSON.stringify(payload) }) if (res.status !== 200) { - error.value = await res.text() + showErrorSnackbar(await res.text()) } else { emits("sent") resetEditor() - error.value = null } loading.value = false } @@ -203,10 +199,3 @@ function pasteMedia(evt: ClipboardEvent) { } } - - diff --git a/src/components/chat/MessageDeletion.vue b/src/components/chat/MessageDeletion.vue index d78be98..2dd01b3 100644 --- a/src/components/chat/MessageDeletion.vue +++ b/src/components/chat/MessageDeletion.vue @@ -12,11 +12,6 @@ - - The realm has been deleted. - - - Something went wrong... {{ error }} + + \ No newline at end of file diff --git a/src/components/posts/PostReaction.vue b/src/components/posts/PostReaction.vue index bfacece..a183601 100644 --- a/src/components/posts/PostReaction.vue +++ b/src/components/posts/PostReaction.vue @@ -26,12 +26,6 @@ - - Your react has been added into post. - Your react has been removed from post. - - - Something went wrong... {{ error }} @@ -39,8 +33,10 @@ import { request } from "@/scripts/request" import { getAtk, useUserinfo } from "@/stores/userinfo" import { reactive, ref } from "vue" +import { useUI } from "@/stores/ui" const id = useUserinfo() +const {showSnackbar, showErrorSnackbar} = useUI() const emits = defineEmits(["update"]) const props = defineProps<{ @@ -62,9 +58,6 @@ function pickColor(): string { return colors[randomIndex] } -const status = reactive({ added: false, removed: false }) -const error = ref(null) - async function reactPost(symbol: string, attitude: number) { const res = await request("interactive", `/api/p/${props.model}/${props.item?.id}/react`, { method: "POST", @@ -72,13 +65,13 @@ async function reactPost(symbol: string, attitude: number) { body: JSON.stringify({ symbol, attitude }) }) if (res.status === 201) { - status.added = true + showSnackbar("Your react has been added onto the post.") emits("update", symbol, 1) } else if (res.status === 204) { - status.removed = true + showSnackbar("Your react has been removed from the post.") emits("update", symbol, -1) } else { - error.value = await res.text() + showErrorSnackbar(await res.text()) } } diff --git a/src/components/publish/ArticleEditor.vue b/src/components/publish/ArticleEditor.vue index 79b8802..4e8fa5a 100644 --- a/src/components/publish/ArticleEditor.vue +++ b/src/components/publish/ArticleEditor.vue @@ -109,14 +109,10 @@ - Your article has been published. Uploading your media, please stand by... - - - Something went wrong... {{ error }}