mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 12:33:26 +00:00
Fix year NaN, no longer open unreleased
This commit is contained in:
@@ -12,10 +12,5 @@ class CheckIosCertificateModule : Module() {
|
||||
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
||||
// The module will be accessible from `requireNativeModule('CheckIosCertificate')` in JavaScript.
|
||||
Name("CheckIosCertificate")
|
||||
|
||||
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
||||
Function("hello") {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -64,8 +64,6 @@ const DownloadsScreen: React.FC = () => {
|
||||
},
|
||||
};
|
||||
|
||||
console.log(isDevelopmentProvisioningProfile());
|
||||
|
||||
return (
|
||||
<ScreenLayout>
|
||||
<YStack gap={2} style={{ padding: 10 }}>
|
||||
|
@@ -150,6 +150,9 @@ async function fetchSearchResults(query: string): Promise<ItemData[]> {
|
||||
id: result.id.toString(),
|
||||
title: result.media_type === "tv" ? result.name : result.title,
|
||||
posterUrl: getMediaPoster(result.poster_path),
|
||||
release_date: new Date(
|
||||
result.media_type === "tv" ? result.first_air_date : result.release_date,
|
||||
),
|
||||
year: new Date(
|
||||
result.media_type === "tv" ? result.first_air_date : result.release_date,
|
||||
).getFullYear(),
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import type { NativeSyntheticEvent } from "react-native";
|
||||
import type { ContextMenuOnPressNativeEvent } from "react-native-context-menu-view";
|
||||
import { useCallback } from "react";
|
||||
import { Keyboard, TouchableOpacity } from "react-native";
|
||||
import ContextMenu from "react-native-context-menu-view";
|
||||
import { useRouter } from "expo-router";
|
||||
@@ -14,9 +15,31 @@ export interface ItemData {
|
||||
title: string;
|
||||
type: "movie" | "tv";
|
||||
year: number;
|
||||
release_date?: Date;
|
||||
posterUrl: string;
|
||||
}
|
||||
|
||||
enum ContextMenuActions {
|
||||
Bookmark = "Bookmark",
|
||||
RemoveBookmark = "Remove Bookmark",
|
||||
Download = "Download",
|
||||
RemoveWatchHistoryItem = "Remove from Continue Watching",
|
||||
}
|
||||
|
||||
function checkReleased(media: ItemData): boolean {
|
||||
const isReleasedYear = Boolean(
|
||||
media.year && media.year <= new Date().getFullYear(),
|
||||
);
|
||||
const isReleasedDate = Boolean(
|
||||
media.release_date && media.release_date <= new Date(),
|
||||
);
|
||||
|
||||
// If the media has a release date, use that, otherwise use the year
|
||||
const isReleased = media.release_date ? isReleasedDate : isReleasedYear;
|
||||
|
||||
return isReleased;
|
||||
}
|
||||
|
||||
export default function Item({ data }: { data: ItemData }) {
|
||||
const resetVideo = usePlayerStore((state) => state.resetVideo);
|
||||
const router = useRouter();
|
||||
@@ -27,7 +50,17 @@ export default function Item({ data }: { data: ItemData }) {
|
||||
|
||||
const { title, type, year, posterUrl } = data;
|
||||
|
||||
const isReleased = useCallback(() => checkReleased(data), [data]);
|
||||
|
||||
const handlePress = () => {
|
||||
if (!isReleased()) {
|
||||
toastController.show("This media is not released yet", {
|
||||
burntOptions: { preset: "error" },
|
||||
native: true,
|
||||
duration: 500,
|
||||
});
|
||||
return;
|
||||
}
|
||||
resetVideo();
|
||||
Keyboard.dismiss();
|
||||
router.push({
|
||||
@@ -36,13 +69,6 @@ export default function Item({ data }: { data: ItemData }) {
|
||||
});
|
||||
};
|
||||
|
||||
enum ContextMenuActions {
|
||||
Bookmark = "Bookmark",
|
||||
RemoveBookmark = "Remove Bookmark",
|
||||
Download = "Download",
|
||||
RemoveWatchHistoryItem = "Remove from Continue Watching",
|
||||
}
|
||||
|
||||
const contextMenuActions = [
|
||||
{
|
||||
title: isBookmarked(data)
|
||||
@@ -112,12 +138,17 @@ export default function Item({ data }: { data: ItemData }) {
|
||||
{title}
|
||||
</Text>
|
||||
<View flexDirection="row" alignItems="center" gap={3}>
|
||||
<Text fontSize={12} color="gray">
|
||||
<Text fontSize={12} color="$ash100">
|
||||
{type === "tv" ? "Show" : "Movie"}
|
||||
</Text>
|
||||
<View height={1} width={1} borderRadius={24} backgroundColor="gray" />
|
||||
<Text fontSize={12} color="gray">
|
||||
{year}
|
||||
<View
|
||||
height={8}
|
||||
width={8}
|
||||
borderRadius={24}
|
||||
backgroundColor="$ash100"
|
||||
/>
|
||||
<Text fontSize={12} color="$ash100">
|
||||
{isReleased() ? year : "Unreleased"}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import { Input, styled } from "tamagui";
|
||||
|
||||
export const MWInput = styled(Input, {
|
||||
fontWeight: "$semibold",
|
||||
|
||||
variants: {
|
||||
type: {
|
||||
default: {
|
||||
|
Reference in New Issue
Block a user