mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-04-21 00:04:42 +01:00
merge develop
This commit is contained in:
@@ -5,7 +5,7 @@ import { apiAtom } from "@/providers/JellyfinProvider";
|
||||
import { getAuthHeaders } from "@/utils/jellyfin/jellyfin";
|
||||
import { writeToLog } from "@/utils/log";
|
||||
import { msToSeconds, secondsToMs } from "@/utils/time";
|
||||
import * as Haptics from "@/packages/expo-haptics";
|
||||
import { useHaptic } from "./useHaptic";
|
||||
|
||||
interface CreditTimestamps {
|
||||
Introduction: {
|
||||
@@ -29,6 +29,7 @@ export const useCreditSkipper = (
|
||||
) => {
|
||||
const [api] = useAtom(apiAtom);
|
||||
const [showSkipCreditButton, setShowSkipCreditButton] = useState(false);
|
||||
const lightHapticFeedback = useHaptic("light");
|
||||
|
||||
if (isVlc) {
|
||||
currentTime = msToSeconds(currentTime);
|
||||
@@ -79,7 +80,7 @@ export const useCreditSkipper = (
|
||||
if (!creditTimestamps) return;
|
||||
console.log(`Skipping credits to ${creditTimestamps.Credits.End}`);
|
||||
try {
|
||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
||||
lightHapticFeedback();
|
||||
wrappedSeek(creditTimestamps.Credits.End);
|
||||
setTimeout(() => {
|
||||
play();
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useMemo } from "react";
|
||||
|
||||
// Used only for intial play settings.
|
||||
// Used only for initial play settings.
|
||||
const useDefaultPlaySettings = (
|
||||
item: BaseItemDto,
|
||||
settings: Settings | null
|
||||
|
||||
63
hooks/useHaptic.ts
Normal file
63
hooks/useHaptic.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { Platform } from "react-native";
|
||||
import { useSettings } from "@/utils/atoms/settings";
|
||||
const Haptics = !Platform.isTV ? require("expo-haptics") : null;
|
||||
|
||||
export type HapticFeedbackType =
|
||||
| "light"
|
||||
| "medium"
|
||||
| "heavy"
|
||||
| "selection"
|
||||
| "success"
|
||||
| "warning"
|
||||
| "error";
|
||||
|
||||
export const useHaptic = (feedbackType: HapticFeedbackType = "selection") => {
|
||||
const [settings] = useSettings();
|
||||
|
||||
if (Platform.isTV) {
|
||||
return () => {};
|
||||
}
|
||||
|
||||
const createHapticHandler = useCallback(
|
||||
(type: Haptics.ImpactFeedbackStyle) => {
|
||||
return Platform.OS === "web" || Platform.isTV
|
||||
? () => {}
|
||||
: () => Haptics.impactAsync(type);
|
||||
},
|
||||
[]
|
||||
);
|
||||
const createNotificationFeedback = useCallback(
|
||||
(type: Haptics.NotificationFeedbackType) => {
|
||||
return Platform.OS === "web" || Platform.isTV
|
||||
? () => {}
|
||||
: () => Haptics.notificationAsync(type);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const hapticHandlers = useMemo(
|
||||
() => ({
|
||||
light: createHapticHandler(Haptics.ImpactFeedbackStyle.Light),
|
||||
medium: createHapticHandler(Haptics.ImpactFeedbackStyle.Medium),
|
||||
heavy: createHapticHandler(Haptics.ImpactFeedbackStyle.Heavy),
|
||||
selection:
|
||||
Platform.OS === "web" || Platform.isTV
|
||||
? () => {}
|
||||
: Haptics.selectionAsync,
|
||||
success: createNotificationFeedback(
|
||||
Haptics.NotificationFeedbackType.Success
|
||||
),
|
||||
warning: createNotificationFeedback(
|
||||
Haptics.NotificationFeedbackType.Warning
|
||||
),
|
||||
error: createNotificationFeedback(Haptics.NotificationFeedbackType.Error),
|
||||
}),
|
||||
[createHapticHandler, createNotificationFeedback]
|
||||
);
|
||||
|
||||
if (settings?.disableHapticFeedback) {
|
||||
return () => {};
|
||||
}
|
||||
return hapticHandlers[feedbackType];
|
||||
};
|
||||
@@ -5,7 +5,7 @@ import { apiAtom } from "@/providers/JellyfinProvider";
|
||||
import { getAuthHeaders } from "@/utils/jellyfin/jellyfin";
|
||||
import { writeToLog } from "@/utils/log";
|
||||
import { msToSeconds, secondsToMs } from "@/utils/time";
|
||||
import * as Haptics from "@/packages/expo-haptics";
|
||||
import { useHaptic } from "./useHaptic";
|
||||
|
||||
interface IntroTimestamps {
|
||||
EpisodeId: string;
|
||||
@@ -33,6 +33,7 @@ export const useIntroSkipper = (
|
||||
if (isVlc) {
|
||||
currentTime = msToSeconds(currentTime);
|
||||
}
|
||||
const lightHapticFeedback = useHaptic("light");
|
||||
|
||||
const wrappedSeek = (seconds: number) => {
|
||||
if (isVlc) {
|
||||
@@ -78,7 +79,7 @@ export const useIntroSkipper = (
|
||||
const skipIntro = useCallback(() => {
|
||||
if (!introTimestamps) return;
|
||||
try {
|
||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
||||
lightHapticFeedback();
|
||||
wrappedSeek(introTimestamps.IntroEnd);
|
||||
setTimeout(() => {
|
||||
play();
|
||||
|
||||
106
hooks/useJellyfinDiscovery.tsx
Normal file
106
hooks/useJellyfinDiscovery.tsx
Normal file
@@ -0,0 +1,106 @@
|
||||
import { useState, useCallback } from "react";
|
||||
import dgram from "react-native-udp";
|
||||
|
||||
const JELLYFIN_DISCOVERY_PORT = 7359;
|
||||
const DISCOVERY_MESSAGE = "Who is JellyfinServer?";
|
||||
|
||||
interface ServerInfo {
|
||||
address: string;
|
||||
port: number;
|
||||
serverId?: string;
|
||||
serverName?: string;
|
||||
}
|
||||
|
||||
export const useJellyfinDiscovery = () => {
|
||||
const [servers, setServers] = useState<ServerInfo[]>([]);
|
||||
const [isSearching, setIsSearching] = useState(false);
|
||||
|
||||
const startDiscovery = useCallback(() => {
|
||||
setIsSearching(true);
|
||||
setServers([]);
|
||||
|
||||
const discoveredServers = new Set<string>();
|
||||
let discoveryTimeout: NodeJS.Timeout;
|
||||
|
||||
const socket = dgram.createSocket({
|
||||
type: "udp4",
|
||||
reusePort: true,
|
||||
debug: __DEV__,
|
||||
});
|
||||
|
||||
socket.on("error", (err) => {
|
||||
console.error("Socket error:", err);
|
||||
socket.close();
|
||||
setIsSearching(false);
|
||||
});
|
||||
|
||||
socket.bind(0, () => {
|
||||
console.log("UDP socket bound successfully");
|
||||
|
||||
try {
|
||||
socket.setBroadcast(true);
|
||||
const messageBuffer = new TextEncoder().encode(DISCOVERY_MESSAGE);
|
||||
|
||||
socket.send(
|
||||
messageBuffer,
|
||||
0,
|
||||
messageBuffer.length,
|
||||
JELLYFIN_DISCOVERY_PORT,
|
||||
"255.255.255.255",
|
||||
(err) => {
|
||||
if (err) {
|
||||
console.error("Failed to send discovery message:", err);
|
||||
return;
|
||||
}
|
||||
console.log("Discovery message sent successfully");
|
||||
}
|
||||
);
|
||||
|
||||
discoveryTimeout = setTimeout(() => {
|
||||
setIsSearching(false);
|
||||
socket.close();
|
||||
}, 5000);
|
||||
} catch (error) {
|
||||
console.error("Error during discovery:", error);
|
||||
setIsSearching(false);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("message", (msg, rinfo: any) => {
|
||||
if (discoveredServers.has(rinfo.address)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = new TextDecoder().decode(msg);
|
||||
const serverInfo = JSON.parse(response);
|
||||
discoveredServers.add(rinfo.address);
|
||||
|
||||
const newServer: ServerInfo = {
|
||||
address: `http://${rinfo.address}:${serverInfo.Port || 8096}`,
|
||||
port: serverInfo.Port || 8096,
|
||||
serverId: serverInfo.Id,
|
||||
serverName: serverInfo.Name,
|
||||
};
|
||||
|
||||
setServers((prev) => [...prev, newServer]);
|
||||
} catch (error) {
|
||||
console.error("Error parsing server response:", error);
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
clearTimeout(discoveryTimeout);
|
||||
if (isSearching) {
|
||||
setIsSearching(false);
|
||||
}
|
||||
socket.close();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return {
|
||||
servers,
|
||||
isSearching,
|
||||
startDiscovery,
|
||||
};
|
||||
};
|
||||
@@ -28,11 +28,18 @@ 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";
|
||||
import {
|
||||
CombinedCredit,
|
||||
PersonDetails,
|
||||
} from "@/utils/jellyseerr/server/models/Person";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import {GenreSliderItem} from "@/utils/jellyseerr/server/interfaces/api/discoverInterfaces";
|
||||
import {UserResultsResponse} from "@/utils/jellyseerr/server/interfaces/api/userInterfaces";
|
||||
import {
|
||||
ServiceCommonServer,
|
||||
ServiceCommonServerWithDetails
|
||||
} from "@/utils/jellyseerr/server/interfaces/api/serviceInterfaces";
|
||||
|
||||
interface SearchParams {
|
||||
query: string;
|
||||
@@ -65,16 +72,24 @@ export enum Endpoints {
|
||||
MOVIE = "/movie",
|
||||
RATINGS = "/ratings",
|
||||
ISSUE = "/issue",
|
||||
USER = "/user",
|
||||
SERVICE = "/service",
|
||||
TV = "/tv",
|
||||
SETTINGS = "/settings",
|
||||
NETWORK = "/network",
|
||||
STUDIO = "/studio",
|
||||
GENRE_SLIDER = "/genreslider",
|
||||
DISCOVER = "/discover",
|
||||
DISCOVER_TRENDING = DISCOVER + "/trending",
|
||||
DISCOVER_MOVIES = DISCOVER + "/movies",
|
||||
DISCOVER_TV = DISCOVER + TV,
|
||||
DISCOVER_TV_NETWORK = DISCOVER + TV + NETWORK,
|
||||
DISCOVER_MOVIES_STUDIO = DISCOVER + `${MOVIE}s` + STUDIO,
|
||||
AUTH_JELLYFIN = "/auth/jellyfin",
|
||||
}
|
||||
|
||||
export type DiscoverEndpoint =
|
||||
| Endpoints.DISCOVER_TV_NETWORK
|
||||
| Endpoints.DISCOVER_TRENDING
|
||||
| Endpoints.DISCOVER_MOVIES
|
||||
| Endpoints.DISCOVER_TV;
|
||||
@@ -120,7 +135,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);
|
||||
}
|
||||
@@ -134,7 +149,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 +
|
||||
@@ -147,7 +162,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 {
|
||||
@@ -181,7 +196,7 @@ export class JellyseerrApi {
|
||||
}
|
||||
|
||||
async discover(
|
||||
endpoint: DiscoverEndpoint,
|
||||
endpoint: DiscoverEndpoint | string,
|
||||
params: any
|
||||
): Promise<SearchResults> {
|
||||
return this.axios
|
||||
@@ -189,6 +204,15 @@ export class JellyseerrApi {
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
async getGenreSliders(
|
||||
endpoint: Endpoints.TV | Endpoints.MOVIE,
|
||||
params: any = undefined
|
||||
): Promise<GenreSliderItem[]> {
|
||||
return this.axios
|
||||
?.get<GenreSliderItem[]>(Endpoints.API_V1 + Endpoints.DISCOVER + Endpoints.GENRE_SLIDER + endpoint, { params })
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
async search(params: SearchParams): Promise<SearchResults> {
|
||||
const response = await this.axios?.get<SearchResults>(
|
||||
Endpoints.API_V1 + Endpoints.SEARCH,
|
||||
@@ -266,9 +290,15 @@ export class JellyseerrApi {
|
||||
});
|
||||
}
|
||||
|
||||
async user(params: any) {
|
||||
return this.axios
|
||||
?.get<UserResultsResponse>(`${Endpoints.API_V1}${Endpoints.USER}`, { params })
|
||||
.then(({data}) => data.results)
|
||||
}
|
||||
|
||||
imageProxy(
|
||||
path?: string,
|
||||
tmdbPath: string = "original",
|
||||
filter: string = "original",
|
||||
width: number = 1920,
|
||||
quality: number = 75
|
||||
) {
|
||||
@@ -276,7 +306,7 @@ export class JellyseerrApi {
|
||||
? this.axios.defaults.baseURL +
|
||||
`/_next/image?` +
|
||||
new URLSearchParams(
|
||||
`url=https://image.tmdb.org/t/p/${tmdbPath}/${path}&w=${width}&q=${quality}`
|
||||
`url=https://image.tmdb.org/t/p/${filter}/${path}&w=${width}&q=${quality}`
|
||||
).toString()
|
||||
: this.axios?.defaults.baseURL +
|
||||
`/images/overseerr_poster_not_found_logo_top.png`;
|
||||
@@ -293,12 +323,24 @@ 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;
|
||||
});
|
||||
}
|
||||
|
||||
async service(type: 'radarr' | 'sonarr') {
|
||||
return this.axios
|
||||
?.get<ServiceCommonServer[]>(Endpoints.API_V1 + Endpoints.SERVICE + `/${type}`)
|
||||
.then(({data}) => data);
|
||||
}
|
||||
|
||||
async serviceDetails(type: 'radarr' | 'sonarr', id: number) {
|
||||
return this.axios
|
||||
?.get<ServiceCommonServerWithDetails>(Endpoints.API_V1 + Endpoints.SERVICE + `/${type}` + `/${id}`)
|
||||
.then(({data}) => data);
|
||||
}
|
||||
|
||||
private setInterceptors() {
|
||||
this.axios.interceptors.response.use(
|
||||
async (response) => {
|
||||
@@ -381,14 +423,14 @@ export const useJellyseerr = () => {
|
||||
switch (mediaRequest.status) {
|
||||
case MediaRequestStatus.PENDING:
|
||||
case MediaRequestStatus.APPROVED:
|
||||
toast.success(`Requested ${title}!`);
|
||||
onSuccess?.();
|
||||
toast.success(t("jellyseerr.toasts.requested_item", {item: title}));
|
||||
onSuccess?.()
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3,17 +3,17 @@ import { markAsNotPlayed } from "@/utils/jellyfin/playstate/markAsNotPlayed";
|
||||
import { markAsPlayed } from "@/utils/jellyfin/playstate/markAsPlayed";
|
||||
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import * as Haptics from "@/packages/expo-haptics";
|
||||
import { useHaptic } from "./useHaptic";
|
||||
import { useAtom } from "jotai";
|
||||
|
||||
export const useMarkAsPlayed = (item: BaseItemDto) => {
|
||||
export const useMarkAsPlayed = (items: BaseItemDto[]) => {
|
||||
const [api] = useAtom(apiAtom);
|
||||
const [user] = useAtom(userAtom);
|
||||
const queryClient = useQueryClient();
|
||||
const lightHapticFeedback = useHaptic("light");
|
||||
|
||||
const invalidateQueries = () => {
|
||||
const queriesToInvalidate = [
|
||||
["item", item.Id],
|
||||
["resumeItems"],
|
||||
["continueWatching"],
|
||||
["nextUp-all"],
|
||||
@@ -23,48 +23,21 @@ export const useMarkAsPlayed = (item: BaseItemDto) => {
|
||||
["home"],
|
||||
];
|
||||
|
||||
items.forEach((item) => {
|
||||
if(!item.Id) return;
|
||||
queriesToInvalidate.push(["item", item.Id]);
|
||||
});
|
||||
|
||||
queriesToInvalidate.forEach((queryKey) => {
|
||||
queryClient.invalidateQueries({ queryKey });
|
||||
});
|
||||
};
|
||||
|
||||
const markAsPlayedStatus = async (played: boolean) => {
|
||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
||||
lightHapticFeedback();
|
||||
|
||||
// Optimistic update
|
||||
queryClient.setQueryData(
|
||||
["item", item.Id],
|
||||
(oldData: BaseItemDto | undefined) => {
|
||||
if (oldData) {
|
||||
return {
|
||||
...oldData,
|
||||
UserData: {
|
||||
...oldData.UserData,
|
||||
Played: !played,
|
||||
},
|
||||
};
|
||||
}
|
||||
return oldData;
|
||||
}
|
||||
);
|
||||
|
||||
try {
|
||||
if (played) {
|
||||
await markAsNotPlayed({
|
||||
api: api,
|
||||
itemId: item?.Id,
|
||||
userId: user?.Id,
|
||||
});
|
||||
} else {
|
||||
await markAsPlayed({
|
||||
api: api,
|
||||
item: item,
|
||||
userId: user?.Id,
|
||||
});
|
||||
}
|
||||
invalidateQueries();
|
||||
} catch (error) {
|
||||
// Revert optimistic update on error
|
||||
items.forEach((item) => {
|
||||
// Optimistic update
|
||||
queryClient.setQueryData(
|
||||
["item", item.Id],
|
||||
(oldData: BaseItemDto | undefined) => {
|
||||
@@ -80,8 +53,45 @@ export const useMarkAsPlayed = (item: BaseItemDto) => {
|
||||
return oldData;
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
try {
|
||||
// Process all items
|
||||
await Promise.all(items.map(item =>
|
||||
played
|
||||
? markAsPlayed({ api, item, userId: user?.Id })
|
||||
: markAsNotPlayed({ api, itemId: item?.Id, userId: user?.Id })
|
||||
));
|
||||
|
||||
// Bulk invalidate
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [
|
||||
"resumeItems",
|
||||
"continueWatching",
|
||||
"nextUp-all",
|
||||
"nextUp",
|
||||
"episodes",
|
||||
"seasons",
|
||||
"home",
|
||||
...items.map(item => ["item", item.Id])
|
||||
].flat()
|
||||
});
|
||||
} catch (error) {
|
||||
// Revert all optimistic updates on any failure
|
||||
items.forEach(item => {
|
||||
queryClient.setQueryData(
|
||||
["item", item.Id],
|
||||
(oldData: BaseItemDto | undefined) =>
|
||||
oldData ? {
|
||||
...oldData,
|
||||
UserData: { ...oldData.UserData, Played: played }
|
||||
} : oldData
|
||||
);
|
||||
});
|
||||
console.error("Error updating played status:", error);
|
||||
}
|
||||
|
||||
invalidateQueries();
|
||||
};
|
||||
|
||||
return markAsPlayedStatus;
|
||||
|
||||
@@ -10,7 +10,9 @@ export const useOrientationSettings = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (settings?.autoRotate) {
|
||||
// Don't need to do anything
|
||||
ScreenOrientation.lockAsync(
|
||||
ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT
|
||||
);
|
||||
} else if (settings?.defaultVideoOrientation) {
|
||||
ScreenOrientation.lockAsync(settings.defaultVideoOrientation);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import { Api } from "@jellyfin/sdk";
|
||||
import { useSettings } from "@/utils/atoms/settings";
|
||||
import { JobStatus } from "@/utils/optimize-server";
|
||||
import { Platform } from "react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
const createFFmpegCommand = (url: string, output: string) => [
|
||||
"-y", // overwrite output files without asking
|
||||
@@ -51,6 +52,7 @@ export const useRemuxHlsToMp4 = () => {
|
||||
const api = useAtomValue(apiAtom);
|
||||
const router = useRouter();
|
||||
const queryClient = useQueryClient();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [settings] = useSettings();
|
||||
const { saveImage } = useImageStorage();
|
||||
@@ -91,7 +93,7 @@ export const useRemuxHlsToMp4 = () => {
|
||||
queryKey: ["downloadedItems"],
|
||||
});
|
||||
saveDownloadedItemInfo(item, stat.getSize());
|
||||
toast.success("Download completed");
|
||||
toast.success(t("home.downloads.toasts.download_completed"));
|
||||
}
|
||||
|
||||
setProcesses((prev) => {
|
||||
@@ -155,7 +157,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: () => {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user