From 00b9b731704ec5994d3a6939618ff6cf2fb62b3a Mon Sep 17 00:00:00 2001 From: paregi12 Date: Sun, 18 Jan 2026 10:22:49 +0530 Subject: [PATCH] fix: resolve syntax/type errors and player navigation issue --- src/components/calendar/CalendarSection.tsx | 10 ++------- src/components/home/ThisWeekSection.tsx | 3 ++- src/hooks/useCalendarData.ts | 24 +++----------------- src/screens/CalendarScreen.tsx | 25 +-------------------- src/screens/MalSettingsScreen.tsx | 2 +- src/screens/streams/useStreamsScreen.ts | 2 +- src/services/mal/MalApi.ts | 2 +- src/services/mal/MalSync.ts | 2 +- src/types/calendar.ts | 23 +++++++++++++++++++ 9 files changed, 35 insertions(+), 58 deletions(-) create mode 100644 src/types/calendar.ts diff --git a/src/components/calendar/CalendarSection.tsx b/src/components/calendar/CalendarSection.tsx index 671a963a..af3699c3 100644 --- a/src/components/calendar/CalendarSection.tsx +++ b/src/components/calendar/CalendarSection.tsx @@ -13,17 +13,12 @@ import { useTranslation } from 'react-i18next'; import { format, addMonths, subMonths, startOfMonth, endOfMonth, eachDayOfInterval, isSameMonth, isToday, isSameDay } from 'date-fns'; import Animated, { FadeIn } from 'react-native-reanimated'; import { useTheme } from '../../contexts/ThemeContext'; +import { CalendarEpisode } from '../../types/calendar'; const { width } = Dimensions.get('window'); const COLUMN_COUNT = 7; // 7 days in a week const DAY_ITEM_SIZE = (width - 32 - 56) / 7; // Slightly smaller than 1/7 to fit all days -interface CalendarEpisode { - id: string; - releaseDate: string; - // Other properties can be included but aren't needed for the calendar -} - interface DayItemProps { date: Date; isCurrentMonth: boolean; @@ -45,8 +40,7 @@ const DayItem = ({ isSelected, hasEvents, onPress -}: DayItemProps) => { - const { currentTheme } = useTheme(); +}: DayItemProps) => { const { currentTheme } = useTheme(); return ( { // Sort episodes by release date with error handling allEpisodes.sort((a, b) => { try { + if (!a.releaseDate) return 1; + if (!b.releaseDate) return -1; const dateA = new Date(a.releaseDate).getTime(); const dateB = new Date(b.releaseDate).getTime(); return dateA - dateB; diff --git a/src/screens/CalendarScreen.tsx b/src/screens/CalendarScreen.tsx index f0a6b5cd..8117bf82 100644 --- a/src/screens/CalendarScreen.tsx +++ b/src/screens/CalendarScreen.tsx @@ -33,34 +33,11 @@ import { memoryManager } from '../utils/memoryManager'; import { useCalendarData } from '../hooks/useCalendarData'; import { AniListService } from '../services/anilist/AniListService'; import { AniListAiringSchedule } from '../services/anilist/types'; +import { CalendarEpisode, CalendarSection } from '../types/calendar'; const { width } = Dimensions.get('window'); const ANDROID_STATUSBAR_HEIGHT = StatusBar.currentHeight || 0; -interface CalendarEpisode { - id: string; - seriesId: string; - title: string; - seriesName: string; - poster: string; - releaseDate: string | null; - season: number; - episode: number; - overview: string; - vote_average: number; - still_path: string | null; - season_poster_path: string | null; - // MAL specific - day?: string; - time?: string; - genres?: string[]; -} - -interface CalendarSection { - title: string; - data: CalendarEpisode[]; -} - const CalendarScreen = () => { const { t } = useTranslation(); const navigation = useNavigation>(); diff --git a/src/screens/MalSettingsScreen.tsx b/src/screens/MalSettingsScreen.tsx index 79e4729f..e4b1cbc2 100644 --- a/src/screens/MalSettingsScreen.tsx +++ b/src/screens/MalSettingsScreen.tsx @@ -273,7 +273,7 @@ const MalSettingsScreen: React.FC = () => { Auto Episode Update - Automatically update your progress on MAL when you finish watching an episode (>=90% completion). + Automatically update your progress on MAL when you finish watching an episode (>=90% completion). { const streamsToPass = selectedEpisode ? episodeStreams : groupedStreams; const streamName = stream.name || stream.title || 'Unnamed Stream'; const streamProvider = stream.addonId || stream.addonName || stream.name; + const releaseDate = type === 'movie' ? metadata?.released : currentEpisode?.air_date; // Save stream to cache try { @@ -367,7 +368,6 @@ export const useStreamsScreen = () => { const season = (type === 'series' || type === 'other') ? currentEpisode?.season_number : undefined; const episode = (type === 'series' || type === 'other') ? currentEpisode?.episode_number : undefined; const episodeTitle = (type === 'series' || type === 'other') ? currentEpisode?.name : undefined; - const releaseDate = type === 'movie' ? metadata?.released : currentEpisode?.air_date; await streamCacheService.saveStreamToCache( id, diff --git a/src/services/mal/MalApi.ts b/src/services/mal/MalApi.ts index 3c4cdcf8..32950288 100644 --- a/src/services/mal/MalApi.ts +++ b/src/services/mal/MalApi.ts @@ -99,7 +99,7 @@ export const MalApiService = { } }, - getMyListStatus: async (malId: number): Promise<{ list_status?: any; num_episodes: number }> => { + getMyListStatus: async (malId: number): Promise<{ my_list_status?: any; num_episodes: number }> => { try { const response = await api.get(`/anime/${malId}`, { params: { fields: 'my_list_status,num_episodes' } diff --git a/src/services/mal/MalSync.ts b/src/services/mal/MalSync.ts index 5032ca4c..0ca04df7 100644 --- a/src/services/mal/MalSync.ts +++ b/src/services/mal/MalSync.ts @@ -1,6 +1,6 @@ import { mmkvStorage } from '../mmkvStorage'; import { MalApiService } from './MalApi'; -import { MalListStatus } from '../../types/mal'; +import { MalListStatus, MalAnimeNode } from '../../types/mal'; import { catalogService } from '../catalogService'; import { ArmSyncService } from './ArmSyncService'; import axios from 'axios'; diff --git a/src/types/calendar.ts b/src/types/calendar.ts new file mode 100644 index 00000000..0065b2e2 --- /dev/null +++ b/src/types/calendar.ts @@ -0,0 +1,23 @@ +export interface CalendarEpisode { + id: string; + seriesId: string; + title: string; + seriesName: string; + poster: string; + releaseDate: string | null; + season: number; + episode: number; + overview: string; + vote_average: number; + still_path: string | null; + season_poster_path: string | null; + // MAL specific + day?: string; + time?: string; + genres?: string[]; +} + +export interface CalendarSection { + title: string; + data: CalendarEpisode[]; +} \ No newline at end of file