1
0
Fork 0
mirror of https://gitlab.com/niansa/qcommsy.git synced 2025-03-06 20:53:33 +01:00

Fixed max_posts

This commit is contained in:
niansa 2020-09-16 17:10:35 +02:00
parent 83b2ec15fa
commit e1c1f26cce
2 changed files with 5 additions and 4 deletions

View file

@ -352,9 +352,8 @@ libCommsy::libCommsy(const std::string& _server_url, const std::string& _server_
throw connectionFailError(); throw connectionFailError();
} }
// Do some stuff XD // Initialise document
document = gumbo_parse(httpcontent.str().c_str()); document = gumbo_parse(httpcontent.str().c_str());
httpcontent.str(std::string()); // Clear buffer just in case we need it later
// Get posts // Get posts
auto gumboPosts = get_posts(document->root); auto gumboPosts = get_posts(document->root);
@ -401,10 +400,12 @@ libCommsy::libCommsy(const std::string& _server_url, const std::string& _server_
// Get lastID // Get lastID
lastID = posts.back().id; lastID = posts.back().id;
// Check if maximum amount of posts to load was exceeded // Check if maximum amount of posts to load was exceeded
if (numposts >= max_posts) { if (max_posts != 0 and numposts >= max_posts) {
// Stop loading more posts // Stop loading more posts
return; return;
} }
} }
// Clear buffer just in case we need it later
httpcontent.str(std::string());
} }
} }

View file

@ -26,7 +26,7 @@ struct commsyPost {
#define libCommsy_NAME "libcommsy" #define libCommsy_NAME "libcommsy"
#define libCommsy_VERSION "1.4-stable" #define libCommsy_VERSION "1.3-stable"
class libCommsy { class libCommsy {
public: public:
std::vector<commsyPost> posts; std::vector<commsyPost> posts;