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
This commit is contained in:
Daniel
2023-01-06 17:15:29 +01:00
committed by GitHub
parent 34bafee3aa
commit 46ac5d5531
4 changed files with 268 additions and 60 deletions

22
src/typings.d.ts vendored
View File

@@ -54,6 +54,22 @@ interface IState {
index: number
}
interface IMetadata<VALUES extends AllowedMetadataValueTypes = string> {
[key: string]: VALUES;
}
interface IMetadataHolder<VALUES extends AllowedMetadataValueTypes = string> {
meta?: IMetadata<VALUES>
}
type AllowedMetadataValueTypes = string | boolean | number | undefined;
type MangaMetadataKeys = keyof IReaderSettings;
type AppMetadataKeys = MangaMetadataKeys;
type MetadataKeyValuePair = [AppMetadataKeys, AllowedMetadataValueTypes];
interface IMangaCard {
id: number
title: string
@@ -61,6 +77,7 @@ interface IMangaCard {
unreadCount?: number
downloadCount?: number
inLibrary?: boolean
meta?: IMetadata
}
interface IManga {
@@ -80,8 +97,9 @@ interface IManga {
inLibrary: boolean
source: ISource
realUrl: string
meta: IMetadata
realUrl: string
freshData: boolean
unreadCount?: number
downloadCount?: number
@@ -107,6 +125,7 @@ interface IChapter {
chapterCount: number
pageCount: number
downloaded: boolean
meta: IAppMetadata
}
interface IMangaChapter {
@@ -126,6 +145,7 @@ interface ICategory {
order: number
name: string
default: boolean
meta: IAppMetadata
}
interface INavbarOverride {