Files
suwayomi-material-you-webui/src/typings.d.ts

344 lines
7.2 KiB
TypeScript
Raw Normal View History

/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
2021-01-26 23:32:12 +03:30
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
2020-12-24 16:50:50 +01:00
interface IExtension {
name: string;
pkgName: string;
versionName: string;
versionCode: number;
lang: string;
isNsfw: boolean;
apkName: string;
iconUrl: string;
installed: boolean;
hasUpdate: boolean;
obsolete: boolean;
2020-12-24 16:50:50 +01:00
}
2020-12-25 06:36:34 +03:30
interface ISource {
id: string;
name: string;
lang: string;
iconUrl: string;
supportsLatest: boolean;
isConfigurable: boolean;
isNsfw: boolean;
displayName: string;
2020-12-25 06:36:34 +03:30
}
2020-12-25 17:42:22 +01:00
interface ISourceFilters {
type: string;
filter: ISourceFilter;
}
interface ISourceFilter {
name: string;
state: number | string | boolean | ISourceFilters[] | IState;
values?: string[];
displayValues?: string[];
selected?: ISelected;
}
interface ISelected {
displayname: string;
value: string;
_value: string;
}
interface IState {
ascending: boolean;
index: number;
}
interface IMetadataMigration {
appKeyPrefix?: { oldPrefix: string; newPrefix: string };
values?: {
/**
* In case the migration should only be applied to a specific metadata key.
* Otherwise, all metadata keys will get migrated.
*/
key?: string;
oldValue: string;
newValue: string;
}[];
keys?: { oldKey: string; newKey: string }[];
}
Save reader settings per manga in Meta (#216) * [#213] Add missing "meta" property - IManga - IMangaCard (optional) - IChapter - ICategory * [#213] Add util functions for handling metadata - global server - manga - chapter - category * [#213] Use "ReaderSettings" from the manga metadata - get ReaderSettings from manga metadata - remove unnecessary check "make sure settings has all the keys" in case the stored settings in the metadata are outdated they will be filled with default values * [#213] Reload manga only in case "mangaId" changed In case the chapter is still from the same manga, a reload is unnecessary * [#213] Only update the changed reader setting Otherwise the app has to send patch requests to the server for every setting even if it didn't change * [#213] Hide "openButton" on first render in case "navBar" is shown The "openButton" was always set to be visible event in case the navBar was shown on the first render * [#213] Open the "ReaderNavBar" if needed after receiving new settings Otherwise, the drawer won't open in case the "navBar" was hidden on the first render since the default state in that case was set to false * [#213] Update "ReaderSettings" after receiving the manga response Otherwise, the default settings aren't getting removed * [#213] Hide/Show "OpenButton" when opening/closing the drawer Otherwise, the button stays hidden until it gets updated due to scrolling * [#213] Keep "ReaderNavBar" state when opening prev/next chapter In case the navBar wasn't sticky but opened, it got closed when the prev/next chapter got opened * [#213] Prevent "ReaderNavBar" from closing when changing "staticNav" setting
2023-01-06 17:15:29 +01:00
interface IMetadata<VALUES extends AllowedMetadataValueTypes = string> {
[key: string]: VALUES;
}
interface IMetadataHolder<VALUES extends AllowedMetadataValueTypes = string> {
meta?: IMetadata<VALUES>;
Save reader settings per manga in Meta (#216) * [#213] Add missing "meta" property - IManga - IMangaCard (optional) - IChapter - ICategory * [#213] Add util functions for handling metadata - global server - manga - chapter - category * [#213] Use "ReaderSettings" from the manga metadata - get ReaderSettings from manga metadata - remove unnecessary check "make sure settings has all the keys" in case the stored settings in the metadata are outdated they will be filled with default values * [#213] Reload manga only in case "mangaId" changed In case the chapter is still from the same manga, a reload is unnecessary * [#213] Only update the changed reader setting Otherwise the app has to send patch requests to the server for every setting even if it didn't change * [#213] Hide "openButton" on first render in case "navBar" is shown The "openButton" was always set to be visible event in case the navBar was shown on the first render * [#213] Open the "ReaderNavBar" if needed after receiving new settings Otherwise, the drawer won't open in case the "navBar" was hidden on the first render since the default state in that case was set to false * [#213] Update "ReaderSettings" after receiving the manga response Otherwise, the default settings aren't getting removed * [#213] Hide/Show "OpenButton" when opening/closing the drawer Otherwise, the button stays hidden until it gets updated due to scrolling * [#213] Keep "ReaderNavBar" state when opening prev/next chapter In case the navBar wasn't sticky but opened, it got closed when the prev/next chapter got opened * [#213] Prevent "ReaderNavBar" from closing when changing "staticNav" setting
2023-01-06 17:15:29 +01:00
}
type AllowedMetadataValueTypes = string | boolean | number | undefined;
type MangaMetadataKeys = keyof IReaderSettings;
type AppMetadataKeys = MangaMetadataKeys;
type MetadataKeyValuePair = [AppMetadataKeys, AllowedMetadataValueTypes];
interface IMangaCard {
id: number;
title: string;
genre: string[];
thumbnailUrl: string;
unreadCount?: number;
downloadCount?: number;
inLibrary?: boolean;
meta?: IMetadata;
}
2020-12-25 17:42:22 +01:00
interface IManga {
id: number;
sourceId: string;
url: string;
title: string;
thumbnailUrl: string;
artist: string;
author: string;
description: string;
genre: string[];
status: string;
2021-09-05 01:11:25 +04:30
inLibrary: boolean;
source: ISource;
2021-09-05 01:11:25 +04:30
meta: IMetadata;
2021-09-05 01:11:25 +04:30
realUrl: string;
freshData: boolean;
unreadCount?: number;
downloadCount?: number;
age: number;
chaptersAge: number;
2021-09-05 01:11:25 +04:30
}
2021-01-19 21:02:57 +03:30
interface IChapter {
id: number;
url: string;
name: string;
uploadDate: number;
chapterNumber: number;
scanlator: string;
mangaId: number;
read: boolean;
bookmarked: boolean;
lastPageRead: number;
lastReadAt: number;
index: number;
fetchedAt: number;
chapterCount: number;
pageCount: number;
downloaded: boolean;
meta: IAppMetadata;
2021-01-19 21:02:57 +03:30
}
2021-02-20 01:23:52 +03:30
2021-09-28 00:41:12 +03:30
interface IMangaChapter {
manga: IManga;
chapter: IChapter;
2021-09-28 00:41:12 +03:30
}
interface IPartialChapter {
pageCount: number;
index: number;
chapterCount: number;
lastPageRead: number;
2021-03-23 03:50:55 +04:30
}
2021-02-20 01:23:52 +03:30
interface ICategory {
id: number;
order: number;
name: string;
default: boolean;
meta: IAppMetadata;
2021-02-20 01:23:52 +03:30
}
2021-03-18 21:46:24 +03:30
interface INavbarOverride {
status: boolean;
value: any;
2021-03-29 02:47:51 +04:30
}
2021-05-15 17:18:57 +04:30
2021-05-15 23:22:37 +04:30
type ReaderType =
| 'ContinuesVertical'
| 'Webtoon'
| 'SingleVertical'
| 'SingleRTL'
| 'SingleLTR'
| 'DoubleVertical'
| 'DoubleRTL'
| 'DoubleLTR'
| 'ContinuesHorizontalLTR'
| 'ContinuesHorizontalRTL';
interface IReaderSettings {
staticNav: boolean;
showPageNumber: boolean;
loadNextOnEnding: boolean;
readerType: ReaderType;
2021-05-15 17:18:57 +04:30
}
interface IReaderPage {
index: number;
src: string;
2021-05-15 17:18:57 +04:30
}
2021-05-15 23:22:37 +04:30
interface IReaderProps {
pages: Array<IReaderPage>;
pageCount: number;
setCurPage: React.Dispatch<React.SetStateAction<number>>;
curPage: number;
initialPage: number;
settings: IReaderSettings;
manga: IMangaCard | IManga;
chapter: IChapter | IPartialChapter;
nextChapter: () => void;
prevChapter: () => void;
2021-05-15 23:22:37 +04:30
}
2021-05-25 21:06:27 +04:30
interface IAbout {
name: string;
version: string;
revision: string;
buildType: 'Stable' | 'Preview';
buildTime: number;
github: string;
discord: string;
2021-05-25 21:06:27 +04:30
}
2021-05-30 04:01:49 +04:30
interface IDownloadChapter {
chapterIndex: number;
mangaId: number;
state: 'Queued' | 'Downloading' | 'Finished' | 'Error';
progress: number;
chapter: IChapter;
manga: IManga;
2021-05-30 04:01:49 +04:30
}
interface IQueue {
status: 'Stopped' | 'Started';
queue: IDownloadChapter[];
2021-05-30 04:01:49 +04:30
}
interface IUpdateStatus {
running: boolean;
statusMap: {
COMPLETE?: IManga[];
RUNNING?: IManga[];
PENDING?: IManga[];
};
}
interface PreferenceProps {
key: string;
title: string;
summary: string;
defaultValue: any;
currentValue: any;
defaultValueType: string;
2021-09-13 19:18:21 +04:30
// intetnal props
updateValue: any;
}
2021-09-13 19:18:21 +04:30
interface TwoStatePreferenceProps extends PreferenceProps {
// intetnal props
type: 'Switch' | 'Checkbox';
2021-09-13 19:18:21 +04:30
}
2021-09-13 19:18:21 +04:30
interface CheckBoxPreferenceProps extends PreferenceProps {}
2021-09-13 19:18:21 +04:30
interface SwitchPreferenceCompatProps extends PreferenceProps {}
2021-09-13 19:18:21 +04:30
interface ListPreferenceProps extends PreferenceProps {
entries: string[];
entryValues: string[];
2021-09-13 19:18:21 +04:30
}
interface MultiSelectListPreferenceProps extends PreferenceProps {
entries: string[];
entryValues: string[];
}
2021-09-13 19:18:21 +04:30
interface EditTextPreferenceProps extends PreferenceProps {
dialogTitle: string;
dialogMessage: string;
text: string;
2021-09-13 19:18:21 +04:30
}
interface SourcePreferences {
type: string;
props: any;
}
2021-10-30 17:29:27 +03:30
interface NavbarItem {
path: string;
title: string;
SelectedIconComponent: OverridableComponent<SvgIconTypeMap<{}, 'svg'>>;
IconComponent: OverridableComponent<SvgIconTypeMap<{}, 'svg'>>;
show: 'mobile' | 'desktop' | 'both';
}
interface PaginatedList<T> {
page: T[];
hasNextPage: boolean;
}
2021-12-13 19:52:56 +05:30
type NullAndUndefined<T> = T | null | undefined;
type ChapterSortMode = 'fetchedAt' | 'source';
2021-12-13 19:52:56 +05:30
interface ChapterListOptions {
active: boolean;
unread: NullAndUndefined<boolean>;
downloaded: NullAndUndefined<boolean>;
bookmarked: NullAndUndefined<boolean>;
reverse: boolean;
sortBy: ChapterSortMode;
showChapterNumber: boolean;
2021-12-13 19:52:56 +05:30
}
type ChapterOptionsReducerAction =
| { type: 'filter'; filterType: string; filterValue: NullAndUndefined<boolean> }
| { type: 'sortBy'; sortBy: ChapterSortMode }
| { type: 'sortReverse' }
| { type: 'showChapterNumber' };
2022-03-03 18:19:01 +05:30
type LibrarySortMode = 'sortToRead' | 'sortAlph' | 'sortID';
enum GridLayout {
Compact = 0,
Comfortable = 1,
List = 2,
}
interface LibraryOptions {
// display options
showDownloadBadge: boolean;
showUnreadBadge: boolean;
gridLayout: GridLayout;
SourcegridLayout: GridLayout;
// filter options
downloaded: NullAndUndefined<boolean>;
unread: NullAndUndefined<boolean>;
sorts: NullAndUndefined<LibrarySortMode>;
sortDesc: NullAndUndefined<boolean>;
2022-03-03 18:19:01 +05:30
}
interface BatchChaptersChange {
delete?: boolean;
isRead?: boolean;
isBookmarked?: boolean;
lastPageRead?: number;
}