Skip to content

Commit ec2948b

Browse files
feat: update getComics function to handle empty type and add all-comic support in HomeType
1 parent 446ca69 commit ec2948b

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/Screens/Comic/APIs/Home.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const getComics = async (hostName, page, type = null) => {
1010
);
1111

1212
// Construct the URL and parameters based on the host, type, and page
13-
let params = `${type}?page=${page}`;
13+
let params = `${type ?? ''}?page=${page}`;
1414
if (
1515
(page === 1 || page == null) &&
1616
hostName === ComicHostName.readcomicsonline
@@ -114,6 +114,7 @@ const HomeType = {
114114
getComics(ComicHostName.comichubfree, 1, 'hot-comic'),
115115
getComics(ComicHostName.comichubfree, 1, 'new-comic'),
116116
getComics(ComicHostName.comichubfree, 1, 'popular-comic'),
117+
getComics(ComicHostName.comichubfree, 1),
117118
],
118119
};
119120

@@ -124,30 +125,38 @@ export const getComicsHome = async (
124125
) => {
125126
setLoading(true);
126127
try {
127-
const [hot_comic_updates, latest_release, most_viewed] = await Promise.all(
128-
HomeType[type],
129-
);
128+
const [hot_comic_updates, latest_release, most_viewed, all_comic] =
129+
await Promise.all(HomeType[type]);
130130

131131
const ComicHomeList = {};
132132

133-
if (hot_comic_updates) {
134-
ComicHomeList['hot-comic-updates'] = {
135-
title: 'Hot Comic',
136-
data: hot_comic_updates?.comicsData,
137-
hostName: ComicHostName.readcomicsonline,
138-
lastPage: hot_comic_updates?.lastPage,
133+
if (all_comic) {
134+
ComicHomeList['all-comic'] = {
135+
title: 'Latest Comic',
136+
data: all_comic?.comicsData,
137+
hostName: ComicHostName.comichubfree,
138+
lastPage: all_comic?.lastPage,
139139
};
140140
}
141141

142142
if (latest_release) {
143143
ComicHomeList['latest-release'] = {
144-
title: 'Latest Release',
144+
title: type === 'comichubfree' ? 'New Comic' : 'Latest Release',
145145
data: latest_release?.comicsData,
146146
hostName: ComicHostName.readcomicsonline,
147147
lastPage: latest_release?.lastPage,
148148
};
149149
}
150150

151+
if (hot_comic_updates) {
152+
ComicHomeList['hot-comic-updates'] = {
153+
title: 'Hot Comic',
154+
data: hot_comic_updates?.comicsData,
155+
hostName: ComicHostName.readcomicsonline,
156+
lastPage: hot_comic_updates?.lastPage,
157+
};
158+
}
159+
151160
if (most_viewed) {
152161
ComicHomeList['most-viewed'] = {
153162
title: 'Most Viewed',

src/Screens/Comic/APIs/constance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const HomePageCardClasses = {
6767
},
6868
},
6969
comichubfree: {
70-
'latest-release': {
70+
'all-comic': {
7171
cardClass: '.episode-details.box-content',
7272
cardTitleClass: '.box-info h3.series-title',
7373
cardLinkClass: '.box-info h3.series-title a',

0 commit comments

Comments
 (0)