mirror of https://github.com/FreeTubeApp/FreeTube
[Fix] Put History in Chronological order again and better sub handling
This commit is contained in:
parent
0797d426f8
commit
cb32ae7db3
|
@ -58,9 +58,12 @@ function showHistory(){
|
||||||
historyDb.find({}).sort({
|
historyDb.find({}).sort({
|
||||||
timeWatched: -1
|
timeWatched: -1
|
||||||
}).exec((err, docs) => {
|
}).exec((err, docs) => {
|
||||||
|
let position = 0;
|
||||||
docs.forEach((video) => {
|
docs.forEach((video) => {
|
||||||
invidiousAPI('videos', video.videoId, {}, (data) => {
|
invidiousAPI('videos', video.videoId, {}, (data) => {
|
||||||
|
data.position = position;
|
||||||
displayVideo(data, 'history');
|
displayVideo(data, 'history');
|
||||||
|
position++;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,27 @@ function loadSubscriptions() {
|
||||||
progressView.progressWidth = (counter / results.length) * 100;
|
progressView.progressWidth = (counter / results.length) * 100;
|
||||||
|
|
||||||
if (counter === results.length) {
|
if (counter === results.length) {
|
||||||
|
addSubsToView(videoList);
|
||||||
|
}
|
||||||
|
},(errorData) => {
|
||||||
|
showToast('Unable to load channel: ' + results[i]['channelName']);
|
||||||
|
counter = counter + 1;
|
||||||
|
progressView.progressWidth = (counter / results.length) * 100;
|
||||||
|
if (counter === results.length) {
|
||||||
|
addSubsToView(videoList);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// User has no subscriptions. Display message.
|
||||||
|
loadingView.seen = false;
|
||||||
|
headerView.seen = false;
|
||||||
|
noSubscriptions.seen = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addSubsToView (videoList) {
|
||||||
videoList.sort((a, b) => {
|
videoList.sort((a, b) => {
|
||||||
return b.published - a.published;
|
return b.published - a.published;
|
||||||
});
|
});
|
||||||
|
@ -134,16 +155,6 @@ function loadSubscriptions() {
|
||||||
}, 60000);
|
}, 60000);
|
||||||
|
|
||||||
console.log('Done');
|
console.log('Done');
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// User has no subscriptions. Display message.
|
|
||||||
loadingView.seen = false;
|
|
||||||
headerView.seen = false;
|
|
||||||
noSubscriptions.seen = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -193,7 +193,8 @@ function displayVideo(videoData, listType = '') {
|
||||||
video.removeFromSave = false;
|
video.removeFromSave = false;
|
||||||
break;
|
break;
|
||||||
case 'history':
|
case 'history':
|
||||||
historyView.videoList = historyView.videoList.concat(video);
|
historyView.videoList.splice(videoData.position, 0, video);
|
||||||
|
console.log(video);
|
||||||
video.removeFromSave = false;
|
video.removeFromSave = false;
|
||||||
break;
|
break;
|
||||||
case 'channel':
|
case 'channel':
|
||||||
|
|
|
@ -25,7 +25,10 @@
|
||||||
* @return {Void}
|
* @return {Void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function invidiousAPI(resource, id, params, success) {
|
function invidiousAPI(resource, id, params, success, fail = function(){
|
||||||
|
showToast('There was an error calling the Invidious API.');
|
||||||
|
loadingView.seen = false;
|
||||||
|
}) {
|
||||||
let requestUrl = 'https://www.invidio.us/api/v1/' + resource + '/' + id + '?' + $.param(params);
|
let requestUrl = 'https://www.invidio.us/api/v1/' + resource + '/' + id + '?' + $.param(params);
|
||||||
|
|
||||||
if (useTor) {
|
if (useTor) {
|
||||||
|
@ -45,12 +48,10 @@ function invidiousAPI(resource, id, params, success) {
|
||||||
requestUrl,
|
requestUrl,
|
||||||
success
|
success
|
||||||
).fail((xhr, textStatus, error) => {
|
).fail((xhr, textStatus, error) => {
|
||||||
showToast('There was an error calling the Invidious API.');
|
fail(xhr);
|
||||||
console.log(error);
|
|
||||||
console.log(xhr);
|
console.log(xhr);
|
||||||
console.log(textStatus);
|
console.log(textStatus);
|
||||||
console.log(requestUrl);
|
console.log(requestUrl);
|
||||||
loadingView.seen = false;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue