fix: change to mmkv and fix downloads with VLC

This commit is contained in:
Fredrik Burmester
2024-11-24 19:34:49 +01:00
parent 335765993d
commit 93d117640a
12 changed files with 191 additions and 172 deletions

View File

@@ -1,12 +1,10 @@
import { useState, useCallback } from "react";
import AsyncStorage from "@react-native-async-storage/async-storage";
import * as FileSystem from "expo-file-system";
import { storage } from "@/utils/mmkv";
import { useCallback } from "react";
const useImageStorage = () => {
const saveBase64Image = useCallback(async (base64: string, key: string) => {
try {
// Save the base64 string to AsyncStorage
// Save the base64 string to storage
storage.set(key, base64);
} catch (error) {
console.error("Error saving image:", error);
@@ -69,7 +67,7 @@ const useImageStorage = () => {
const loadImage = useCallback(async (key: string) => {
try {
// Retrieve the base64 string from AsyncStorage
// Retrieve the base64 string from storage
const base64Image = storage.getString(key);
if (base64Image !== null) {
// Set the loaded image state

View File

@@ -1,21 +1,19 @@
import { useCallback } from "react";
import { useAtom, useAtomValue } from "jotai";
import AsyncStorage from "@react-native-async-storage/async-storage";
import * as FileSystem from "expo-file-system";
import { FFmpegKit, FFmpegKitConfig } from "ffmpeg-kit-react-native";
import { useDownload } from "@/providers/DownloadProvider";
import { apiAtom } from "@/providers/JellyfinProvider";
import { getItemImage } from "@/utils/getItemImage";
import { writeToLog } from "@/utils/log";
import {
BaseItemDto,
MediaSourceInfo,
} from "@jellyfin/sdk/lib/generated-client/models";
import { writeToLog } from "@/utils/log";
import { useQueryClient } from "@tanstack/react-query";
import { toast } from "sonner-native";
import { useDownload } from "@/providers/DownloadProvider";
import * as FileSystem from "expo-file-system";
import { useRouter } from "expo-router";
import { JobStatus } from "@/utils/optimize-server";
import { FFmpegKit, FFmpegKitConfig } from "ffmpeg-kit-react-native";
import { useAtomValue } from "jotai";
import { useCallback } from "react";
import { toast } from "sonner-native";
import useImageStorage from "./useImageStorage";
import { getItemImage } from "@/utils/getItemImage";
import { apiAtom } from "@/providers/JellyfinProvider";
/**
* Custom hook for remuxing HLS to MP4 using FFmpeg.