aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-11 08:37:39 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-11 08:37:39 +0200
commit4d700aee6a9bc51fb0f5c1d92123975ee25645d1 (patch)
treee9793961890748ffa07b54eb75fa34aa00640f92
parent1be647662eb19af2e8fe27a500ac3705c3109045 (diff)
Fix watch history being broken
-rw-r--r--README.md3
-rw-r--r--src/QuickMedia.cpp16
2 files changed, 9 insertions, 10 deletions
diff --git a/README.md b/README.md
index 388110b..667edde 100644
--- a/README.md
+++ b/README.md
@@ -80,4 +80,5 @@ In image boards when viewing videos, automatically play the next one after the c
When viewing images the image download start from page 1 to the end page. The image download should start from the viewing page.\
Go to next chapter when reaching the end of the chapter in image endless mode.\
Some text is not visible on 4chan, such as code blocks.\
-Show indication when search is in progress (or when something is loading). Some sites such as youtube and mangadex are slow at searching.\ \ No newline at end of file
+Show indication when search is in progress (or when something is loading). Some sites such as youtube and mangadex are slow at searching.\
+Allow deleting watch history with delete key (and show confirmation). \ No newline at end of file
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 32913a3..18dd114 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -367,15 +367,9 @@ namespace QuickMedia {
static void fill_history_items_from_json(const Json::Value &history_json, BodyItems &history_items) {
assert(history_json.isArray());
- if(history_json.empty())
- return;
+ BodyItems body_items;
- auto begin = history_json.begin();
- --begin;
- auto end = history_json.end();
- while(end != begin) {
- --end;
- const Json::Value &item = *end;
+ for(const Json::Value &item : history_json) {
if(!item.isObject())
continue;
@@ -396,7 +390,11 @@ namespace QuickMedia {
auto body_item = std::make_unique<BodyItem>(std::move(title_str));
body_item->url = "https://youtube.com/watch?v=" + video_id_str;
body_item->thumbnail_url = "https://img.youtube.com/vi/" + video_id_str + "/hqdefault.jpg";
- history_items.push_back(std::move(body_item));
+ body_items.push_back(std::move(body_item));
+ }
+
+ for(auto it = body_items.rbegin(), end = body_items.rend(); it != end; ++it) {
+ history_items.push_back(std::move(*it));
}
}