Skip to content

Commit

Permalink
+ button to load chapter in notification
Browse files Browse the repository at this point in the history
  • Loading branch information
ejnshtein committed Feb 5, 2019
1 parent 291accb commit a501291
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 2 additions & 3 deletions actions/chapter-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ composer.action([
/^chapter=(\S+):read=(\S+):next=(\S+):offset=(\S+?):(\S+)$/i,
/^chapter=(\S+):read=(\S+):copy=(\S+):offset=(\S+?):(\S+)$/i
], async ctx => {
ctx.answerCbQuery('')
// console.log(ctx.match)
const chapterId = ctx.match[1]
const markedRead = ctx.match[2] === 'true'
Expand All @@ -18,8 +17,8 @@ composer.action([
const history = ctx.match[5]
let chapter = await getChapter(chapterId)
const manga = await getManga(chapter.manga_id, false)
chapter = await getFiles(chapter, manga, ctx)
if (!chapter) { return }
chapter = await getFiles(chapter, manga, ctx, offset, history)
if (!chapter) { return ctx.answerCbQuery('') }
const keyboard = [
[
{
Expand Down
8 changes: 7 additions & 1 deletion lib/get-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const FormData = require('form-data')
const cachePoll = {}
const updatePoll = {} // soon

module.exports = async (chapter, manga, ctx) => {
module.exports = async (chapter, manga, ctx, offset = 0, history = 'p=1:o=0') => {
const cachedData = await collection('chapters').findOne({ id: chapter.id }).exec()
if (cachedData) {
if (cachedData.timestamp === chapter.timestamp) {
Expand Down Expand Up @@ -118,6 +118,12 @@ module.exports = async (chapter, manga, ctx) => {
text: 'Ok!',
callback_data: 'delete'
}
],
[
{
text: 'Load chapter!',
callback_data: `chapter=${chapter.id}:read=false:copy=true:offset=${offset}:${history}`
}
]
]
}
Expand Down
8 changes: 7 additions & 1 deletion lib/store-history.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
const getUrlInMessage = require('./get-url-in-message')

module.exports = message => `<a href="${getUrlInMessage(message) || 'https://mangadex.org/search?title='}">&#8203;</a>`
module.exports = message => {
let link = 'https://mangadex.org/search?title='
try {
link = getUrlInMessage(message)
} catch (e) {}
return `<a href="${link}">&#8203;</a>`
}

0 comments on commit a501291

Please sign in to comment.