From da0ca665a6f4f455c863fec60426c9e75ed92c3d Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Fri, 8 Jan 2021 11:38:25 +0000 Subject: [PATCH] Mark entry as read when exiting reader at the end --- public/js/reader.js | 17 ++++++++++++++++- src/views/reader.html.ecr | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/public/js/reader.js b/public/js/reader.js index 321f131..c09c340 100644 --- a/public/js/reader.js +++ b/public/js/reader.js @@ -257,9 +257,24 @@ const readerComponent = () => { * @param {string} nextUrl - URL of the next entry */ nextEntry(nextUrl) { - this.saveProgress(items.length, () => { + this.saveProgress(this.items.length, () => { this.redirect(nextUrl); }); + }, + /** + * Exits the reader, and optionally sets the reading progress tp 100% + * + * @param {string} exitUrl - The Exit URL + * @param {boolean} [markCompleted] - Whether we should mark the + * reading progress to 100% + */ + exitReader(exitUrl, markCompleted = false) { + if (!markCompleted) { + return this.redirect(exitUrl); + } + this.saveProgress(this.items.length, () => { + this.redirect(exitUrl); + }); } }; } diff --git a/src/views/reader.html.ecr b/src/views/reader.html.ecr index 91beaf3..afeb510 100644 --- a/src/views/reader.html.ecr +++ b/src/views/reader.html.ecr @@ -36,7 +36,7 @@ <%- if next_entry_url -%> <%- else -%> - + <%- end -%> @@ -91,7 +91,7 @@