2018-06-02 00:17:33 +02:00
|
|
|
/*
|
2018-07-24 03:11:56 +02:00
|
|
|
This file is part of FreeTube.
|
2018-06-02 00:17:33 +02:00
|
|
|
|
2018-07-24 03:11:56 +02:00
|
|
|
FreeTube is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2018-06-02 00:17:33 +02:00
|
|
|
|
2018-07-24 03:11:56 +02:00
|
|
|
FreeTube is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2018-06-02 00:17:33 +02:00
|
|
|
|
2018-07-24 03:11:56 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with FreeTube. If not, see <http://www.gnu.org/licenses/>.
|
2018-06-02 00:17:33 +02:00
|
|
|
*/
|
|
|
|
|
2018-07-24 03:11:56 +02:00
|
|
|
// import {freeTubeLog} from './events.js';
|
2018-06-02 00:17:33 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A file for checking / managing updates
|
|
|
|
*/
|
|
|
|
|
2019-03-28 19:23:24 +01:00
|
|
|
function checkForNewUpdate() {
|
2019-08-07 15:49:25 +02:00
|
|
|
const requestUrl = 'https://api.github.com/repos/freetubeapp/freetube/releases';
|
2019-03-28 19:23:24 +01:00
|
|
|
|
2019-08-07 15:49:25 +02:00
|
|
|
let success = function (data) {
|
|
|
|
let currentVersion = require('electron').remote.app.getVersion();
|
|
|
|
let versionNumber = data[0].tag_name.replace('v', '');
|
|
|
|
versionNumber = versionNumber.replace('-beta', '');
|
2019-03-28 19:23:24 +01:00
|
|
|
|
2019-08-07 15:49:25 +02:00
|
|
|
let blogRegexPattern = /\(.*\)/;
|
2019-03-28 19:23:24 +01:00
|
|
|
|
2019-08-07 15:49:25 +02:00
|
|
|
let blogUrl = blogRegexPattern.exec(data[0].body);
|
|
|
|
blogUrl = blogUrl[0].replace(/\(|\)/g, '');
|
2019-03-28 19:23:24 +01:00
|
|
|
|
2019-08-07 15:49:25 +02:00
|
|
|
if (versionNumber > currentVersion) {
|
|
|
|
confirmFunction(data[0].name + ` is now available! Would you like to download the update? <a href="${blogUrl}">Changelog</a>`, openReleasePage);
|
|
|
|
}
|
|
|
|
};
|
2019-03-28 19:23:24 +01:00
|
|
|
|
2019-08-07 15:49:25 +02:00
|
|
|
if (useTor) {
|
|
|
|
proxyRequest(() => {
|
|
|
|
$.getJSON(
|
|
|
|
requestUrl,
|
|
|
|
success
|
|
|
|
).fail((xhr, textStatus, error) => {
|
|
|
|
fail(xhr);
|
|
|
|
ft.log(xhr);
|
|
|
|
ft.log(textStatus);
|
|
|
|
ft.log(requestUrl);
|
|
|
|
});
|
|
|
|
})
|
2019-03-28 19:23:24 +01:00
|
|
|
|
2019-08-07 15:49:25 +02:00
|
|
|
} else {
|
|
|
|
$.getJSON(
|
|
|
|
requestUrl,
|
|
|
|
success
|
|
|
|
).fail((xhr, textStatus, error) => {
|
|
|
|
fail(xhr);
|
|
|
|
ft.log(xhr);
|
|
|
|
ft.log(textStatus);
|
|
|
|
ft.log(requestUrl);
|
|
|
|
});
|
|
|
|
}
|
2019-03-28 19:23:24 +01:00
|
|
|
}
|
2018-06-02 00:17:33 +02:00
|
|
|
|
2018-07-24 03:11:56 +02:00
|
|
|
const openReleasePage = function () {
|
2019-06-13 01:52:21 +02:00
|
|
|
shell.openExternal('https://freetubeapp.io/#download');
|
2018-07-24 03:11:56 +02:00
|
|
|
}
|