aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-12-18 22:47:10 +0100
committerdec05eba <dec05eba@protonmail.com>2020-12-18 22:49:33 +0100
commit4f8e4d11e51e2436b957157de86755f5f8879f61 (patch)
tree26a186264ce0ba4e72d8384a3d4be9357d37c353 /src/plugins
parent3ef2293fd55894c968cd44608fa813d699354c20 (diff)
Matrix: get previous messages immediately even if sync in progress
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Matrix.cpp2
-rw-r--r--src/plugins/Pleroma.cpp4
-rw-r--r--src/plugins/Pornhub.cpp20
3 files changed, 15 insertions, 11 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 003cf46..a07d050 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -2355,7 +2355,7 @@ namespace QuickMedia {
PluginResult Matrix::get_previous_room_messages(RoomData *room_data, bool latest_messages, size_t &num_new_messages) {
num_new_messages = 0;
std::string from = room_data->get_prev_batch();
- if(from.empty())
+ if(from.empty() || latest_messages)
from = "END";
rapidjson::Document request_data(rapidjson::kObjectType);
diff --git a/src/plugins/Pleroma.cpp b/src/plugins/Pleroma.cpp
index 8479e39..20d71c7 100644
--- a/src/plugins/Pleroma.cpp
+++ b/src/plugins/Pleroma.cpp
@@ -5,11 +5,13 @@ extern "C" {
#include <HtmlParser.h>
}
-namespace QuickMedia {
+namespace {
struct HtmlParseUserdata {
std::string result;
};
+}
+namespace QuickMedia {
static void html_parse_callback(HtmlParser *html_parser, HtmlParseType parse_type, void *userdata) {
HtmlParseUserdata *parse_userdata = (HtmlParseUserdata*)userdata;
if(parse_type == HTML_PARSE_TEXT) {
diff --git a/src/plugins/Pornhub.cpp b/src/plugins/Pornhub.cpp
index 1f0840e..b4e908a 100644
--- a/src/plugins/Pornhub.cpp
+++ b/src/plugins/Pornhub.cpp
@@ -6,11 +6,7 @@ extern "C" {
}
#include <string.h>
-namespace QuickMedia {
- static bool begins_with(const char *str, const char *begin_with) {
- return strncmp(str, begin_with, strlen(begin_with)) == 0;
- }
-
+namespace {
// TODO: Optimize by using HtmlStringView instead of std::string
struct HtmlElement {
std::string tag_name;
@@ -19,6 +15,16 @@ namespace QuickMedia {
HtmlElement *parent = nullptr; // ref
};
+ struct HtmlParseUserdata {
+ HtmlElement *current_html_element;
+ };
+}
+
+namespace QuickMedia {
+ static bool begins_with(const char *str, const char *begin_with) {
+ return strncmp(str, begin_with, strlen(begin_with)) == 0;
+ }
+
static void html_cleanup(HtmlElement *html_element_root) {
for(HtmlElement *child_html_element : html_element_root->children) {
html_cleanup(child_html_element);
@@ -34,10 +40,6 @@ namespace QuickMedia {
return default_value;
}
- struct HtmlParseUserdata {
- HtmlElement *current_html_element;
- };
-
static void html_page_callback(HtmlParser *html_parser, HtmlParseType parse_type, void *userdata) {
HtmlParseUserdata *parse_userdata = (HtmlParseUserdata*)userdata;
if(parse_type == HTML_PARSE_TAG_START) {