mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 18:13:25 +00:00
rework downloads
This commit is contained in:
@@ -5,8 +5,8 @@ import ContextMenu from "react-native-context-menu-view";
|
||||
import { TouchableOpacity } from "react-native-gesture-handler";
|
||||
import { Image, Text, View, XStack, YStack } from "tamagui";
|
||||
|
||||
import type { Download } from "~/contexts/DownloadManagerContext";
|
||||
import { useDownloadManager } from "~/contexts/DownloadManagerContext";
|
||||
import type { Download } from "~/hooks/useDownloadManager";
|
||||
import { useDownloadManager } from "~/hooks/useDownloadManager";
|
||||
import { MWProgress } from "./ui/Progress";
|
||||
import { FlashingText } from "./ui/Text";
|
||||
|
||||
@@ -57,9 +57,9 @@ export function DownloadItem(props: DownloadItemProps) {
|
||||
e: NativeSyntheticEvent<ContextMenuOnPressNativeEvent>,
|
||||
) => {
|
||||
if (e.nativeEvent.name === ContextMenuActions.Cancel) {
|
||||
void cancelDownload(props.item.id);
|
||||
void cancelDownload(props.item);
|
||||
} else if (e.nativeEvent.name === ContextMenuActions.Remove) {
|
||||
removeDownload(props.item.id);
|
||||
removeDownload(props.item);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -4,9 +4,9 @@ import { useCallback } from "react";
|
||||
import { Keyboard, TouchableOpacity } from "react-native";
|
||||
import ContextMenu from "react-native-context-menu-view";
|
||||
import { useRouter } from "expo-router";
|
||||
import { useToastController } from "@tamagui/toast";
|
||||
import { Image, Text, View } from "tamagui";
|
||||
|
||||
import { useToast } from "~/hooks/useToast";
|
||||
import { usePlayerStore } from "~/stores/player/store";
|
||||
import { useBookmarkStore, useWatchHistoryStore } from "~/stores/settings";
|
||||
|
||||
@@ -43,10 +43,10 @@ function checkReleased(media: ItemData): boolean {
|
||||
export default function Item({ data }: { data: ItemData }) {
|
||||
const resetVideo = usePlayerStore((state) => state.resetVideo);
|
||||
const router = useRouter();
|
||||
const toastController = useToastController();
|
||||
const { isBookmarked, addBookmark, removeBookmark } = useBookmarkStore();
|
||||
const { hasWatchHistoryItem, removeFromWatchHistory } =
|
||||
useWatchHistoryStore();
|
||||
const { showToast } = useToast();
|
||||
|
||||
const { title, type, year, posterUrl } = data;
|
||||
|
||||
@@ -54,10 +54,8 @@ export default function Item({ data }: { data: ItemData }) {
|
||||
|
||||
const handlePress = () => {
|
||||
if (!isReleased()) {
|
||||
toastController.show("This media is not released yet", {
|
||||
showToast("This media is not released yet", {
|
||||
burntOptions: { preset: "error" },
|
||||
native: true,
|
||||
duration: 500,
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -86,17 +84,13 @@ export default function Item({ data }: { data: ItemData }) {
|
||||
) => {
|
||||
if (e.nativeEvent.name === ContextMenuActions.Bookmark) {
|
||||
addBookmark(data);
|
||||
toastController.show("Added to bookmarks", {
|
||||
showToast("Added to bookmarks", {
|
||||
burntOptions: { preset: "done" },
|
||||
native: true,
|
||||
duration: 500,
|
||||
});
|
||||
} else if (e.nativeEvent.name === ContextMenuActions.RemoveBookmark) {
|
||||
removeBookmark(data);
|
||||
toastController.show("Removed from bookmarks", {
|
||||
showToast("Removed from bookmarks", {
|
||||
burntOptions: { preset: "done" },
|
||||
native: true,
|
||||
duration: 500,
|
||||
});
|
||||
} else if (e.nativeEvent.name === ContextMenuActions.Download) {
|
||||
router.push({
|
||||
@@ -107,10 +101,8 @@ export default function Item({ data }: { data: ItemData }) {
|
||||
e.nativeEvent.name === ContextMenuActions.RemoveWatchHistoryItem
|
||||
) {
|
||||
removeFromWatchHistory(data);
|
||||
toastController.show("Removed from Continue Watching", {
|
||||
showToast("Removed from Continue Watching", {
|
||||
burntOptions: { preset: "done" },
|
||||
native: true,
|
||||
duration: 500,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@@ -2,7 +2,6 @@ import type { LanguageCode } from "iso-639-1";
|
||||
import type { ContentCaption } from "subsrt-ts/dist/types/handler";
|
||||
import { useState } from "react";
|
||||
import { MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
|
||||
import { useToastController } from "@tamagui/toast";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { parse } from "subsrt-ts";
|
||||
import { Spinner, useTheme, View } from "tamagui";
|
||||
@@ -10,6 +9,7 @@ import { Spinner, useTheme, View } from "tamagui";
|
||||
import type { Stream } from "@movie-web/provider-utils";
|
||||
|
||||
import type { CaptionWithData } from "~/stores/captions";
|
||||
import { useToast } from "~/hooks/useToast";
|
||||
import {
|
||||
getCountryCodeFromLanguage,
|
||||
getPrettyLanguageNameFromLocale,
|
||||
@@ -35,7 +35,7 @@ const parseCaption = async (
|
||||
};
|
||||
|
||||
export const CaptionsSelector = () => {
|
||||
const toast = useToastController();
|
||||
const { showToast } = useToast();
|
||||
const theme = useTheme();
|
||||
const [open, setOpen] = useState(false);
|
||||
const captions = usePlayerStore(
|
||||
@@ -97,11 +97,7 @@ export const CaptionsSelector = () => {
|
||||
fontWeight="bold"
|
||||
chromeless
|
||||
onPress={() => {
|
||||
toast.show("Work in progress", {
|
||||
burntOptions: { preset: "none" },
|
||||
native: true,
|
||||
duration: 500,
|
||||
});
|
||||
showToast("Work in progress");
|
||||
}}
|
||||
>
|
||||
Customize
|
||||
|
@@ -3,7 +3,7 @@ import { useTheme } from "tamagui";
|
||||
|
||||
import { findHighestQuality } from "@movie-web/provider-utils";
|
||||
|
||||
import { useDownloadManager } from "~/contexts/DownloadManagerContext";
|
||||
import { useDownloadManager } from "~/hooks/useDownloadManager";
|
||||
import { convertMetaToScrapeMedia } from "~/lib/meta";
|
||||
import { usePlayerStore } from "~/stores/player/store";
|
||||
import { MWButton } from "../ui/Button";
|
||||
|
@@ -18,9 +18,9 @@ import {
|
||||
import type { ItemData } from "../item/item";
|
||||
import type { AudioTrack } from "./AudioTrackSelector";
|
||||
import type { PlayerMeta } from "~/stores/player/slices/video";
|
||||
import { useDownloadManager } from "~/contexts/DownloadManagerContext";
|
||||
import { useMeta } from "~/hooks/player/useMeta";
|
||||
import { useScrape } from "~/hooks/player/useSourceScrape";
|
||||
import { useDownloadManager } from "~/hooks/useDownloadManager";
|
||||
import { convertMetaToScrapeMedia } from "~/lib/meta";
|
||||
import { PlayerStatus } from "~/stores/player/slices/interface";
|
||||
import { usePlayerStore } from "~/stores/player/store";
|
||||
|
Reference in New Issue
Block a user