Skip to content

Commit 96399a0

Browse files
feat: Restore ComicHubFree API integration and update search functionality
1 parent 5abf03a commit 96399a0

File tree

3 files changed

+24
-40
lines changed

3 files changed

+24
-40
lines changed

src/Redux/Actions/GlobalActions.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -526,17 +526,17 @@ export const searchComic =
526526
data: item.data,
527527
link: `${host}/comic/${item.data}`,
528528
}));
529-
// } else if (source === 'comichubfree') {
530-
// const host = 'https://comichubfree.com';
531-
// url = `${host}/ajax/search?key=${encodeURIComponent(queryValue)}`;
532-
// const response = await APICaller.get(url);
533-
// const json = response?.data || [];
534-
535-
// formatted = json.map(item => ({
536-
// title: item.title,
537-
// data: item.slug,
538-
// link: `${host}/comic/${item.slug}`,
539-
// }));
529+
} else if (source === 'comichubfree') {
530+
const host = 'https://comichubfree.com';
531+
url = `${host}/ajax/search?key=${encodeURIComponent(queryValue)}`;
532+
const response = await APICaller.get(url);
533+
const json = response?.data || [];
534+
535+
formatted = json.map(item => ({
536+
title: item.title,
537+
data: item.slug,
538+
link: `${host}/comic/${item.slug}`,
539+
}));
540540
} else if (source === 'readallcomics') {
541541
const host = 'https://readallcomics.com';
542542
url = `${host}/?story=${queryValue.replace(/ /g, '+')}&s=&type=comic`;

src/Screens/Search/Search.js

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export function Search({navigation}) {
5757
// https://readcomicsonline.ru/comic/{comic-name}/{chapter-name}
5858
let link = searchTerm.trim();
5959
if (
60-
// !link.startsWith('https://comichubfree.com/comic/') &&
61-
(!link.startsWith('https://readcomicsonline.ru/comic/') &&
60+
(!link.startsWith('https://comichubfree.com/comic/') &&
61+
!link.startsWith('https://readcomicsonline.ru/comic/') &&
6262
!link.startsWith('https://readallcomics.com/category/')) ||
6363
(!link.includes('comic/') && !link.includes('category/'))
6464
) {
@@ -67,34 +67,18 @@ export function Search({navigation}) {
6767
return;
6868
}
6969

70-
// comichubfreeResult,
71-
const [readcomicsonlineResult, readallcomicsResult] = await Promise.all([
72-
dispatch(searchComic(link, 'readcomicsonline')),
73-
// dispatch(searchComic(link, 'comichubfree')),
74-
dispatch(searchComic(link, 'readallcomics')),
75-
]);
70+
const [readcomicsonlineResult, comichubfreeResult, readallcomicsResult] =
71+
await Promise.all([
72+
dispatch(searchComic(link, 'readcomicsonline')),
73+
dispatch(searchComic(link, 'comichubfree')),
74+
dispatch(searchComic(link, 'readallcomics')),
75+
]);
7676

77-
console.log('readcomicsonlineResult', {
78-
readcomicsonlineResult,
79-
// comichubfreeResult,
80-
readallcomicsResult,
77+
setSearchData({
78+
ReadAllComic: readallcomicsResult ?? [],
79+
ComicHub: comichubfreeResult ?? [],
80+
ComicOnline: readcomicsonlineResult ?? [],
8181
});
82-
83-
// || comichubfreeResult
84-
if (readcomicsonlineResult) {
85-
if (
86-
// comichubfreeResult.length == 0 &&
87-
readcomicsonlineResult.length == 0 &&
88-
readallcomicsResult.length == 0
89-
) {
90-
Alert.alert('No results found');
91-
}
92-
setSearchData({
93-
ReadAllComic: readallcomicsResult,
94-
// ComicHub: comichubfreeResult,
95-
ComicOnline: readcomicsonlineResult,
96-
});
97-
}
9882
return;
9983
}
10084
// remove the last element if present in the link like 5, 100, etc

src/Utils/APIs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const ComicHostName = {
22
readcomicsonline: 'https://readcomicsonline.ru/',
3-
// comichubfree: 'https://comichubfree.com/',
3+
comichubfree: 'https://comichubfree.com/',
44
readallcomics: 'https://readallcomics.com/',
55
};
66
export const AnimeHostName = {

0 commit comments

Comments
 (0)