From: Andrew Dolgov Date: Thu, 21 Mar 2013 14:01:42 +0000 (+0400) Subject: implement basic auto-reload on some dependent file timestamp changing X-Git-Tag: 1.7.5~44 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=16314ddafe88b6c214892799a5da354e2188524c;p=tt-rss.git implement basic auto-reload on some dependent file timestamp changing --- diff --git a/include/functions.php b/include/functions.php index 3d6b7c89..aa557554 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2034,6 +2034,8 @@ $data['last_article_id'] = getLastArticleId($link); $data['cdm_expanded'] = get_pref($link, 'CDM_EXPANDED'); + $data['dep_ts'] = calculate_dep_timestamp(); + if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) { $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock"); @@ -4103,4 +4105,16 @@ echo "\n"; } + function calculate_dep_timestamp() { + $files = array_merge(glob("js/*.js"), glob("*.css")); + + $max_ts = -1; + + foreach ($files as $file) { + if (filemtime($file) > $max_ts) $max_ts = filemtime($file); + } + + return $max_ts; + } + ?> diff --git a/js/tt-rss.js b/js/tt-rss.js index 77bb5117..ed5e01d4 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -446,6 +446,12 @@ function parse_runtime_info(data) { return; } + if (k == "dep_ts" && parseInt(getInitParam("dep_ts")) > 0) { + if (parseInt(getInitParam("dep_ts")) < parseInt(v)) { + window.location.reload(); + } + } + if (k == "daemon_is_running" && v != 1) { notify_error("Update daemon is not running.", true); return;