Move to Zustand and add Filters to web_test (#1077)

* Moved to zustand and started refactored filters

- Move from redux to zustand
- Refactor Filters typings and add some helper types
- Add Filters button and Picker/Switch filter options
- Fixed Syosetu typings

* Add rule consistent-type-definitions

- Add consistent-type-definitions eslint rule to force consistent use of types instead of interfaces
- Run eslint to auto-change every interface to types

https://dev.to/atheodosiou/types-vs-interfaces-in-typescript-making-the-right-choice-48a4
https://www.youtube.com/watch?v=zM9UPcIyyhQ

* Add other filters and refactor

- Move Dialog to FiltersDialog
- CheckboxFilter, TextFilter, XCheckboxFilter added
- Added TripleCheckbox and TripleSwitch as tri-state checkbox/switch items using Mui stylings

* TriStateCheckbox/Switch refactor

- Change name of TripleSwitch and TripleCheckbox to TriState
- Change slightly TriStateSwitch and StyledSwitch styles
- Add option to change into TriStateSwitches via `localStorage` value `useSwitches`

* Refactor code and fix issues

* fix: prettier

---------

Co-authored-by: nyagami <hoangquan05112002@gmail.com>
This commit is contained in:
Marcin Majewski
2024-08-18 17:31:41 +02:00
committed by GitHub
parent eb5522b066
commit b2caf26da3
73 changed files with 1914 additions and 916 deletions
+4 -4
View File
@@ -367,14 +367,14 @@ class LnMTLPlugin implements Plugin.PagePlugin {
export default new LnMTLPlugin();
interface ChapterEntry {
type ChapterEntry = {
number: number;
title: string;
slug: string;
created_at: string;
}
};
interface VolumeEntry {
type VolumeEntry = {
id: string;
title: string;
}
};
+2 -2
View File
@@ -369,9 +369,9 @@ class RanobesPlugin implements Plugin.PagePlugin {
}
export default new RanobesPlugin();
interface ChapterEntry {
type ChapterEntry = {
id: number;
title: string;
date: string;
link: string;
}
};
+2 -2
View File
@@ -6,10 +6,10 @@ import { defaultCover } from '@libs/defaultCover';
import { NovelItem } from '../../test_web/static/js';
// import { isUrlAbsolute } from "@libs/isAbsoluteUrl";
interface FuzzySearchOptions {
type FuzzySearchOptions = {
caseSensitive: boolean;
sort: boolean;
}
};
// Shamelessly stolen from 'https://raw.githubusercontent.com/wouterrutgers/fuzzy-search/master/src/FuzzySearch.mjs'
// I did modify the code a fair bit, but the algorithm is still the same under the hood.
+4 -4
View File
@@ -722,18 +722,18 @@ class RoyalRoad implements Plugin.PluginBase {
export default new RoyalRoad();
interface ChapterEntry {
type ChapterEntry = {
id: number;
volumeId: number;
title: string;
date: string;
order: number;
url: string;
}
};
interface VolumeEntry {
type VolumeEntry = {
id: number;
title: string;
cover: string;
order: number;
}
};
+22 -22
View File
@@ -205,22 +205,22 @@ class WTRLAB implements Plugin.PluginBase {
} satisfies Filters;
}
interface NovelJson {
type NovelJson = {
props: Props;
page: string;
}
};
interface Props {
type Props = {
pageProps: PageProps;
__N_SSP: boolean;
}
};
interface PageProps {
type PageProps = {
serie: Serie;
server_time: Date;
}
};
interface Serie {
type Serie = {
serie_data: SerieData;
chapters: Chapter[];
recommendation: SerieData[];
@@ -231,9 +231,9 @@ interface Serie {
data: Data;
is_default: boolean;
raw_type: string;
}
};
interface Chapter {
type Chapter = {
serie_id: number;
id: number;
order: number;
@@ -242,16 +242,16 @@ interface Chapter {
name: string;
created_at: string;
updated_at: string;
}
interface ChapterData {
};
type ChapterData = {
data: ChapterContent;
}
interface ChapterContent {
};
type ChapterContent = {
title: string;
body: string;
}
};
interface SerieData {
type SerieData = {
serie_id?: number;
recommendation_id?: number;
score?: string;
@@ -273,26 +273,26 @@ interface SerieData {
from: null;
raw_id: number;
genres?: number[];
}
};
interface Data {
type Data = {
title: string;
author: string;
description: string;
image: string;
}
};
interface JsonNovel {
type JsonNovel = {
success: boolean;
data: Datum[];
}
interface Datum {
};
type Datum = {
serie: Serie;
chapters: Chapter[];
updated_at: Date;
raw_id: number;
slug: string;
data: Data;
}
};
export default new WTRLAB();
+28 -28
View File
@@ -4,35 +4,35 @@ import { Plugin } from '@typings/plugin';
import { Filters } from '@libs/filterInputs';
import { NovelStatus } from '@libs/novelStatus';
interface StringValue {
type StringValue = {
value: string;
}
};
interface BoolValue {
type BoolValue = {
value: boolean;
}
};
interface DecimalValue {
type DecimalValue = {
units: bigint;
nanos: number;
}
};
interface Timestamp {
type Timestamp = {
seconds: number;
nanos: number;
}
};
interface NovelEntry {
type NovelEntry = {
name: string;
coverUrl: string;
slug: string;
}
};
interface RelatedChapterUserInfo {
type RelatedChapterUserInfo = {
isChapterUnlocked?: BoolValue;
}
};
interface ChapterItem {
type ChapterItem = {
entityId: number;
name: string;
slug: string;
@@ -41,19 +41,19 @@ interface ChapterItem {
relatedUserInfo?: RelatedChapterUserInfo;
offset: number;
publishedAt?: Timestamp;
}
};
interface GetChapterResponse {
type GetChapterResponse = {
item?: ChapterItem;
}
};
interface ChapterGroupCounts {
type ChapterGroupCounts = {
total: number;
advance: number;
normal: number;
}
};
interface ChapterGroupItem {
type ChapterGroupItem = {
id: number;
title: string;
order: number;
@@ -61,11 +61,11 @@ interface ChapterGroupItem {
toChapterNumber?: DecimalValue;
chapterList: ChapterItem[];
counts?: ChapterGroupCounts;
}
};
interface GetChapterListResponse {
type GetChapterListResponse = {
items: ChapterGroupItem[];
}
};
enum NovelItem_Status {
Finished = 0,
@@ -74,14 +74,14 @@ enum NovelItem_Status {
All = -1,
}
interface NovelKarmaInfo {
type NovelKarmaInfo = {
isActive: boolean;
isFree: boolean;
maxFreeChapter?: DecimalValue;
canUnlockWithVip: boolean;
}
};
interface NovelItem {
type NovelItem = {
id: number;
name: string;
slug: string;
@@ -94,11 +94,11 @@ interface NovelItem {
authorName?: StringValue;
karmaInfo?: NovelKarmaInfo;
genres: string[];
}
};
interface GetNovelResponse {
type GetNovelResponse = {
item?: NovelItem;
}
};
class WuxiaWorld implements Plugin.PluginBase {
id = 'wuxiaworld';