2021-03-26 04:17:02 +04:30
|
|
|
/*
|
|
|
|
|
* 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
|
2023-05-18 13:17:41 +02:00
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
2021-01-26 23:32:12 +03:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
import { OverridableComponent } from '@mui/material/OverridableComponent';
|
2024-04-14 15:50:12 +02:00
|
|
|
import { SvgIconTypeMap } from '@mui/material/SvgIcon';
|
2023-09-25 23:32:26 +02:00
|
|
|
import {
|
2023-10-29 02:01:59 +02:00
|
|
|
GetServerSettingsQuery,
|
2024-07-03 23:15:50 +02:00
|
|
|
GetSourceBrowseQuery,
|
|
|
|
|
GetSourceSettingsQuery,
|
2023-09-25 23:32:26 +02:00
|
|
|
MetaType,
|
|
|
|
|
SourcePreferenceChangeInput,
|
|
|
|
|
} from '@/lib/graphql/generated/graphql.ts';
|
2024-09-05 12:20:21 +02:00
|
|
|
import { AppTheme } from '@/lib/ui/AppThemes.ts';
|
2024-09-30 04:01:23 +02:00
|
|
|
import { SortSettings } from '@/screens/Migration.types.ts';
|
2024-10-05 19:33:09 +02:00
|
|
|
import { TranslationKey } from '@/Base.types.ts';
|
2024-10-05 19:21:26 +02:00
|
|
|
import { MangaMetadataKeys } from '@/modules/manga/MangaCard.types.tsx';
|
2024-10-05 19:33:09 +02:00
|
|
|
import { LibraryOptions, MetadataLibrarySettings } from '@/modules/library/Library.types.ts';
|
2023-02-24 16:40:37 +01:00
|
|
|
|
2024-05-08 04:01:23 +02:00
|
|
|
export interface IPos {
|
|
|
|
|
type: 'selectState' | 'textState' | 'checkBoxState' | 'triState' | 'sortState';
|
|
|
|
|
position: number;
|
|
|
|
|
state: any;
|
|
|
|
|
group?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type SavedSourceSearch = { query?: string; filters?: IPos[] };
|
|
|
|
|
|
|
|
|
|
export interface ISourceMetadata {
|
|
|
|
|
savedSearches?: Record<string, SavedSourceSearch>;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-17 03:40:55 +02:00
|
|
|
export interface ICategoryMetadata extends LibraryOptions {}
|
|
|
|
|
|
2024-07-03 23:15:50 +02:00
|
|
|
export type SourceFilters = GetSourceBrowseQuery['source']['filters'][number];
|
2022-03-04 01:25:10 +00:00
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IMetadataMigration {
|
2023-02-06 10:06:33 +01:00
|
|
|
appKeyPrefix?: { oldPrefix: string; newPrefix: string };
|
2023-02-17 13:10:44 +01:00
|
|
|
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;
|
|
|
|
|
}[];
|
2023-02-06 10:06:33 +01:00
|
|
|
keys?: { oldKey: string; newKey: string }[];
|
2023-01-06 18:19:45 +01:00
|
|
|
}
|
|
|
|
|
|
2023-04-22 11:34:19 +02:00
|
|
|
export type Metadata<Keys extends string = string, Values = string> = {
|
|
|
|
|
[key in Keys]: Values;
|
|
|
|
|
};
|
2023-01-06 17:15:29 +01:00
|
|
|
|
2023-09-08 00:44:01 +02:00
|
|
|
export type GqlMetaHolder = { meta?: MetaType[] };
|
|
|
|
|
|
2023-04-22 11:34:19 +02:00
|
|
|
export type MetadataHolder<Keys extends string = string, Values = string> = {
|
|
|
|
|
meta?: Metadata<Keys, Values>;
|
|
|
|
|
};
|
2023-01-06 17:15:29 +01:00
|
|
|
|
2024-09-17 03:40:55 +02:00
|
|
|
export type AllowedMetadataValueTypes = string | boolean | number | undefined | null;
|
2023-01-06 17:15:29 +01:00
|
|
|
|
2023-11-19 21:17:35 +01:00
|
|
|
export type MetadataServerSettingKeys = keyof MetadataServerSettings;
|
|
|
|
|
|
2023-03-04 22:21:24 +05:30
|
|
|
export type SearchMetadataKeys = keyof ISearchSettings;
|
|
|
|
|
|
2024-05-08 04:01:23 +02:00
|
|
|
export type SourceMetadataKeys = keyof ISourceMetadata;
|
|
|
|
|
|
2024-09-17 03:40:55 +02:00
|
|
|
export type CategoryMetadataKeys = keyof ICategoryMetadata;
|
|
|
|
|
|
|
|
|
|
export type AppMetadataKeys =
|
|
|
|
|
| MetadataServerSettingKeys
|
|
|
|
|
| MangaMetadataKeys
|
|
|
|
|
| SearchMetadataKeys
|
|
|
|
|
| SourceMetadataKeys
|
|
|
|
|
| CategoryMetadataKeys;
|
2023-01-06 17:15:29 +01:00
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export type MetadataKeyValuePair = [AppMetadataKeys, AllowedMetadataValueTypes];
|
2023-01-06 17:15:29 +01:00
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface INavbarOverride {
|
2023-02-06 10:06:33 +01:00
|
|
|
status: boolean;
|
|
|
|
|
value: any;
|
2021-03-29 02:47:51 +04:30
|
|
|
}
|
2021-05-15 17:18:57 +04:30
|
|
|
|
2024-03-16 16:21:15 +01:00
|
|
|
export type MetadataDownloadSettings = {
|
2023-11-19 21:17:35 +01:00
|
|
|
deleteChaptersManuallyMarkedRead: boolean;
|
2023-12-05 22:20:13 +01:00
|
|
|
deleteChaptersWhileReading: number;
|
2023-11-19 21:17:35 +01:00
|
|
|
deleteChaptersWithBookmark: boolean;
|
2024-02-16 19:16:18 +01:00
|
|
|
downloadAheadLimit: number;
|
2024-03-16 16:21:15 +01:00
|
|
|
};
|
2023-12-27 18:08:16 +01:00
|
|
|
|
2024-03-16 16:21:15 +01:00
|
|
|
export type MetadataClientSettings = {
|
2024-03-06 23:07:48 +01:00
|
|
|
devices: string[];
|
2024-03-16 16:21:15 +01:00
|
|
|
};
|
2024-03-16 14:02:54 +01:00
|
|
|
|
2024-03-16 16:21:15 +01:00
|
|
|
export type MetadataMigrationSettings = {
|
2024-04-20 23:26:34 +02:00
|
|
|
migrateChapters: boolean;
|
|
|
|
|
migrateCategories: boolean;
|
2024-04-20 23:51:47 +02:00
|
|
|
migrateTracking: boolean;
|
2024-03-16 14:02:54 +01:00
|
|
|
deleteChapters: boolean;
|
2024-09-30 04:01:23 +02:00
|
|
|
migrateSortSettings: SortSettings;
|
2023-11-19 21:17:35 +01:00
|
|
|
};
|
|
|
|
|
|
2024-03-23 23:44:46 +01:00
|
|
|
export type MetadataBrowseSettings = {
|
|
|
|
|
hideLibraryEntries: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
2024-04-20 22:14:01 +02:00
|
|
|
export type MetadataTrackingSettings = {
|
|
|
|
|
updateProgressAfterReading: boolean;
|
2024-04-20 23:15:02 +02:00
|
|
|
updateProgressManualMarkRead: boolean;
|
2024-04-20 22:14:01 +02:00
|
|
|
};
|
|
|
|
|
|
2024-05-07 00:30:22 +02:00
|
|
|
export type MetadataUpdateSettings = {
|
|
|
|
|
webUIInformAvailableUpdate: boolean;
|
2024-05-07 00:37:01 +02:00
|
|
|
serverInformAvailableUpdate: boolean;
|
2024-05-07 00:30:22 +02:00
|
|
|
};
|
|
|
|
|
|
2024-09-05 12:20:21 +02:00
|
|
|
export type MetadataThemeSettings = {
|
|
|
|
|
customThemes: Record<string, AppTheme>;
|
2024-09-10 14:45:08 +02:00
|
|
|
mangaThumbnailBackdrop: boolean;
|
2024-09-05 12:20:21 +02:00
|
|
|
};
|
|
|
|
|
|
2024-03-16 16:21:15 +01:00
|
|
|
export type MetadataServerSettings = MetadataDownloadSettings &
|
|
|
|
|
MetadataLibrarySettings &
|
|
|
|
|
MetadataClientSettings &
|
2024-03-23 23:44:46 +01:00
|
|
|
MetadataMigrationSettings &
|
2024-04-20 22:14:01 +02:00
|
|
|
MetadataBrowseSettings &
|
2024-05-07 00:30:22 +02:00
|
|
|
MetadataTrackingSettings &
|
2024-09-05 12:20:21 +02:00
|
|
|
MetadataUpdateSettings &
|
|
|
|
|
MetadataThemeSettings;
|
2024-03-16 16:21:15 +01:00
|
|
|
|
2023-03-04 22:21:24 +05:30
|
|
|
export interface ISearchSettings {
|
|
|
|
|
ignoreFilters: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-03 23:15:50 +02:00
|
|
|
export type SourcePreferences = GetSourceSettingsQuery['source']['preferences'][number];
|
2021-09-13 19:18:21 +04:30
|
|
|
|
2023-09-25 23:32:26 +02:00
|
|
|
export interface PreferenceProps {
|
|
|
|
|
updateValue: <Key extends keyof Omit<SourcePreferenceChangeInput, 'position'>>(
|
|
|
|
|
type: Key,
|
|
|
|
|
value: SourcePreferenceChangeInput[Key],
|
|
|
|
|
) => void;
|
2021-08-06 04:53:53 +04:30
|
|
|
}
|
|
|
|
|
|
2023-09-25 23:32:26 +02:00
|
|
|
export type TwoStatePreferenceProps = (CheckBoxPreferenceProps | SwitchPreferenceCompatProps) & {
|
2021-09-13 19:18:21 +04:30
|
|
|
// intetnal props
|
2023-09-25 23:32:26 +02:00
|
|
|
twoStateType: 'Switch' | 'Checkbox';
|
|
|
|
|
};
|
2021-11-29 19:08:02 +03:30
|
|
|
|
2023-09-25 23:32:26 +02:00
|
|
|
export type CheckBoxPreferenceProps = PreferenceProps &
|
|
|
|
|
ExtractByKeyValue<SourcePreferences, '__typename', 'CheckBoxPreference'>;
|
2021-11-29 19:08:02 +03:30
|
|
|
|
2023-09-25 23:32:26 +02:00
|
|
|
export type SwitchPreferenceCompatProps = PreferenceProps &
|
|
|
|
|
ExtractByKeyValue<SourcePreferences, '__typename', 'SwitchPreference'>;
|
2021-11-29 19:08:02 +03:30
|
|
|
|
2023-09-25 23:32:26 +02:00
|
|
|
export type ListPreferenceProps = PreferenceProps &
|
|
|
|
|
ExtractByKeyValue<SourcePreferences, '__typename', 'ListPreference'>;
|
2021-11-29 19:08:02 +03:30
|
|
|
|
2023-09-25 23:32:26 +02:00
|
|
|
export type MultiSelectListPreferenceProps = PreferenceProps &
|
|
|
|
|
ExtractByKeyValue<SourcePreferences, '__typename', 'MultiSelectListPreference'>;
|
2021-09-13 19:18:21 +04:30
|
|
|
|
2023-09-25 23:32:26 +02:00
|
|
|
export type EditTextPreferenceProps = PreferenceProps &
|
|
|
|
|
ExtractByKeyValue<SourcePreferences, '__typename', 'EditTextPreference'>;
|
2021-10-24 21:34:38 +05:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface NavbarItem {
|
2023-02-06 10:06:33 +01:00
|
|
|
path: string;
|
2023-03-23 13:59:32 +01:00
|
|
|
title: TranslationKey;
|
2023-02-06 10:06:33 +01:00
|
|
|
SelectedIconComponent: OverridableComponent<SvgIconTypeMap<{}, 'svg'>>;
|
|
|
|
|
IconComponent: OverridableComponent<SvgIconTypeMap<{}, 'svg'>>;
|
|
|
|
|
show: 'mobile' | 'desktop' | 'both';
|
2021-10-24 21:34:38 +05:30
|
|
|
}
|
2021-11-10 23:04:04 +03:30
|
|
|
|
2023-10-29 02:01:59 +02:00
|
|
|
export type ServerSettings = GetServerSettingsQuery['settings'];
|