Revert "Merge branch 'develop' into chore/expo-52"

This reverts commit 933f3f2f7c, reversing
changes made to f92fee4158.
This commit is contained in:
Fredrik Burmester
2025-01-23 11:34:22 +01:00
parent 933f3f2f7c
commit d5c634b74b
176 changed files with 3718 additions and 6122 deletions

View File

@@ -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 { useHaptic } from "./useHaptic";
import * as Haptics from "expo-haptics";
interface CreditTimestamps {
Introduction: {
@@ -29,7 +29,6 @@ export const useCreditSkipper = (
) => {
const [api] = useAtom(apiAtom);
const [showSkipCreditButton, setShowSkipCreditButton] = useState(false);
const lightHapticFeedback = useHaptic("light");
if (isVlc) {
currentTime = msToSeconds(currentTime);
@@ -80,7 +79,7 @@ export const useCreditSkipper = (
if (!creditTimestamps) return;
console.log(`Skipping credits to ${creditTimestamps.Credits.End}`);
try {
lightHapticFeedback();
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
wrappedSeek(creditTimestamps.Credits.End);
setTimeout(() => {
play();

View File

@@ -6,7 +6,7 @@ import {
} from "@jellyfin/sdk/lib/generated-client";
import { useMemo } from "react";
// Used only for initial play settings.
// Used only for intial play settings.
const useDefaultPlaySettings = (
item: BaseItemDto,
settings: Settings | null

View File

@@ -1,54 +0,0 @@
import { useCallback, useMemo } from "react";
import { Platform } from "react-native";
import * as Haptics from "expo-haptics";
import { useSettings } from "@/utils/atoms/settings";
export type HapticFeedbackType =
| "light"
| "medium"
| "heavy"
| "selection"
| "success"
| "warning"
| "error";
export const useHaptic = (feedbackType: HapticFeedbackType = "selection") => {
const [settings] = useSettings();
const createHapticHandler = useCallback(
(type: Haptics.ImpactFeedbackStyle) => {
return Platform.OS === "web" ? () => {} : () => Haptics.impactAsync(type);
},
[]
);
const createNotificationFeedback = useCallback(
(type: Haptics.NotificationFeedbackType) => {
return Platform.OS === "web"
? () => {}
: () => 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" ? () => {} : 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];
};

View File

@@ -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 { useHaptic } from "./useHaptic";
import * as Haptics from "expo-haptics";
interface IntroTimestamps {
EpisodeId: string;
@@ -33,7 +33,6 @@ export const useIntroSkipper = (
if (isVlc) {
currentTime = msToSeconds(currentTime);
}
const lightHapticFeedback = useHaptic("light");
const wrappedSeek = (seconds: number) => {
if (isVlc) {
@@ -79,7 +78,7 @@ export const useIntroSkipper = (
const skipIntro = useCallback(() => {
if (!introTimestamps) return;
try {
lightHapticFeedback();
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
wrappedSeek(introTimestamps.IntroEnd);
setTimeout(() => {
play();

View File

@@ -1,106 +0,0 @@
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,
};
};

View File

@@ -28,18 +28,6 @@ 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;
@@ -67,29 +55,19 @@ export enum Endpoints {
API_V1 = "/api/v1",
SEARCH = "/search",
REQUEST = "/request",
PERSON = "/person",
COMBINED_CREDITS = "/combined_credits",
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;
@@ -135,7 +113,7 @@ export class JellyseerrApi {
if (inRange(status, 200, 299)) {
if (data.version < "2.0.0") {
const error =
t("jellyseerr.toasts.jellyseer_does_not_meet_requirements");
"Jellyseerr server does not meet minimum version requirements! Please update to at least 2.0.0";
toast.error(error);
throw Error(error);
}
@@ -149,7 +127,7 @@ export class JellyseerrApi {
requiresPass: true,
};
}
toast.error(t("jellyseerr.toasts.jellyseerr_test_failed"));
toast.error(`Jellyseerr test failed. Please try again.`);
writeErrorLog(
`Jellyseerr returned a ${status} for url:\n` +
response.config.url +
@@ -162,7 +140,7 @@ export class JellyseerrApi {
};
})
.catch((e) => {
const msg = t("jellyseerr.toasts.failed_to_test_jellyseerr_server_url");
const msg = "Failed to test jellyseerr server url";
toast.error(msg);
console.error(msg, e);
return {
@@ -196,7 +174,7 @@ export class JellyseerrApi {
}
async discover(
endpoint: DiscoverEndpoint | string,
endpoint: DiscoverEndpoint,
params: any
): Promise<SearchResults> {
return this.axios
@@ -204,15 +182,6 @@ 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,
@@ -235,27 +204,6 @@ export class JellyseerrApi {
});
}
async personDetails(id: number | string): Promise<PersonDetails> {
return this.axios
?.get<PersonDetails>(Endpoints.API_V1 + Endpoints.PERSON + `/${id}`)
.then((response) => {
return response?.data;
});
}
async personCombinedCredits(id: number | string): Promise<CombinedCredit> {
return this.axios
?.get<CombinedCredit>(
Endpoints.API_V1 +
Endpoints.PERSON +
`/${id}` +
Endpoints.COMBINED_CREDITS
)
.then((response) => {
return response?.data;
});
}
async movieRatings(id: number) {
return this.axios
?.get<RTRating>(
@@ -290,26 +238,14 @@ 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,
filter: string = "original",
width: number = 1920,
quality: number = 75
) {
return path
? this.axios.defaults.baseURL +
`/_next/image?` +
new URLSearchParams(
`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`;
tvStillImageProxy(path: string, width: number = 1920, quality: number = 75) {
return (
this.axios.defaults.baseURL +
`/_next/image?` +
new URLSearchParams(
`url=https://image.tmdb.org/t/p/original/${path}&w=${width}&q=${quality}`
).toString()
);
}
async submitIssue(mediaId: number, issueType: IssueType, message: string) {
@@ -323,24 +259,12 @@ export class JellyseerrApi {
const issue = response.data;
if (issue.status === IssueStatus.OPEN) {
toast.success(t("jellyseerr.toasts.issue_submitted"));
toast.success("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) => {
@@ -397,7 +321,6 @@ const jellyseerrUserAtom = atom(storage.get<JellyseerrUser>(JELLYSEERR_USER));
export const useJellyseerr = () => {
const [jellyseerrUser, setJellyseerrUser] = useAtom(jellyseerrUserAtom);
const [settings, updateSettings] = useSettings();
const queryClient = useQueryClient();
const jellyseerrApi = useMemo(() => {
const cookies = storage.get<string[]>(JELLYSEERR_COOKIES);
@@ -415,22 +338,18 @@ export const useJellyseerr = () => {
const requestMedia = useCallback(
(title: string, request: MediaRequestBody, onSuccess?: () => void) => {
jellyseerrApi?.request?.(request)?.then(async (mediaRequest) => {
await queryClient.invalidateQueries({
queryKey: ["search", "jellyseerr"],
});
jellyseerrApi?.request?.(request)?.then((mediaRequest) => {
switch (mediaRequest.status) {
case MediaRequestStatus.PENDING:
case MediaRequestStatus.APPROVED:
toast.success(t("jellyseerr.toasts.requested_item", {item: title}));
toast.success(`Requested ${title}!`);
onSuccess?.()
break;
case MediaRequestStatus.DECLINED:
toast.error(t("jellyseerr.toasts.you_dont_have_permission_to_request"));
toast.error(`You don't have permission to request!`);
break;
case MediaRequestStatus.FAILED:
toast.error(t("jellyseerr.toasts.something_went_wrong_requesting_media"));
toast.error(`Something went wrong requesting media!`);
break;
}
});

View File

@@ -3,14 +3,13 @@ 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 { useHaptic } from "./useHaptic";
import * as Haptics from "expo-haptics";
import { useAtom } from "jotai";
export const useMarkAsPlayed = (item: BaseItemDto) => {
const [api] = useAtom(apiAtom);
const [user] = useAtom(userAtom);
const queryClient = useQueryClient();
const lightHapticFeedback = useHaptic("light");
const invalidateQueries = () => {
const queriesToInvalidate = [
@@ -30,7 +29,7 @@ export const useMarkAsPlayed = (item: BaseItemDto) => {
};
const markAsPlayedStatus = async (played: boolean) => {
lightHapticFeedback();
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
// Optimistic update
queryClient.setQueryData(

View File

@@ -7,9 +7,7 @@ export const useOrientationSettings = () => {
useEffect(() => {
if (settings?.autoRotate) {
ScreenOrientation.lockAsync(
ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT
);
// Don't need to do anything
} else if (settings?.defaultVideoOrientation) {
ScreenOrientation.lockAsync(settings.defaultVideoOrientation);
}

View File

@@ -18,7 +18,6 @@ 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
@@ -50,7 +49,6 @@ export const useRemuxHlsToMp4 = () => {
const api = useAtomValue(apiAtom);
const router = useRouter();
const queryClient = useQueryClient();
const { t } = useTranslation();
const [settings] = useSettings();
const { saveImage } = useImageStorage();
@@ -86,7 +84,7 @@ export const useRemuxHlsToMp4 = () => {
queryKey: ["downloadedItems"],
});
saveDownloadedItemInfo(item, stat.getSize());
toast.success(t("home.downloads.toasts.download_completed"));
toast.success("Download completed");
}
setProcesses((prev) => {
@@ -146,7 +144,7 @@ export const useRemuxHlsToMp4 = () => {
// First lets save any important assets we want to present to the user offline
await onSaveAssets(api, item);
toast.success(t("home.downloads.toasts.download_started_for", {item: item.Name}), {
toast.success(`Download started for ${item.Name}`, {
action: {
label: "Go to download",
onClick: () => {

View File

@@ -2,7 +2,6 @@ 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;
@@ -19,7 +18,6 @@ export const useWebSocket = ({
}: UseWebSocketProps) => {
const router = useRouter();
const { ws } = useWebSocketContext();
const { t } = useTranslation();
useEffect(() => {
if (!ws) return;
@@ -42,7 +40,7 @@ export const useWebSocket = ({
console.log("Command ~ DisplayMessage");
const title = json?.Data?.Arguments?.Header;
const body = json?.Data?.Arguments?.Text;
Alert.alert(t("player.message_from_server", {message: title}), body);
Alert.alert("Message from server: " + title, body);
}
};