Minor fixes

Closes #373
Closes #374
This commit is contained in:
Rajarshee Chatterjee
2022-08-15 16:51:21 +05:30
parent 87fa081cfd
commit 66798c46db
7 changed files with 57 additions and 23 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ export const getLibraryNovelsFromDb = (
let getLibraryNovelsQuery = 'SELECT * FROM novels WHERE followed = 1';
if (onlyOngoingNovels) {
getLibraryNovelsQuery += ' AND status NOT LIKE "Completed"';
getLibraryNovelsQuery += " AND status NOT LIKE 'Completed'";
}
return new Promise(resolve =>
+4 -1
View File
@@ -19,7 +19,7 @@ export const getCategoryNovelsFromDb = async (
*
FROM
novels
WHERE
WHERE (
categoryIds LIKE '[${categoryId}]'
OR
categoryIds LIKE '[${categoryId},%'
@@ -27,6 +27,9 @@ export const getCategoryNovelsFromDb = async (
categoryIds LIKE '%,${categoryId}]'
OR
categoryIds LIKE '%,${categoryId},%'
)
AND
followed = 1
`;
if (onlyOngoingNovels) {
+10
View File
@@ -0,0 +1,10 @@
import { useEffect } from 'react';
import { BackHandler } from 'react-native';
export function useBackHandler(handler: () => boolean) {
useEffect(() => {
BackHandler.addEventListener('hardwareBackPress', handler);
return () => BackHandler.removeEventListener('hardwareBackPress', handler);
}, [handler]);
}
+11
View File
@@ -28,11 +28,16 @@ import MigrateNovel from '../screens/browse/migration/MigrationNovels';
import MalTopNovels from '../screens/browse/discover/MalTopNovels';
import NewUpdateDialog from '../components/NewUpdateDialog';
import BrowseSettings from '../screens/browse/BrowseSettings';
import { useAppDispatch } from '@redux/hooks';
import { updateLibraryAction } from '@redux/updates/updates.actions';
import { useSettings } from '@hooks/reduxHooks';
const Stack = createStackNavigator();
const MainNavigator = () => {
const theme = useTheme();
const dispatch = useAppDispatch();
const { updateLibraryOnLaunch = false } = useSettings();
useEffect(() => {
const timer = setTimeout(async () => {
@@ -45,6 +50,12 @@ const MainNavigator = () => {
};
}, [theme.id]);
useEffect(() => {
if (updateLibraryOnLaunch) {
dispatch(updateLibraryAction());
}
}, []);
const { isNewVersion, latestRelease } = useGithubUpdateChecker() || {};
return (
+17 -17
View File
@@ -3,23 +3,23 @@ import { SET_LAST_UPDATE_TIME } from './updates.types';
import { showToast } from '../../hooks/showToast';
import { updateLibrary } from '../../services/updates/updates';
export const updateLibraryAction =
({ categoryId }) =>
async (dispatch, getState) => {
showToast('Updating library');
export const updateLibraryAction = props => async (dispatch, getState) => {
showToast('Updating library');
dispatch({ type: SET_LAST_UPDATE_TIME, payload: Date.now() });
dispatch({ type: SET_LAST_UPDATE_TIME, payload: Date.now() });
const {
downloadNewChapters = false,
onlyUpdateOngoingNovels = false,
refreshNovelMetadata = false,
} = getState().settingsReducer;
const {
downloadNewChapters = false,
onlyUpdateOngoingNovels = false,
refreshNovelMetadata = false,
} = getState().settingsReducer;
await updateLibrary({
downloadNewChapters,
onlyUpdateOngoingNovels,
refreshNovelMetadata,
categoryId,
});
};
const categoryId = props?.categoryId;
await updateLibrary({
downloadNewChapters,
onlyUpdateOngoingNovels,
refreshNovelMetadata,
categoryId,
});
};
+10
View File
@@ -31,6 +31,7 @@ import SetCategoryModal from '@screens/novel/components/SetCategoriesModal';
import useBoolean from '@hooks/useBoolean';
import { debounce } from 'lodash';
import { ButtonVariation } from '@components/Button/Button';
import { useBackHandler } from '@hooks/useBackHandler';
type State = NavigationState<{
key: string;
@@ -58,6 +59,15 @@ const LibraryScreen = () => {
const { library, refetchLibrary, isLoading } = useLibrary({ searchText });
const [selectedNovelIds, setSelectedNovelIds] = useState<number[]>([]);
useBackHandler(() => {
if (selectedNovelIds.length) {
setSelectedNovelIds([]);
return true;
}
return false;
});
const layout = useWindowDimensions();
const [index, setIndex] = useState(0);
@@ -1,6 +1,6 @@
import React from 'react';
import { Button, Dialog, Portal } from 'react-native-paper';
import { Button, Dialog, overlay, Portal } from 'react-native-paper';
const RemoveDownloadsDialog = ({
dialogVisible,
@@ -15,7 +15,7 @@ const RemoveDownloadsDialog = ({
onDismiss={hideDialog}
style={{
borderRadius: 6,
backgroundColor: theme.colorPrimary,
backgroundColor: overlay(2, theme.surface),
}}
>
<Dialog.Title
@@ -30,7 +30,7 @@ const RemoveDownloadsDialog = ({
<Dialog.Actions>
<Button
uppercase={false}
theme={{ colors: { primary: theme.colorAccent } }}
theme={{ colors: { primary: theme.primary } }}
onPress={hideDialog}
labelStyle={{ letterSpacing: 0 }}
>
@@ -38,7 +38,7 @@ const RemoveDownloadsDialog = ({
</Button>
<Button
uppercase={false}
theme={{ colors: { primary: theme.colorAccent } }}
theme={{ colors: { primary: theme.primary } }}
onPress={onSubmit}
labelStyle={{ letterSpacing: 0 }}
>