Skip to content

Commit

Permalink
Fix: Bug fixes (#969)
Browse files Browse the repository at this point in the history
* fix: Range selection text

* fix: backup novel transaction

* fix: not show fetch plugins error

* fix: Filter button color

* adjust: plugin detail weight

* minor: plugin tab bar ripple color

* fix: category card buttons
  • Loading branch information
nyagami authored Feb 24, 2024
1 parent ca688bb commit 21e46d5
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 35 deletions.
6 changes: 3 additions & 3 deletions android/app/src/main/assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ class TextToSpeech {
this.stop();
} else {
this.icon.classList.add('speak');
const selected = window.getSelection().anchorNode;
if (selected) {
const selection = window.getSelection();
if (selection.type === 'Range') {
if (this.leaf && this.TTSWrapper) {
this.TTSWrapper.replaceWith(this.leaf);
}
this.leaf = selected;
this.leaf = selection.anchorNode;
this.makeLeafSpeakable();
this.speak();
} else {
Expand Down
17 changes: 11 additions & 6 deletions src/database/queries/NovelQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,19 @@ const restoreObjectQuery = (table: string, obj: any) => {
`;
};

export const _restoreNovelAndChapters = (backupNovel: BackupNovel) => {
export const _restoreNovelAndChapters = async (backupNovel: BackupNovel) => {
const { chapters, ...novel } = backupNovel;
await new Promise(resolve => {
db.transaction(tx => {
tx.executeSql('DELETE FROM Novel WHERE id = ?', [novel.id]);
tx.executeSql(
restoreObjectQuery('Novel', novel),
Object.values(novel) as string[] | number[],
() => resolve(null),
);
});
});
db.transaction(tx => {
tx.executeSql('DELETE FROM Novel WHERE id = ?', [novel.id]);
tx.executeSql(
restoreObjectQuery('Novel', novel),
Object.values(novel) as string[] | number[],
);
for (const chapter of chapters) {
tx.executeSql(
restoreObjectQuery('Chapter', chapter),
Expand Down
11 changes: 1 addition & 10 deletions src/plugins/pluginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { isUrlAbsolute } from './helpers/isAbsoluteUrl';
import { fetchApi, fetchFile, fetchText } from './helpers/fetch';
import { defaultCover } from './helpers/constants';
import { encode, decode } from 'urlencode';
import { getString } from '@strings/translations';
import TextFile from '@native/TextFile';

const pluginsFilePath = PluginDownloadFolder + '/plugins.json';
Expand Down Expand Up @@ -131,15 +130,7 @@ const fetchPlugins = async () => {

const availablePlugins: Record<Language, Array<PluginItem>> = await fetch(
`https://raw.githubusercontent.com/${githubUsername}/${githubRepository}/beta-dist/.dist/plugins.min.json`,
)
.then(res => res.json())
.catch(() => {
throw new Error(
`${getString(
'browseScreen.pluginsHostError',
)}: ${githubUsername}/${githubRepository}`,
);
});
).then(res => res.json());
return availablePlugins;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ const FilterBottomSheet: React.FC<BottomSheetProps> = ({
/>
<Button
title={getString('common.filter')}
textColor={theme.onSurface}
textColor={theme.onPrimary}
onPress={() => {
setFilters(selectedFilters);
filterSheetRef?.current?.collapse();
filterSheetRef?.current?.close();
}}
mode="contained"
/>
Expand Down
3 changes: 0 additions & 3 deletions src/screens/Categories/CategoriesScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@ const CategoriesScreen = () => {

const [isLoading, setIsLoading] = useState(true);
const [categories, setCategories] = useState<Category[]>();
// const [error, setError] = useState();

const getCategories = async () => {
try {
let res = await getCategoriesFromDb();

setCategories(res);
} catch (err) {
// setError(error?.message);
} finally {
setIsLoading(false);
}
Expand Down
20 changes: 12 additions & 8 deletions src/screens/Categories/components/CategoryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ const CategoryCard: React.FC<CategoryCardProps> = ({
color={theme.onSurface}
onPress={() => updateCategorySort(categoryIndex, categoryIndex - 1)}
theme={theme}
disabled={categoryIndex <= 0}
disabled={
categoryIndex <= 0 || (categoryIndex === 1 && category.id === 2)
}
/>
<IconButton
name="menu-down"
Expand All @@ -99,13 +101,15 @@ const CategoryCard: React.FC<CategoryCardProps> = ({
onPress={showCategoryModal}
theme={theme}
/>
<IconButton
name="delete-outline"
color={theme.onSurface}
style={styles.manageBtn}
onPress={showDeleteCategoryModal}
theme={theme}
/>
{categoryIndex !== 0 && category.id !== 2 && (
<IconButton
name="delete-outline"
color={theme.onSurface}
style={styles.manageBtn}
onPress={showDeleteCategoryModal}
theme={theme}
/>
)}
</View>
</View>
<Portal>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/browse/BrowseScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const BrowseScreen = ({ navigation }: BrowseScreenProps) => {
)}
inactiveColor={theme.secondary}
activeColor={theme.primary}
pressColor={theme.rippleColor}
android_ripple={{ color: theme.rippleColor }}
/>
)}
/>
Expand Down
1 change: 0 additions & 1 deletion src/screens/browse/components/PluginCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ const styles = StyleSheet.create({
addition: {
textAlign: 'left',
fontSize: 12,
fontWeight: '300',
},
name: {
fontWeight: 'bold',
Expand Down
1 change: 0 additions & 1 deletion strings/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export interface StringMap {
'browseScreen.migration.selectSourceDesc': 'string';
'browseScreen.noSource': 'string';
'browseScreen.pinned': 'string';
'browseScreen.pluginsHostError': 'string';
'browseScreen.removeFromLibrary': 'string';
'browseScreen.searchbar': 'string';
'browseScreen.selectNovel': 'string';
Expand Down

0 comments on commit 21e46d5

Please sign in to comment.