Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve plugin settings, standardized captcha errors, hide chapters that no longer exist #1389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Soopyboo32
Copy link
Contributor

@Soopyboo32 Soopyboo32 commented Jan 4, 2025

@@ -32,6 +33,7 @@ export const createTables = () => {

db.transaction(tx => {
tx.executeSql(createRepositoryTableQuery);
tx.executeSql(addHiddenColumnQuery);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Db migration

Comment on lines +31 to +33
const chaptersToHide = existingChapters.filter(
c => !chapters.some(ch => ch.path === c.path),
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hide chapters if they are known but not in the list given

@@ -77,6 +77,7 @@ const getLibraryWithCategoryQuery = `
SUM(unread) as chaptersUnread, SUM(isDownloaded) as chaptersDownloaded,
novelId, MAX(readTime) as lastReadAt, MAX(updatedTime) as lastUpdatedAt
FROM Chapter
WHERE hidden = 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont show hidden chapters for unread counts

@@ -14,23 +14,23 @@ const getChaptersReadCountQuery = `
FROM Chapter
JOIN Novel
ON Chapter.novelId = Novel.id
WHERE Chapter.unread = 0 AND Novel.inLibrary = 1
WHERE Chapter.unread = 0 AND Novel.inLibrary = 1 AND Chapter.hidden = 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont show hidden chapters for stats

@@ -157,6 +157,7 @@ export default function usePlugins() {
name: _plg.name,
version: _plg.version,
hasUpdate: false,
hasSettings: !!_plg.pluginSettings,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the hasSettings value on plugin update, not only plugin installation

@@ -44,9 +44,25 @@ export const fetchApi = async (
init?: FetchInit,
): Promise<Response> => {
init = makeInit(init);
return await fetch(url, init);
return await fetch(url, init).then(checkCloudflareError);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standardized cloudflare error handling across all plugins

Comment on lines +151 to +153
const unloadPlugin = (pluginId: string) => {
plugins[pluginId] = undefined;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

option to unload plugin so you dont need to restart app to apply plugin settings


interface PluginSetting {
value: string;
label: string;
type?: 'Switch';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add switch setting type

@@ -75,6 +78,7 @@ const SourceSettingsModal: React.FC<SourceSettingsModal> = ({
Object.entries(formValues).forEach(([key, value]) => {
storage.set(key, value);
});
unloadPlugin(pluginId);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unload plugin on settings change (itll get re-loaded when needed) as this allows re-initialization of plugin settings

Comment on lines +120 to +128
setting?.type === 'Switch' ? (
<SwitchItem
key={key}
label={setting.label}
value={!!formValues[key]}
onPress={() => handleChange(key, formValues[key] ? '' : 'true')}
theme={theme}
/>
) : (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch setting type

(saves the values as either an empty string or the string "true" as plugin settings are all strings, and by making false falsy it will work just as well)

@@ -71,7 +71,7 @@ const Novel = ({ route, navigation }: NovelScreenProps) => {
lastRead,
novelSettings: {
sort = defaultChapterSort,
filter = '',
filter = 'AND hidden=0',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by default hide hidden chapters

@@ -223,7 +223,11 @@ const NovelInfoHeader = ({
) : null}
<IconButton
icon="filter-variant"
iconColor={filter ? filterColor(theme.isDark) : theme.onSurface}
iconColor={
filter.trim() !== 'AND hidden=0'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cus AND hidden=0 is default check for not eq that

Comment on lines +95 to +104
<Checkbox
theme={theme}
label={getString('novelScreen.bottomSheet.filters.dontExist')}
status={!filter.match('AND hidden=0')}
onPress={() => {
filter.match('AND hidden=0')
? filterChapters(filter.replace(/ ?AND hidden=0/, ''))
: filterChapters(filter + ' AND hidden=0');
}}
/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkbox to remove the AND hidden=0 check (to show hidden chapters)

@@ -184,7 +194,7 @@ const ChaptersSettingsSheet = ({
);

return (
<BottomSheet snapPoints={[240]} bottomSheetRef={bottomSheetRef}>
<BottomSheet snapPoints={[280]} bottomSheetRef={bottomSheetRef}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sheet needs to be taller cus new option

Comment on lines +90 to +92
const chaptersToHide = existingChapters.filter(
c => !chapters.some(ch => ch.path === c.path),
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another place where hiding chapters that are in db but not in response

@@ -124,7 +124,7 @@
"updatedTo": "Updated to %{version}",
"settings": {
"title": "Plugin Settings",
"description": "Fill in the plugin settings. Restart app to apply the settings."
"description": "Fill in the plugin settings."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont need to restart the app anymore 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant