Re-implement version check
This makes LibreTime check its version against github releases and lets the user know when to update. It uses the red exclamation point when there is a patch release or if LibreTime is more than one major release ahead. The orange icon is used when LibreTime is on a git install, a single major update is available, or a pre-release version is installed. The green update icon gets used to signify that a new minor release is available. Finally the green checkmark will be used when you are on a stable release.
This commit is contained in:
parent
81d3c3e2b8
commit
06a3ad0ed3
8 changed files with 230 additions and 38 deletions
|
@ -879,8 +879,27 @@ class Application_Model_Preference
|
|||
public static function GetLatestVersion()
|
||||
{
|
||||
$config = Config::getConfig();
|
||||
$latest = self::getValue("latest_version");
|
||||
if ($latest == null || strlen($latest) == 0) {
|
||||
|
||||
$latest = json_decode(self::getValue('latest_version'));
|
||||
$nextCheck = self::getValue('latest_version_nextcheck');
|
||||
if ($latest && $nextCheck > time()) {
|
||||
return $latest;
|
||||
}
|
||||
|
||||
$rss = new SimplePie();
|
||||
$rss->set_feed_url(array(LIBRETIME_UPDATE_FEED));
|
||||
$rss->enable_cache(false);
|
||||
$rss->init();
|
||||
$rss->handle_content_type();
|
||||
// get all available versions ut to default github api limit
|
||||
$versions = array();
|
||||
foreach ($rss->get_items() as $item) {
|
||||
$versions[] = $item->get_title();
|
||||
}
|
||||
$latest = $versions;
|
||||
self::setValue('latest_version', json_encode($latest));
|
||||
self::setValue('latest_version_nextcheck', strtotime('+1 week'));
|
||||
if (empty($latest)) {
|
||||
return $config['airtime_version'];
|
||||
} else {
|
||||
return $latest;
|
||||
|
@ -899,7 +918,7 @@ class Application_Model_Preference
|
|||
{
|
||||
$link = self::getValue("latest_link");
|
||||
if ($link == null || strlen($link) == 0) {
|
||||
return 'http://airtime.sourcefabric.org';
|
||||
return LIBRETIME_WHATS_NEW_URL;
|
||||
} else {
|
||||
return $link;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue