From c635fc3fc4467f3e561e236d46534b6be735a645 Mon Sep 17 00:00:00 2001
From: dec05eba <dec05eba@protonmail.com>
Date: Tue, 6 Aug 2019 04:03:53 +0200
Subject: Sleep until events when viewing manga

---
 src/QuickMedia.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 3cfbc08..c16ee2d 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -439,7 +439,7 @@ namespace QuickMedia {
             json_chapters = Json::Value(Json::objectValue);
             json_chapter = Json::Value(Json::objectValue);
         }
-        json_chapter["current"] = latest_read;
+        json_chapter["current"] = std::min(latest_read, num_images);
         json_chapter["total"] = num_images;
         json_chapters[chapter_title] = json_chapter;
         if(!save_manga_progress_json(content_storage_file, content_storage_json)) {
@@ -460,7 +460,7 @@ namespace QuickMedia {
 
         // TODO: Show to user if a certain page is missing (by checking page name (number) and checking if some are skipped)
         while (current_page == Page::IMAGES) {
-            while (window.pollEvent(event)) {
+            if(window.waitEvent(event)) {
                 if (event.type == sf::Event::Closed) {
                     current_page = Page::EXIT;
                 } else if(event.type == sf::Event::Resized) {
-- 
cgit v1.2.3-70-g09d2