fix: type errors
* fix app.tsx * fix InfoItem * fix helpers * fix webview ref * fix MoreScreen * fix NovelScreenButtonGroup * fix ReaderScreen * fix readerTextAlignSelector * fix ReaderValueChange * fix UpdateNovelCard * fix myAnimeList * fixed legacy backup * fix migrateNovel
This commit is contained in:
@@ -92,7 +92,6 @@ const Divider = ({ theme }: { theme: ThemeColors }) => (
|
||||
|
||||
const InfoItem = ({
|
||||
title,
|
||||
icon = 'information-outline',
|
||||
theme,
|
||||
style,
|
||||
}: {
|
||||
@@ -102,7 +101,11 @@ const InfoItem = ({
|
||||
style?: StyleProp<ViewStyle>;
|
||||
}) => (
|
||||
<View style={[styles.infoCtn, style]}>
|
||||
<MaterialIcon size={20} color={theme.onSurfaceVariant} name={icon} />
|
||||
<MaterialIcon
|
||||
size={20}
|
||||
color={theme.onSurfaceVariant}
|
||||
name={'information-outline'}
|
||||
/>
|
||||
<Text style={[styles.infoMsg, { color: theme.onSurfaceVariant }]}>
|
||||
{title}
|
||||
</Text>
|
||||
|
||||
@@ -78,11 +78,14 @@ export const getNovelById = async (novelId: number) => {
|
||||
export const getNovelByPath = (
|
||||
novelPath: string,
|
||||
pluginId: string,
|
||||
): NovelInfo | null => {
|
||||
): NovelInfo | undefined => {
|
||||
const res = getFirstSync<NovelInfo>([
|
||||
'SELECT * FROM Novel WHERE path = ? AND pluginId = ?',
|
||||
[novelPath, pluginId],
|
||||
]);
|
||||
if (!res) {
|
||||
return undefined;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
|
||||
@@ -90,7 +90,8 @@ export function getFirstSync<T = unknown>(queryObject: QueryObject<T>) {
|
||||
return defaultQuerySync<T, false>('getFirstSync', queryObject, null);
|
||||
}
|
||||
|
||||
type TransactionObject = [query, ...params: SQLiteBindValue[]];
|
||||
type params = SQLiteBindValue[];
|
||||
type TransactionObject = [query, ...params];
|
||||
|
||||
export async function transactionAsync(transactionObject: TransactionObject[]) {
|
||||
await db.withTransactionAsync(async () => {
|
||||
|
||||
@@ -84,9 +84,12 @@ export type SettingsStackParamList = {
|
||||
RespositorySettings: { url?: string } | undefined;
|
||||
};
|
||||
|
||||
export type NovelScreenProps = StackScreenProps<ReaderStackParamList, 'Novel'>;
|
||||
export type NovelScreenProps = StackScreenProps<
|
||||
ReaderStackParamList & RootStackParamList,
|
||||
'Novel'
|
||||
>;
|
||||
export type ChapterScreenProps = StackScreenProps<
|
||||
ReaderStackParamList,
|
||||
ReaderStackParamList & RootStackParamList,
|
||||
'Chapter'
|
||||
>;
|
||||
export type ReaderStackParamList = {
|
||||
|
||||
@@ -11,7 +11,7 @@ interface AppbarProps {
|
||||
theme: ThemeColors;
|
||||
canGoBack: boolean;
|
||||
canGoForward: boolean;
|
||||
webView: RefObject<WebView>;
|
||||
webView: RefObject<WebView | null>;
|
||||
setMenuVisible: (value: boolean) => void;
|
||||
goBack: () => void;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import { showToast } from '@utils/showToast';
|
||||
interface MenuProps {
|
||||
theme: ThemeColors;
|
||||
currentUrl: string;
|
||||
webView: RefObject<WebView>;
|
||||
webView: RefObject<WebView | null>;
|
||||
setMenuVisible: (value: boolean) => void;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,23 +57,19 @@ const MoreScreen = ({ navigation }: MoreStackScreenProps) => {
|
||||
<List.Section>
|
||||
<Pressable
|
||||
android_ripple={{ color: theme.rippleColor }}
|
||||
style={{
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 14,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
style={styles.pressable}
|
||||
onPress={enableDownloadedOnlyMode}
|
||||
>
|
||||
<View style={{ flexDirection: 'row' }}>
|
||||
<View style={styles.row}>
|
||||
<List.Icon theme={theme} icon="cloud-off-outline" />
|
||||
<View style={{ marginLeft: 16 }}>
|
||||
<View style={styles.marginLeft16}>
|
||||
<Text
|
||||
style={{
|
||||
color: theme.onSurface,
|
||||
fontSize: 16,
|
||||
}}
|
||||
style={[
|
||||
{
|
||||
color: theme.onSurface,
|
||||
},
|
||||
styles.fontSize16,
|
||||
]}
|
||||
>
|
||||
{getString('moreScreen.downloadOnly')}
|
||||
</Text>
|
||||
@@ -88,7 +84,6 @@ const MoreScreen = ({ navigation }: MoreStackScreenProps) => {
|
||||
</View>
|
||||
</View>
|
||||
<Switch
|
||||
theme={theme}
|
||||
value={downloadedOnlyMode}
|
||||
onValueChange={enableDownloadedOnlyMode}
|
||||
size={24}
|
||||
@@ -96,23 +91,19 @@ const MoreScreen = ({ navigation }: MoreStackScreenProps) => {
|
||||
</Pressable>
|
||||
<Pressable
|
||||
android_ripple={{ color: theme.rippleColor }}
|
||||
style={{
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 14,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
style={styles.pressable}
|
||||
onPress={enableIncognitoMode}
|
||||
>
|
||||
<View style={{ flexDirection: 'row' }}>
|
||||
<View style={styles.row}>
|
||||
<List.Icon theme={theme} icon="glasses" />
|
||||
<View style={{ marginLeft: 16 }}>
|
||||
<View style={styles.marginLeft16}>
|
||||
<Text
|
||||
style={{
|
||||
color: theme.onSurface,
|
||||
fontSize: 16,
|
||||
}}
|
||||
style={[
|
||||
{
|
||||
color: theme.onSurface,
|
||||
},
|
||||
styles.fontSize16,
|
||||
]}
|
||||
>
|
||||
{getString('moreScreen.incognitoMode')}
|
||||
</Text>
|
||||
@@ -127,7 +118,6 @@ const MoreScreen = ({ navigation }: MoreStackScreenProps) => {
|
||||
</View>
|
||||
</View>
|
||||
<Switch
|
||||
theme={theme}
|
||||
value={incognitoMode}
|
||||
onValueChange={enableIncognitoMode}
|
||||
size={24}
|
||||
@@ -216,4 +206,14 @@ const styles = StyleSheet.create({
|
||||
fontSize: 12,
|
||||
lineHeight: 20,
|
||||
},
|
||||
pressable: {
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 14,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
},
|
||||
row: { flexDirection: 'row' },
|
||||
fontSize16: { fontSize: 16 },
|
||||
marginLeft16: { marginLeft: 16 },
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ import { ChapterContextProvider, useChapterContext } from './ChapterContext';
|
||||
import { BottomSheetModalMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
|
||||
import { useBackHandler } from '@hooks/index';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import { View } from 'react-native';
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import { Drawer } from 'react-native-drawer-layout';
|
||||
|
||||
const Chapter = ({ route, navigation }: ChapterScreenProps) => {
|
||||
@@ -34,7 +34,7 @@ const Chapter = ({ route, navigation }: ChapterScreenProps) => {
|
||||
|
||||
const openDrawer = useCallback(() => {
|
||||
setOpen(true);
|
||||
}, [open]);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ChapterContextProvider
|
||||
@@ -134,7 +134,9 @@ export const ChapterContent = ({
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View style={{ flex: 1, paddingLeft: left, paddingRight: right }}>
|
||||
<View
|
||||
style={[{ paddingLeft: left, paddingRight: right }, styles.container]}
|
||||
>
|
||||
{keepScreenOn ? <KeepScreenAwake /> : null}
|
||||
{loading ? (
|
||||
<ChapterLoadingScreen />
|
||||
@@ -174,3 +176,7 @@ export const ChapterContent = ({
|
||||
};
|
||||
|
||||
export default Chapter;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { flex: 1 },
|
||||
});
|
||||
|
||||
@@ -5,9 +5,12 @@ import { useChapterReaderSettings, useTheme } from '@hooks/persisted';
|
||||
import { IconButtonV2 } from '@components';
|
||||
import { ChapterReaderSettings } from '@hooks/persisted/useSettings';
|
||||
|
||||
type ValueKey<T extends object> = {
|
||||
[K in keyof T]: T[K] extends number ? K : never;
|
||||
}[keyof T];
|
||||
type ValueKey<T extends object> = Exclude<
|
||||
{
|
||||
[K in keyof T]: T[K] extends number ? K : never;
|
||||
}[keyof T],
|
||||
undefined
|
||||
>;
|
||||
|
||||
interface ReaderValueChangeProps {
|
||||
labelStyle?: TextStyle | TextStyle[];
|
||||
|
||||
@@ -73,12 +73,10 @@ const BackupSettings = ({ navigation }: BackupSettingsScreenProps) => {
|
||||
/>
|
||||
<List.InfoItem
|
||||
title={getString('backupScreen.restoreLargeBackupsWarning')}
|
||||
icon="information-outline"
|
||||
theme={theme}
|
||||
/>
|
||||
<List.InfoItem
|
||||
title={getString('backupScreen.createBackupWarning')}
|
||||
icon="information-outline"
|
||||
theme={theme}
|
||||
/>
|
||||
</List.Section>
|
||||
|
||||
@@ -37,7 +37,6 @@ export default function TextToSpeechSettings() {
|
||||
<List.SubHeader theme={theme}>Text to Speech</List.SubHeader>
|
||||
<View style={styles.row}>
|
||||
<Switch
|
||||
theme={theme}
|
||||
value={TTSEnable}
|
||||
onValueChange={() => {
|
||||
setChapterGeneralSettings({
|
||||
|
||||
@@ -141,7 +141,7 @@ const UpdateNovelCard: React.FC<UpdateCardProps> = ({
|
||||
description={`${chapterListInfo.updatesPerDay} ${descriptionText}`}
|
||||
onPress={updateList}
|
||||
>
|
||||
{chapterList.length > 0 ? ( //@ts-expect-error
|
||||
{chapterList.length > 0 ? (
|
||||
<FlatList
|
||||
data={chapterList}
|
||||
keyExtractor={it => 'update' + it.id}
|
||||
|
||||
@@ -73,7 +73,7 @@ export const myAnimeListTracker: Tracker = {
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
grant_type: 'refresh_token',
|
||||
refresh_token: auth.refreshToken,
|
||||
refresh_token: auth.refreshToken!,
|
||||
}).toString(),
|
||||
});
|
||||
|
||||
@@ -128,11 +128,11 @@ export const myAnimeListTracker: Tracker = {
|
||||
let status = payload.status
|
||||
? normalizedToMal[payload.status]
|
||||
: normalizedToMal.CURRENT;
|
||||
let repeating = false;
|
||||
let repeating = 'false';
|
||||
if (status.includes(';')) {
|
||||
const split = status.split(';');
|
||||
status = split[0];
|
||||
repeating = Boolean(split[1]);
|
||||
repeating = split[1];
|
||||
}
|
||||
|
||||
const url = `${baseApiUrl}/manga/${id}/my_list_status`;
|
||||
@@ -145,8 +145,8 @@ export const myAnimeListTracker: Tracker = {
|
||||
body: new URLSearchParams({
|
||||
status,
|
||||
is_rereading: repeating,
|
||||
num_chapters_read: payload.progress,
|
||||
score: payload.score,
|
||||
num_chapters_read: '' + payload.progress!,
|
||||
score: '' + payload.score!,
|
||||
}).toString(),
|
||||
});
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export const createBackup = async () => {
|
||||
await FileSystem.StorageAccessFramework.requestDirectoryPermissionsAsync();
|
||||
|
||||
if (!permissions.granted) {
|
||||
showToast(getString('backupScreen.legacy.permissionDenied'));
|
||||
showToast(getString('backupScreen.failed'));
|
||||
return;
|
||||
}
|
||||
const directoryUri = permissions.directoryUri;
|
||||
@@ -40,7 +40,7 @@ export const createBackup = async () => {
|
||||
})
|
||||
.catch(error => {
|
||||
showToast(
|
||||
getString('backupScreen.legacy.failedToSave', {
|
||||
getString('backupScreen.failed', {
|
||||
message: error.message,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -76,25 +76,25 @@ export const migrateNovel = async (
|
||||
await db.withTransactionAsync(async () => {
|
||||
await db.runAsync(
|
||||
migrateNovelMetaDataQuery,
|
||||
fromNovel.cover || toNovel.cover || '',
|
||||
fromNovel.summary || toNovel.summary || '',
|
||||
fromNovel.author || toNovel.author || '',
|
||||
fromNovel.artist || toNovel.artist || '',
|
||||
fromNovel.status || toNovel.status || '',
|
||||
fromNovel.genres || toNovel.genres || '',
|
||||
toNovel.id,
|
||||
fromNovel.cover || toNovel!.cover || '',
|
||||
fromNovel.summary || toNovel!.summary || '',
|
||||
fromNovel.author || toNovel!.author || '',
|
||||
fromNovel.artist || toNovel!.artist || '',
|
||||
fromNovel.status || toNovel!.status || '',
|
||||
fromNovel.genres || toNovel!.genres || '',
|
||||
toNovel!.id,
|
||||
);
|
||||
|
||||
await db.runAsync(
|
||||
'UPDATE OR IGNORE NovelCategory SET novelId = ? WHERE novelId = ?',
|
||||
toNovel.id,
|
||||
toNovel!.id,
|
||||
fromNovel.id,
|
||||
);
|
||||
await db.runAsync('DELETE FROM Novel WHERE id = ?', fromNovel.id);
|
||||
});
|
||||
|
||||
setMMKVObject(
|
||||
`${NOVEL_SETTINSG_PREFIX}_${toNovel.pluginId}_${toNovel.path}`,
|
||||
`${NOVEL_SETTINSG_PREFIX}_${toNovel!.pluginId}_${toNovel!.path}`,
|
||||
getMMKVObject(
|
||||
`${NOVEL_SETTINSG_PREFIX}_${fromNovel.pluginId}_${fromNovel.path}`,
|
||||
),
|
||||
@@ -106,7 +106,7 @@ export const migrateNovel = async (
|
||||
|
||||
const setLastRead = (chapter: ChapterInfo) => {
|
||||
setMMKVObject(
|
||||
`${LAST_READ_PREFIX}_${toNovel.pluginId}_${toNovel.path}`,
|
||||
`${LAST_READ_PREFIX}_${toNovel!.pluginId}_${toNovel!.path}`,
|
||||
chapter,
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ReaderTheme } from '@hooks/persisted/useSettings';
|
||||
import { MaterialDesignIconName } from '@type/icon';
|
||||
|
||||
export const presetReaderThemes: ReaderTheme[] = [
|
||||
{ backgroundColor: '#f5f5fa', textColor: '#111111' },
|
||||
@@ -13,7 +14,7 @@ export const presetReaderThemes: ReaderTheme[] = [
|
||||
|
||||
interface TextAlignments {
|
||||
value: string;
|
||||
icon: string;
|
||||
icon: MaterialDesignIconName;
|
||||
}
|
||||
|
||||
export const textAlignments: TextAlignments[] = [
|
||||
|
||||
Reference in New Issue
Block a user