aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-03 21:09:26 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-03 21:09:26 +0100
commit9f12d8a7f6e4cdf0cb95130b69da2b368cc9cbb5 (patch)
tree6b0c85fca617329a94fc94c0f4a247ff7ecd38fd /src/plugins
parentf7f45ddc492b992cc49a92f620e37316e4d1fed4 (diff)
Add thumbnail to manga history page. Start on new manga history format (one json file)
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Manga.cpp1
-rw-r--r--src/plugins/MangaCombined.cpp1
-rw-r--r--src/plugins/MangaGeneric.cpp2
-rw-r--r--src/plugins/Mangadex.cpp2
-rw-r--r--src/plugins/Manganelo.cpp2
-rw-r--r--src/plugins/Page.cpp33
6 files changed, 30 insertions, 11 deletions
diff --git a/src/plugins/Manga.cpp b/src/plugins/Manga.cpp
index 5f0aae7..4401974 100644
--- a/src/plugins/Manga.cpp
+++ b/src/plugins/Manga.cpp
@@ -24,6 +24,7 @@ namespace QuickMedia {
std::shared_ptr<BodyItem> MangaChaptersPage::get_bookmark_body_item() {
auto body_item = BodyItem::create(content_title);
body_item->url = content_url;
+ body_item->thumbnail_url = thumbnail_url;
return body_item;
}
} \ No newline at end of file
diff --git a/src/plugins/MangaCombined.cpp b/src/plugins/MangaCombined.cpp
index 0742562..f678e57 100644
--- a/src/plugins/MangaCombined.cpp
+++ b/src/plugins/MangaCombined.cpp
@@ -122,6 +122,7 @@ namespace QuickMedia {
PluginResult MangaCombinedSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
Page *page = (Page*)submit_body_item->userdata;
if(!page) return PluginResult::OK;
+ page->submit_body_item = submit_body_item;
return page->submit(title, url, result_tabs);
}
diff --git a/src/plugins/MangaGeneric.cpp b/src/plugins/MangaGeneric.cpp
index e25fd96..0c1ee37 100644
--- a/src/plugins/MangaGeneric.cpp
+++ b/src/plugins/MangaGeneric.cpp
@@ -380,7 +380,7 @@ namespace QuickMedia {
}
PluginResult MangaGenericChaptersPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<MangaGenericImagesPage>(program, content_title, title, url, service_name, website_url, list_page_query, fail_on_http_error), nullptr});
+ result_tabs.push_back(Tab{nullptr, std::make_unique<MangaGenericImagesPage>(program, content_title, title, url, service_name, website_url, list_page_query, fail_on_http_error, thumbnail_url), nullptr});
return PluginResult::OK;
}
diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp
index 8dd6822..88f4c18 100644
--- a/src/plugins/Mangadex.cpp
+++ b/src/plugins/Mangadex.cpp
@@ -377,7 +377,7 @@ namespace QuickMedia {
}
PluginResult MangadexChaptersPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<MangadexImagesPage>(program, search_page, content_title, url, title), nullptr});
+ result_tabs.push_back(Tab{nullptr, std::make_unique<MangadexImagesPage>(program, search_page, content_title, url, title, thumbnail_url), nullptr});
return PluginResult::OK;
}
diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp
index e5c5719..55f0467 100644
--- a/src/plugins/Manganelo.cpp
+++ b/src/plugins/Manganelo.cpp
@@ -154,7 +154,7 @@ namespace QuickMedia {
}
PluginResult ManganeloChaptersPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<ManganeloImagesPage>(program, content_title, title, url), nullptr});
+ result_tabs.push_back(Tab{nullptr, std::make_unique<ManganeloImagesPage>(program, content_title, title, url, thumbnail_url), nullptr});
return PluginResult::OK;
}
diff --git a/src/plugins/Page.cpp b/src/plugins/Page.cpp
index 34ca889..2e3caf4 100644
--- a/src/plugins/Page.cpp
+++ b/src/plugins/Page.cpp
@@ -85,16 +85,34 @@ namespace QuickMedia {
if(!read_file_as_json(bookmark_path, json_root) || !json_root.isArray())
return PluginResult::OK;
+ std::vector<const Json::Value*> bookmark_json_items;
+ for(const Json::Value &item : json_root) {
+ if(!item.isObject())
+ continue;
+
+ const Json::Value &timestamp = item["timestamp"];
+ if(!timestamp.isInt64())
+ continue;
+
+ bookmark_json_items.push_back(&item);
+ }
+
+ std::sort(bookmark_json_items.begin(), bookmark_json_items.end(), [](const Json::Value *val1, const Json::Value *val2) {
+ const Json::Value &timestamp1 = (*val1)["timestamp"];
+ const Json::Value &timestamp2 = (*val2)["timestamp"];
+ return timestamp1.asInt64() > timestamp2.asInt64();
+ });
+
const time_t time_now = time(nullptr);
- for(const Json::Value &item_json : json_root) {
- if(!item_json.isObject())
+ for(const Json::Value *item_json : bookmark_json_items) {
+ if(!item_json->isObject())
continue;
- const Json::Value &title_json = item_json["title"];
- const Json::Value &author_json = item_json["author"];
- const Json::Value &url_json = item_json["url"];
- const Json::Value &thumbnail_url_json = item_json["thumbnail_url"];
- const Json::Value &timestamp_json = item_json["timestamp"];
+ const Json::Value &title_json = (*item_json)["title"];
+ const Json::Value &author_json = (*item_json)["author"];
+ const Json::Value &url_json = (*item_json)["url"];
+ const Json::Value &thumbnail_url_json = (*item_json)["thumbnail_url"];
+ const Json::Value &timestamp_json = (*item_json)["timestamp"];
auto body_item = BodyItem::create(title_json.isString() ? title_json.asString() : "");
if(author_json.isString())
@@ -116,7 +134,6 @@ namespace QuickMedia {
result_items.push_back(std::move(body_item));
}
- std::reverse(result_items.begin(), result_items.end());
return PluginResult::OK;
}
} \ No newline at end of file