aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp16
1 files changed, 7 insertions, 9 deletions
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));
}
}