Skip to content

Commit

Permalink
Updated read markers
Browse files Browse the repository at this point in the history
  • Loading branch information
Mug committed Oct 27, 2022
1 parent f03f988 commit 7cd83c4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/Chapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ export class ChapterDisplay extends React.Component {

//TODO: Sort by oneshot-volume-chapter (see reader/api.js line 241)
this.setState({
chapter: c.data[0]
chapter: ch
});
});
}
Expand Down Expand Up @@ -1315,7 +1315,8 @@ export class ChapterDisplay extends React.Component {

if (user != null) {
console.log("onread");
API.readChapter(chapter.getId())
const manga = chapter.GetRelationship("manga")[0];
API.readChapter(manga.getId(),[chapter.getId()],[])
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Manga.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class ChapterList extends React.Component {
if (chapterRead.includes(chapter.id)) {
return (
<span className="clickable" title="Mark as unread" onClick={(e) => {
API.unreadChapter(chapter.id);
API.readChapter(manga.getId(),[],[chapter.id]);

const arr = this.state.chapterRead;

Expand All @@ -222,7 +222,7 @@ class ChapterList extends React.Component {
} else {
return (
<span className="clickable" title="Mark as read" onClick={(e) => {
API.readChapter(chapter.id);
API.readChapter(manga.getId(),[chapter.id],[]);

const arr = this.state.chapterRead;
arr.push(chapter.id);
Expand Down
12 changes: 5 additions & 7 deletions src/MangaDexAPI/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,13 @@ class DexFS {
const req = await axios.get(`${CORS_BYPASS}https://api.mangadex.org/manga/${mangaId}/read`);
return APIResponseGen(req.data);
}
async readChapter(chapterId) {
const req = await axios.post(`${CORS_BYPASS}https://api.mangadex.org/chapter/${chapterId}/read`);
async readChapter(mangaId,readChapterIds,unreadChapterIds) {
const req = await axios.post(`${CORS_BYPASS}https://api.mangadex.org/manga/${mangaId}/read`, { params: {
chapterIdsRead: readChapterIds,
chapterIdsUnread: unreadChapterIds
}});
return APIResponseGen(req.data);
}
async unreadChapter(chapterId) {
const req = await axios.delete(`${CORS_BYPASS}https://api.mangadex.org/chapter/${chapterId}/read`);
return APIResponseGen(req.data);
}


async cover(manga, custom={}, limit=100, offset=0) {
var params = {
Expand Down

0 comments on commit 7cd83c4

Please sign in to comment.