Alert and Toasts

This commit is contained in:
Simon Caron
2025-01-01 21:31:04 -05:00
parent 34fc26ed18
commit e833b4bc68
15 changed files with 143 additions and 66 deletions

View File

@@ -28,6 +28,7 @@ import Issue from "@/utils/jellyseerr/server/entity/Issue";
import { RTRating } from "@/utils/jellyseerr/server/api/rating/rottentomatoes";
import { writeErrorLog } from "@/utils/log";
import DiscoverSlider from "@/utils/jellyseerr/server/entity/DiscoverSlider";
import { t } from "i18next";
interface SearchParams {
query: string;
@@ -113,7 +114,7 @@ export class JellyseerrApi {
if (inRange(status, 200, 299)) {
if (data.version < "2.0.0") {
const error =
"Jellyseerr server does not meet minimum version requirements! Please update to at least 2.0.0";
t("jellyseerr.toasts.jellyseer_does_not_meet_requirements");
toast.error(error);
throw Error(error);
}
@@ -127,7 +128,7 @@ export class JellyseerrApi {
requiresPass: true,
};
}
toast.error(`Jellyseerr test failed. Please try again.`);
toast.error(t("jellyseerr.toasts.jellyseerr_test_failed"));
writeErrorLog(
`Jellyseerr returned a ${status} for url:\n` +
response.config.url +
@@ -140,7 +141,7 @@ export class JellyseerrApi {
};
})
.catch((e) => {
const msg = "Failed to test jellyseerr server url";
const msg = t("jellyseerr.toasts.failed_to_test_jellyseerr_server_url");
toast.error(msg);
console.error(msg, e);
return {
@@ -259,7 +260,7 @@ export class JellyseerrApi {
const issue = response.data;
if (issue.status === IssueStatus.OPEN) {
toast.success("Issue submitted!");
toast.success(t("jellyseerr.toasts.issue_submitted"));
}
return issue;
});
@@ -342,13 +343,13 @@ export const useJellyseerr = () => {
switch (mediaRequest.status) {
case MediaRequestStatus.PENDING:
case MediaRequestStatus.APPROVED:
toast.success(`Requested ${title}!`);
toast.success(t("jellyseerr.toasts.requested_item", {item: title}));
break;
case MediaRequestStatus.DECLINED:
toast.error(`You don't have permission to request!`);
toast.error(t("jellyseerr.toasts.you_dont_have_permission_to_request"));
break;
case MediaRequestStatus.FAILED:
toast.error(`Something went wrong requesting media!`);
toast.error(t("jellyseerr.toasts.something_went_wrong_requesting_media"));
break;
}
});

View File

@@ -18,6 +18,7 @@ import useDownloadHelper from "@/utils/download";
import { Api } from "@jellyfin/sdk";
import { useSettings } from "@/utils/atoms/settings";
import { JobStatus } from "@/utils/optimize-server";
import { useTranslation } from "react-i18next";
const createFFmpegCommand = (url: string, output: string) => [
"-y", // overwrite output files without asking
@@ -49,6 +50,7 @@ export const useRemuxHlsToMp4 = () => {
const api = useAtomValue(apiAtom);
const router = useRouter();
const queryClient = useQueryClient();
const { t } = useTranslation();
const [settings] = useSettings();
const { saveImage } = useImageStorage();
@@ -84,7 +86,7 @@ export const useRemuxHlsToMp4 = () => {
queryKey: ["downloadedItems"],
});
saveDownloadedItemInfo(item, stat.getSize());
toast.success("Download completed");
toast.success(t("home.downloads.toasts.download_completed"));
}
setProcesses((prev) => {
@@ -144,7 +146,7 @@ export const useRemuxHlsToMp4 = () => {
// First lets save any important assets we want to present to the user offline
await onSaveAssets(api, item);
toast.success(`Download started for ${item.Name}`, {
toast.success(t("home.downloads.toasts.download_started_for", {item: item.Name}), {
action: {
label: "Go to download",
onClick: () => {

View File

@@ -2,6 +2,7 @@ import { useEffect } from "react";
import { Alert } from "react-native";
import { useRouter } from "expo-router";
import { useWebSocketContext } from "@/providers/WebSocketProvider";
import { useTranslation } from "react-i18next";
interface UseWebSocketProps {
isPlaying: boolean;
@@ -18,6 +19,7 @@ export const useWebSocket = ({
}: UseWebSocketProps) => {
const router = useRouter();
const { ws } = useWebSocketContext();
const { t } = useTranslation();
useEffect(() => {
if (!ws) return;
@@ -40,7 +42,7 @@ export const useWebSocket = ({
console.log("Command ~ DisplayMessage");
const title = json?.Data?.Arguments?.Header;
const body = json?.Data?.Arguments?.Text;
Alert.alert("Message from server: " + title, body);
Alert.alert(t("player.message_from_server", {message: title}), body);
}
};