-
Notifications
You must be signed in to change notification settings - Fork 197
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
base: master
Are you sure you want to change the base?
Improve plugin settings, standardized captcha errors, hide chapters that no longer exist #1389
Conversation
…hat no longer exist
@@ -32,6 +33,7 @@ export const createTables = () => { | |||
|
|||
db.transaction(tx => { | |||
tx.executeSql(createRepositoryTableQuery); | |||
tx.executeSql(addHiddenColumnQuery); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Db migration
const chaptersToHide = existingChapters.filter( | ||
c => !chapters.some(ch => ch.path === c.path), | ||
); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
const unloadPlugin = (pluginId: string) => { | ||
plugins[pluginId] = undefined; | ||
}; |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
setting?.type === 'Switch' ? ( | ||
<SwitchItem | ||
key={key} | ||
label={setting.label} | ||
value={!!formValues[key]} | ||
onPress={() => handleChange(key, formValues[key] ? '' : 'true')} | ||
theme={theme} | ||
/> | ||
) : ( |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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
<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'); | ||
}} | ||
/> |
There was a problem hiding this comment.
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}> |
There was a problem hiding this comment.
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
const chaptersToHide = existingChapters.filter( | ||
c => !chapters.some(ch => ch.path === c.path), | ||
); |
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
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 🔥
https://youtu.be/lysW01_UKpQ