diff --git a/components/authentication/AuthenticationForm.vue b/components/authentication/AuthenticationForm.vue index eb4a5859..26e4d9f1 100644 --- a/components/authentication/AuthenticationForm.vue +++ b/components/authentication/AuthenticationForm.vue @@ -56,7 +56,6 @@ type Form = { confirm_password: string } -const config = useRuntimeConfig(); const rest = useRestApi(); const authModalOpen = useAuthenticationModal(); const settings = useSettings(); @@ -120,8 +119,8 @@ function login () { notify({ group: "error", title: "Error", - text: err.message - }, 4000); // 4s + text: `Login failed. ${err.message}.` + }, 10000); }); } @@ -143,8 +142,8 @@ function signup () { notify({ group: "error", title: "Error", - text: err.message - }, 4000); // 4s + text: `Registration failed. ${err.message}.` + }, 10000); }); } diff --git a/components/torrent/TorrentActionCard.vue b/components/torrent/TorrentActionCard.vue index 3f7832c8..389c931b 100644 --- a/components/torrent/TorrentActionCard.vue +++ b/components/torrent/TorrentActionCard.vue @@ -150,6 +150,7 @@ import { LinkIcon, CalendarIcon, CircleStackIcon, UserCircleIcon, HashtagIcon, TagIcon } from "@heroicons/vue/24/solid"; import { PropType } from "vue"; import { TorrentResponse } from "torrust-index-types-lib"; +import { notify } from "notiwind-ts"; import { fileSize, downloadTorrent, @@ -199,6 +200,13 @@ function deleteTorrent () { rest.value.torrent.deleteTorrent(props.torrent.info_hash) .then(() => { emit("deleted"); + }) + .catch((err) => { + notify({ + group: "error", + title: "Error", + text: `Trying to delete the torrent. ${err.message}.` + }, 10000); }); } diff --git a/components/torrent/TorrentListTorrentDetails.vue b/components/torrent/TorrentListTorrentDetails.vue index 258a860b..c67f6671 100644 --- a/components/torrent/TorrentListTorrentDetails.vue +++ b/components/torrent/TorrentListTorrentDetails.vue @@ -17,10 +17,9 @@ diff --git a/composables/states.ts b/composables/states.ts index f52b15a8..33210c04 100644 --- a/composables/states.ts +++ b/composables/states.ts @@ -1,6 +1,7 @@ import { PublicSettings, Category, TokenResponse, TorrentTag } from "torrust-index-types-lib"; import { Rest } from "torrust-index-api-lib"; import { useRuntimeConfig, useState } from "#app"; +import { notify } from "notiwind-ts"; export const useRestApi = () => useState("rest-api", () => new Rest(useRuntimeConfig().public.apiBase)); export const useCategories = () => useState>("categories", () => new Array()); @@ -13,6 +14,13 @@ export function getSettings () { useRestApi().value.settings.getPublicSettings() .then((publicSettings) => { useSettings().value = publicSettings; + }) + .catch((err) => { + notify({ + group: "error", + title: "Error", + text: `Trying to get public settings. ${err.message}.` + }, 10000); }); } @@ -20,6 +28,13 @@ export function getCategories () { useRestApi().value.category.getCategories() .then((res) => { useCategories().value = res; + }) + .catch((err) => { + notify({ + group: "error", + title: "Error", + text: `Trying to get categories. ${err.message}.` + }, 10000); }); } @@ -27,6 +42,13 @@ export function getTags () { useRestApi().value.tag.getTags() .then((res) => { useTags().value = res; + }) + .catch((err) => { + notify({ + group: "error", + title: "Error", + text: `Trying to get tags. ${err.message}.` + }, 10000); }); } @@ -37,6 +59,13 @@ export async function loginUser (login: string, password: string) { }) .then((user) => { useUser().value = user; + }) + .catch((err) => { + notify({ + group: "error", + title: "Error", + text: `Trying to login. ${err.message}.` + }, 10000); }); } @@ -54,5 +83,12 @@ export async function getUser () { return await useRestApi().value.user.renewToken() .then((user) => { useUser().value = user; + }) + .catch((err) => { + notify({ + group: "error", + title: "Error", + text: `Trying to get user info. ${err.message}.` + }, 10000); }); } diff --git a/pages/admin/settings.vue b/pages/admin/settings.vue index 1fc98a5c..6f28dd3b 100644 --- a/pages/admin/settings.vue +++ b/pages/admin/settings.vue @@ -30,7 +30,8 @@ diff --git a/pages/upload.vue b/pages/upload.vue index 8bf623d1..ba4a508b 100644 --- a/pages/upload.vue +++ b/pages/upload.vue @@ -89,7 +89,6 @@ import { onMounted, ref, toRaw, useRestApi, - useRuntimeConfig, useTags, useUser } from "#imports"; @@ -103,7 +102,6 @@ type FormUploadTorrent = { torrentFile: any; } -const config = useRuntimeConfig(); const categories = useCategories(); const tags = useTags(); const user = useUser(); @@ -168,8 +166,8 @@ function submitForm () { notify({ group: "error", title: "Error", - text: err - }, 4000); + text: `Trying to upload the torrent. ${err.message}.` + }, 10000); }); }