diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-08-01 00:26:57 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-08-01 00:26:57 +0200 |
commit | aead89cca00cba7bef8752163752f6a9c213ae6f (patch) | |
tree | 53732517adf900839b312818870718363596b0d8 | |
parent | 31976fb2d19be13fb87d835ea8578356cafaa7db (diff) |
4chan: fix last posted timestamp being incorrect (when saved to disk)
-rw-r--r-- | include/Utils.hpp | 1 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 13 | ||||
-rw-r--r-- | src/Utils.cpp | 9 |
3 files changed, 7 insertions, 16 deletions
diff --git a/include/Utils.hpp b/include/Utils.hpp index 7aec9e6..cdef844 100644 --- a/include/Utils.hpp +++ b/include/Utils.hpp @@ -11,5 +11,4 @@ namespace QuickMedia { bool is_running_wayland(); time_t iso_utc_to_unix_time(const char *time_str); std::string unix_time_to_local_time_str(time_t unix_time); - int64_t get_unix_time_monotonic(); }
\ No newline at end of file diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 1f7372a..4a3003b 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -54,7 +54,7 @@ #include <X11/extensions/Xrandr.h> #include <GL/glx.h> -static int FPS_IDLE = 2; +static int FPS_IDLE; static const double IDLE_TIMEOUT_SEC = 2.0; static const sf::Vector2i AVATAR_THUMBNAIL_SIZE(std::floor(32), std::floor(32)); @@ -463,7 +463,7 @@ namespace QuickMedia { } if(low_cpu_mode) - FPS_IDLE = 2; + FPS_IDLE = 3; else FPS_IDLE = 20; @@ -3724,7 +3724,8 @@ namespace QuickMedia { const int captcha_solution_text_height = 18 * get_ui_scale(); sf::Text captcha_solution_text("", *FontLoader::get_font(FontLoader::FontType::LATIN_BOLD), captcha_solution_text_height); int solved_captcha_ttl = 0; - int64_t last_posted_time = get_unix_time_monotonic(); + int64_t last_posted_time = time(nullptr); + fprintf(stderr, "unix time: %ld\n", last_posted_time); int64_t seconds_until_post_again = 60; // TODO: Timeout for other imageboards bool has_post_timeout = thread_page->get_pass_id().empty(); @@ -3760,7 +3761,7 @@ namespace QuickMedia { // TODO: Asynchronously update the thread periodically to show new comments. selected_file_for_upload.clear(); // TODO: Remove from here, this is async has_post_timeout = thread_page->get_pass_id().empty(); - last_posted_time = get_unix_time_monotonic(); + last_posted_time = time(nullptr); Path last_posted_time_filepath; if(get_image_board_last_posted_filepath(plugin_name, last_posted_time_filepath)) @@ -3803,7 +3804,7 @@ namespace QuickMedia { if(text.empty() && selected_file_for_upload.empty()) return false; - if(has_post_timeout && seconds_until_post_again - (get_unix_time_monotonic() - last_posted_time) > 0) + if(has_post_timeout && seconds_until_post_again - (time(nullptr) - last_posted_time) > 0) return false; comment_input.set_editable(false); @@ -4325,7 +4326,7 @@ namespace QuickMedia { } if((navigation_stage == NavigationStage::REPLYING || navigation_stage == NavigationStage::VIEWING_COMMENTS) && has_post_timeout) { - int64_t time_left_until_post_again = seconds_until_post_again - (get_unix_time_monotonic() - last_posted_time); + int64_t time_left_until_post_again = seconds_until_post_again - (time(nullptr) - last_posted_time); if(time_left_until_post_again > 0) { sf::RectangleShape time_left_bg(comment_input_shade.getSize()); time_left_bg.setPosition(comment_input_shade.getPosition()); diff --git a/src/Utils.cpp b/src/Utils.cpp index 3032f22..c73932b 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -126,13 +126,4 @@ namespace QuickMedia { strftime(time_str, sizeof(time_str) - 1, "%Y %b %d, %a %H:%M", &time_tm); return time_str; } - - int64_t get_unix_time_monotonic() { - struct timespec t; - if(clock_gettime(CLOCK_MONOTONIC, &t) == -1) { - fprintf(stderr, "This kernel version doesn't support CLOCK_MONOTONIC\n"); - abort(); - } - return t.tv_sec; - } }
\ No newline at end of file |