Skip to content
This repository has been archived by the owner on Jul 8, 2021. It is now read-only.

Commit

Permalink
Save downloads on logout
Browse files Browse the repository at this point in the history
  • Loading branch information
FaisalUmair committed May 25, 2018
1 parent cde648e commit aadf80c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var headers;
var cookieJar = request.jar();

electron.ipcRenderer.on('saveDownloads',function(){
saveDownloads();
saveDownloads(true);
});

var subDomain = 'www';
Expand Down Expand Up @@ -805,10 +805,9 @@ prompt.confirm('Confirm Log Out?', function(ok) {
if(ok){
$('.ui.logout.dimmer').addClass('active');
request({url:'https://www.udemy.com/user/logout/?h=E0ofeFhaTXoT',headers:{'Cookie': settings.get('cookie'),'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36','Host': 'www.udemy.com','origin':'https://www.udemy.com'}},function(){
saveDownloads(false);
settings.set('access_token',false);
$('.ui.logout.dimmer').removeClass('active');
$('.ui.login').slideDown('fast');
$('.ui.dashboard').fadeOut('fast');
location.reload();
});
}
});
Expand Down Expand Up @@ -964,7 +963,7 @@ function handleResponse(response,keyword='') {
}


function saveDownloads(){
function saveDownloads(quit){
var downloadedCourses = [];
var $downloads = $('.ui.downloads.section .ui.courses.items .ui.course.item').slice(0,50);
if($downloads.length){
Expand Down Expand Up @@ -993,7 +992,9 @@ function saveDownloads(){
});
settings.set('downloadedCourses', downloadedCourses);
}
electron.ipcRenderer.send('quitApp');
if(quit){
electron.ipcRenderer.send('quitApp');
}
}

function loadDownloads(){
Expand Down

0 comments on commit aadf80c

Please sign in to comment.