Minor Tracker Fixes
This commit is contained in:
+2
-1
@@ -8,6 +8,7 @@ npm-debug.*
|
||||
*.mobileprovision
|
||||
*.orig.*
|
||||
web-build/
|
||||
.env
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
@@ -76,4 +77,4 @@ web-build/
|
||||
src/sources/en/generators/
|
||||
|
||||
# jenv
|
||||
.java-version
|
||||
.java-version
|
||||
|
||||
@@ -9,6 +9,7 @@ interface ListItemProps {
|
||||
title: string;
|
||||
description?: string | null;
|
||||
icon?: string;
|
||||
right?: string;
|
||||
onPress?: () => void;
|
||||
theme: ThemeColors;
|
||||
}
|
||||
@@ -35,6 +36,7 @@ const Item: React.FC<ListItemProps> = ({
|
||||
icon,
|
||||
onPress,
|
||||
theme,
|
||||
right,
|
||||
}) => (
|
||||
<PaperList.Item
|
||||
title={title}
|
||||
@@ -52,6 +54,17 @@ const Item: React.FC<ListItemProps> = ({
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
right={
|
||||
right
|
||||
? () => (
|
||||
<PaperList.Icon
|
||||
color={theme.primary}
|
||||
icon={right}
|
||||
style={styles.iconCtn}
|
||||
/>
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
onPress={onPress}
|
||||
rippleColor={theme.rippleColor}
|
||||
style={styles.listItemCtn}
|
||||
|
||||
@@ -85,17 +85,10 @@ const usePosition = (novelId, chapterId) => {
|
||||
return position;
|
||||
};
|
||||
|
||||
const useTrackingStatus = () => {
|
||||
const tracker = useSelector(state => state.trackerReducer);
|
||||
|
||||
return tracker;
|
||||
};
|
||||
|
||||
export {
|
||||
useSettings,
|
||||
usePreferences,
|
||||
useContinueReading,
|
||||
useTrackingStatus,
|
||||
useNovel,
|
||||
useChapter,
|
||||
useSavedSettings,
|
||||
|
||||
@@ -25,3 +25,6 @@ export const useDownloadQueue = () =>
|
||||
|
||||
export const useSourcesReducer = () =>
|
||||
useAppSelector((state: RootState) => state.sourceReducerV2);
|
||||
|
||||
export const useTrackerReducer = () =>
|
||||
useAppSelector(state => state.trackerReducer);
|
||||
|
||||
@@ -59,6 +59,7 @@ import useBoolean from '@hooks/useBoolean';
|
||||
import { useCategorySettings } from '@hooks/useSettings';
|
||||
import { openChapter } from '../../utils/handleNavigateParams';
|
||||
import NovelScreenLoading from './components/LoadingAnimation/NovelScreenLoading';
|
||||
import { useTrackerReducer } from '@redux/hooks';
|
||||
|
||||
const Novel = ({ route, navigation }) => {
|
||||
const item = route.params;
|
||||
@@ -71,6 +72,7 @@ const Novel = ({ route, navigation }) => {
|
||||
|
||||
const { novel, chapters, loading, updating } = useNovel();
|
||||
const { downloadQueue } = useSelector(state => state.downloadsReducer);
|
||||
const { tracker } = useTrackerReducer();
|
||||
|
||||
const [selected, setSelected] = useState([]);
|
||||
const [downloadMenu, showDownloadMenu] = useState(false);
|
||||
@@ -713,12 +715,14 @@ const Novel = ({ route, navigation }) => {
|
||||
filter={filter}
|
||||
showChapterTitles={showChapterTitles}
|
||||
/>
|
||||
<TrackSheet
|
||||
bottomSheetRef={trackerSheetRef}
|
||||
novelId={novel.novelId}
|
||||
novelName={novel.novelName}
|
||||
theme={theme}
|
||||
/>
|
||||
{tracker ? (
|
||||
<TrackSheet
|
||||
bottomSheetRef={trackerSheetRef}
|
||||
novelId={novel.novelId}
|
||||
novelName={novel.novelName}
|
||||
theme={theme}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
</Provider>
|
||||
);
|
||||
|
||||
@@ -3,7 +3,8 @@ import { StyleSheet, View, ToastAndroid } from 'react-native';
|
||||
import { overlay, Portal } from 'react-native-paper';
|
||||
import BottomSheet from '@components/BottomSheet/BottomSheet';
|
||||
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useTrackerReducer } from '@redux/hooks';
|
||||
import { updateTracker } from '../../../../redux/tracker/tracker.actions';
|
||||
|
||||
import TrackSearchDialog from './TrackSearchDialog';
|
||||
@@ -13,10 +14,7 @@ import SetTrackChaptersDialog from './SetTrackChaptersDialog';
|
||||
import { AddTrackingCard, TrackedItemCard } from './TrackerCards';
|
||||
|
||||
const TrackSheet = ({ bottomSheetRef, novelId, novelName, theme }) => {
|
||||
const tracker = useSelector(state => state.trackerReducer.tracker);
|
||||
const trackedNovels = useSelector(
|
||||
state => state.trackerReducer.trackedNovels,
|
||||
);
|
||||
const { tracker, trackedNovels } = useTrackerReducer();
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const [trackItem, setTrackItem] = useState();
|
||||
|
||||
@@ -12,11 +12,9 @@ import {
|
||||
} from '../../database/queries/ChapterQueries';
|
||||
import { fetchChapter } from '../../services/Source/source';
|
||||
import { showToast } from '../../hooks/showToast';
|
||||
import {
|
||||
usePosition,
|
||||
useSettings,
|
||||
useTrackingStatus,
|
||||
} from '../../hooks/reduxHooks';
|
||||
import { usePosition, useSettings } from '../../hooks/reduxHooks';
|
||||
import { useTrackerReducer } from '@redux/hooks';
|
||||
|
||||
import { useTheme } from '@hooks/useTheme';
|
||||
import { updateChaptersRead } from '../../redux/tracker/tracker.actions';
|
||||
import { markChapterReadAction } from '../../redux/novel/novel.actions';
|
||||
@@ -98,7 +96,7 @@ const ChapterContent = ({ route, navigation }) => {
|
||||
const position = usePosition(novelId, chapterId);
|
||||
const minScroll = useRef(0);
|
||||
|
||||
const { tracker, trackedNovels } = useTrackingStatus();
|
||||
const { tracker, trackedNovels } = useTrackerReducer();
|
||||
const isTracked = trackedNovels.find(obj => obj.novelId === novelId);
|
||||
|
||||
const [chapter, setChapter] = useState({});
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from './index';
|
||||
|
||||
const apiEndpoint = 'https://graphql.anilist.co';
|
||||
const clientId = '9085';
|
||||
const clientId = process.env.ANILIST_CLIENT_ID;
|
||||
const authUrl = `https://anilist.co/api/v2/oauth/authorize?client_id=${clientId}&response_type=token`;
|
||||
const redirectUri = Linking.createURL('');
|
||||
const searchQuery = `query($search: String) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as WebBrowser from 'expo-web-browser';
|
||||
import qs from 'qs';
|
||||
import { createTracker, type UserListStatus } from './index';
|
||||
|
||||
const clientId = 'd2f499825d64b0213bb77e78193ccbb1';
|
||||
const clientId = process.env.MYANIMELIST_CLIENT_ID;
|
||||
const baseOAuthUrl = 'https://myanimelist.net/v1/oauth2/authorize';
|
||||
const tokenUrl = 'https://myanimelist.net/v1/oauth2/token';
|
||||
const baseApiUrl = 'https://api.myanimelist.net/v2';
|
||||
@@ -110,6 +110,7 @@ export const myAnimeListTracker = createTracker('MyAnimeList', {
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.accessToken}`,
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -122,7 +123,7 @@ export const myAnimeListTracker = createTracker('MyAnimeList', {
|
||||
};
|
||||
},
|
||||
updateUserListEntry: async (id, payload, auth) => {
|
||||
let status = normalizedToMal[payload.status];
|
||||
let status = normalizedToMal[payload.status] || normalizedToMal.CURRENT;
|
||||
let repeating = false;
|
||||
if (status.includes(';')) {
|
||||
const split = status.split(';');
|
||||
@@ -135,6 +136,7 @@ export const myAnimeListTracker = createTracker('MyAnimeList', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.accessToken}`,
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: qs.stringify({
|
||||
status,
|
||||
|
||||
Reference in New Issue
Block a user