Skip to content

Commit

Permalink
Merge branch 'LNReader:master' into progress-tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Batorian authored Dec 1, 2024
2 parents 65cf676 + ecb3875 commit b593388
Show file tree
Hide file tree
Showing 109 changed files with 10,328 additions and 1,483 deletions.
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ module.exports = {
trailingComma: 'all',
arrowParens: 'avoid',
quoteProps: 'preserve',
endOfLine: 'auto', // stop prettier from getting mad on windows
};
1 change: 1 addition & 0 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'react-native-gesture-handler';
import 'react-native-url-polyfill/auto';
import { enableFreeze } from 'react-native-screens';

enableFreeze(true);
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/assets/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ body {

body.page-reader {
overflow: hidden;
padding-bottom: unset;
}

#LNReader-chapter {
Expand Down
2 changes: 2 additions & 0 deletions android/app/src/main/assets/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ window.addEventListener('DOMContentLoaded', async () => {
if (reader.generalSettings.val.pageReader) {
const diffX =
(e.changedTouches[0].screenX - this.initialX) / reader.layoutWidth;
reader.chapterElement.style.transition = 'unset';
reader.chapterElement.style.transform =
'translateX(-' + (pageReader.page.val - diffX) * 100 + '%)';
}
Expand All @@ -421,6 +422,7 @@ window.addEventListener('DOMContentLoaded', async () => {
const diffX = e.changedTouches[0].screenX - this.initialX;
const diffY = e.changedTouches[0].screenY - this.initialY;
if (reader.generalSettings.val.pageReader) {
reader.chapterElement.style.transition = '200ms';
const diffXPercentage = diffX / reader.layoutWidth;
if (diffXPercentage < -0.3) {
pageReader.movePage(pageReader.page.val + 1);
Expand Down
2 changes: 1 addition & 1 deletion crowdin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pull_request_title: 'chore: Update translations'
pull_request_title: 'chore: Update Translations'
commit_message: '[ci skip]'
files:
- source: /strings/languages/en/strings.json
Expand Down
78 changes: 59 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"i18n-js": "^3.8.0",
"lodash-es": "^4.17.21",
"protobufjs": "^7.2.6",
"qs": "^6.12.0",
"react": "18.2.0",
"react-native": "0.72.10",
"react-native-background-actions": "^3.0.1",
Expand All @@ -62,6 +61,7 @@
"react-native-screens": "^3.22.0",
"react-native-shimmer-placeholder": "^2.0.9",
"react-native-tab-view": "^3.5.2",
"react-native-url-polyfill": "^2.0.0",
"react-native-vector-icons": "^9.0.0",
"react-native-webview": "^13.10.5",
"react-native-zip-archive": "^7.0.0",
Expand Down
31 changes: 25 additions & 6 deletions src/components/BottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import React, { Ref, useCallback } from 'react';
import React, { RefObject, useCallback, useRef } from 'react';
import {
BottomSheetBackdrop,
BottomSheetBackdropProps,
BottomSheetModal,
BottomSheetModalProps,
} from '@gorhom/bottom-sheet';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useBackHandler } from '@hooks/index';
import { BottomSheetModalMethods } from '@gorhom/bottom-sheet/lib/typescript/types';

interface BottomSheetProps extends Omit<BottomSheetModalProps, 'ref'> {
bottomSheetRef: Ref<BottomSheetModal> | null;
bottomSheetRef: RefObject<BottomSheetModalMethods> | null;
}

const BottomSheet: React.FC<BottomSheetProps> = props => {
const BottomSheet: React.FC<BottomSheetProps> = ({
bottomSheetRef,
children,
onChange,
...otherProps
}) => {
const indexRef = useRef<number>();
const { bottom } = useSafeAreaInsets();
const renderBackdrop = useCallback(
(backdropProps: BottomSheetBackdropProps) => (
Expand All @@ -23,15 +31,26 @@ const BottomSheet: React.FC<BottomSheetProps> = props => {
),
[],
);
useBackHandler(() => {
if (typeof indexRef.current === 'number' && indexRef.current !== -1) {
bottomSheetRef?.current?.close();
return true;
}
return false;
});
return (
<BottomSheetModal
ref={props.bottomSheetRef}
ref={bottomSheetRef}
backdropComponent={renderBackdrop}
handleComponent={null}
containerStyle={{ paddingBottom: bottom }}
{...props}
onChange={index => {
onChange?.(index);
indexRef.current = index;
}}
{...otherProps}
>
{props.children}
{children}
</BottomSheetModal>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { coverPlaceholderColor } from '../theme/colors';
import color from 'color';
import { ThemeColors } from '@theme/types';
import { NovelItem } from '@plugins/types';
import { LibraryNovelInfo } from '@database/types';
import { NovelInfo } from '@database/types';

interface ListViewProps {
item: NovelItem | LibraryNovelInfo;
item: NovelItem | NovelInfo;
downloadBadge?: React.ReactNode;
unreadBadge?: React.ReactNode;
inLibraryBadge?: React.ReactNode;
Expand Down
5 changes: 2 additions & 3 deletions src/components/NovelCover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ interface INovelCover<TNovel> {
libraryStatus: boolean;
theme: ThemeColors;
isSelected: boolean;
addSkeletonLoading: boolean;
addSkeletonLoading?: boolean;
onLongPress: (item: TNovel) => void;
selectedNovelIds: number[];
}
Expand Down Expand Up @@ -86,8 +86,7 @@ function NovelCover<TNovel extends CoverItemLibrary | CoverItemPlugin>({

const coverHeight = useMemo(
() => (window.width / numColumns) * (4 / 3),
// eslint-disable-next-line react-hooks/exhaustive-deps
[numColumns],
[window.width, numColumns],
);

const selectNovel = () => onLongPress(item);
Expand Down
2 changes: 1 addition & 1 deletion src/database/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { createRepositoryTableQuery } from './tables/RepositoryTable';

const dbName = 'lnreader.db';

const db = SQLite.openDatabase(dbName);
export const db = SQLite.openDatabase(dbName);

export const createTables = () => {
db.exec([{ sql: 'PRAGMA foreign_keys = ON', args: [] }], false, () => {});
Expand Down
3 changes: 1 addition & 2 deletions src/database/queries/CategoryQueries.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import * as SQLite from 'expo-sqlite';
import { noop } from 'lodash-es';
import { BackupCategory, Category, NovelCategory, CCategory } from '../types';
import { showToast } from '@utils/showToast';
import { txnErrorCallback } from '../utils/helpers';
import { getString } from '@strings/translations';
const db = SQLite.openDatabase('lnreader.db');
import { db } from '@database/db';

const getCategoriesQuery = `
SELECT * FROM Category ORDER BY sort
Expand Down
5 changes: 2 additions & 3 deletions src/database/queries/ChapterQueries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as SQLite from 'expo-sqlite';
import { showToast } from '@utils/showToast';
import { ChapterInfo, DownloadedChapter } from '../types';
import { ChapterItem } from '@plugins/types';
Expand All @@ -9,8 +8,8 @@ import { noop } from 'lodash-es';
import { getString } from '@strings/translations';
import FileManager from '@native/FileManager';
import { NOVEL_STORAGE } from '@utils/Storages';
import { db } from '@database/db';

const db = SQLite.openDatabase('lnreader.db');
const insertChapterQuery = `
INSERT OR IGNORE INTO Chapter (path, name, releaseTime, novelId, chapterNumber, page, position)
VALUES (?, ?, ?, ?, ?, ?, ?)
Expand Down Expand Up @@ -42,7 +41,7 @@ export const insertChapters = async (
`
UPDATE Chapter SET
page = ?, position = ?
WHERE path = ? AND novelId = ? (AND page != ? OR position != ?)
WHERE path = ? AND novelId = ? AND (page != ? OR position != ?)
`,
[
chapter.page || '1',
Expand Down
3 changes: 1 addition & 2 deletions src/database/queries/HistoryQueries.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { History } from '@database/types';
import { txnErrorCallback } from '@database/utils/helpers';
import * as SQLite from 'expo-sqlite';
import { db } from '@database/db';
import { noop } from 'lodash-es';
const db = SQLite.openDatabase('lnreader.db');

import { showToast } from '../../utils/showToast';
import { getString } from '@strings/translations';
Expand Down
4 changes: 1 addition & 3 deletions src/database/queries/LibraryQueries.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { LibraryFilter } from '@screens/library/constants/constants';
import * as SQLite from 'expo-sqlite';
import { LibraryNovelInfo, NovelInfo } from '../types';
import { txnErrorCallback } from '../utils/helpers';

const db = SQLite.openDatabase('lnreader.db');
import { db } from '@database/db';

export const getNovelsWithCategory = (
categoryId: number,
Expand Down
4 changes: 1 addition & 3 deletions src/database/queries/NovelQueries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import * as SQLite from 'expo-sqlite';
const db = SQLite.openDatabase('lnreader.db');

import * as DocumentPicker from 'expo-document-picker';

import { fetchNovel } from '@services/plugin/fetch';
Expand All @@ -16,6 +13,7 @@ import { NOVEL_STORAGE } from '@utils/Storages';
import FileManager from '@native/FileManager';
import { downloadFile } from '@plugins/helpers/fetch';
import { getPlugin } from '@plugins/pluginManager';
import { db } from '@database/db';

export const insertNovelAndChapters = async (
pluginId: string,
Expand Down
5 changes: 1 addition & 4 deletions src/database/queries/RepositoryQueries.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import * as SQLite from 'expo-sqlite';

import { Repository } from '@database/types';

import { txnErrorCallback } from '../utils/helpers';
import { noop } from 'lodash-es';

const db = SQLite.openDatabase('lnreader.db');
import { db } from '@database/db';

const getRepositoriesQuery = 'SELECT * FROM Repository';

Expand Down
4 changes: 1 addition & 3 deletions src/database/queries/StatsQueries.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as SQLite from 'expo-sqlite';
import { countBy } from 'lodash-es';
import { LibraryStats } from '../types';
import { txnErrorCallback } from '../utils/helpers';

const db = SQLite.openDatabase('lnreader.db');
import { db } from '@database/db';

const getLibraryStatsQuery = `
SELECT COUNT(*) as novelsCount, COUNT(DISTINCT pluginId) as sourcesCount
Expand Down
Loading

0 comments on commit b593388

Please sign in to comment.