aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp11
-rw-r--r--src/plugins/Matrix.cpp2
-rw-r--r--src/plugins/Pleroma.cpp4
-rw-r--r--src/plugins/Pornhub.cpp20
4 files changed, 25 insertions, 12 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 0789f78..db0f9f6 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3801,7 +3801,7 @@ namespace QuickMedia {
if(tabs[MESSAGES_TAB_INDEX].body->items.size() < 30) {
previous_messages_future = [this, &current_room]() {
Messages messages;
- if(matrix->get_previous_room_messages(current_room, messages, true) != PluginResult::OK)
+ if(matrix->get_previous_room_messages(current_room, messages) != PluginResult::OK)
fprintf(stderr, "Failed to get previous matrix messages in room: %s\n", current_room->id.c_str());
return messages;
};
@@ -3809,6 +3809,15 @@ namespace QuickMedia {
}
};
+ if(!matrix->is_initial_sync_finished()) {
+ previous_messages_future = [this, &current_room]() {
+ Messages messages;
+ if(matrix->get_previous_room_messages(current_room, messages, true) != PluginResult::OK)
+ fprintf(stderr, "Failed to get previous matrix messages in room: %s\n", current_room->id.c_str());
+ return messages;
+ };
+ }
+
sf::RectangleShape more_messages_below_rect;
more_messages_below_rect.setFillColor(sf::Color(128, 50, 50));
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) {