mirror of https://github.com/FreeTubeApp/FreeTube
Make Favorites Functionality more Responsive
This commit is contained in:
parent
5d2706848d
commit
8c42fb8cae
|
@ -33,14 +33,29 @@ function addSavedVideo(videoId) {
|
||||||
|
|
||||||
checkIfSaved.then((saved) => {
|
checkIfSaved.then((saved) => {
|
||||||
if (saved === false) {
|
if (saved === false) {
|
||||||
let data = {
|
invidiousAPI('videos', video.videoId, {}, (data) => {
|
||||||
videoId: videoId,
|
let publishedText = new Date(data.published * 1000);
|
||||||
timeSaved: new Date().getTime(),
|
publishedText = dateFormat(publishedText, "mmm dS, yyyy");
|
||||||
};
|
let videoData = {
|
||||||
|
videoId: video.videoId,
|
||||||
|
published: data.published,
|
||||||
|
publishedText: publishedText,
|
||||||
|
description: data.description,
|
||||||
|
viewCount: data.viewCount,
|
||||||
|
title: data.title,
|
||||||
|
lengthSeconds: data.lengthSeconds,
|
||||||
|
videoThumbnails: data.videoThumbnails[4].url,
|
||||||
|
author: data.author,
|
||||||
|
authorId: data.authorId,
|
||||||
|
liveNow: false,
|
||||||
|
paid: false,
|
||||||
|
type: 'video',
|
||||||
|
};
|
||||||
|
|
||||||
savedVidsDb.insert(data, (err, newDoc) => {
|
savedVidsDb.insert(data, (err, newDoc) => {
|
||||||
showToast('The video has been favorited!');
|
showToast('The video has been favorited!');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
showToast('The video has already been favorited!')
|
showToast('The video has already been favorited!')
|
||||||
}
|
}
|
||||||
|
@ -122,13 +137,39 @@ function showSavedVideos() {
|
||||||
savedVidsDb.find({}).sort({
|
savedVidsDb.find({}).sort({
|
||||||
timeSaved: -1
|
timeSaved: -1
|
||||||
}).exec((err, docs) => {
|
}).exec((err, docs) => {
|
||||||
let position = 0;
|
docs.forEach((video, index) => {
|
||||||
docs.forEach((video) => {
|
if (typeof(video.author) === 'undefined'){
|
||||||
invidiousAPI('videos', video.videoId, {}, (data) => {
|
invidiousAPI('videos', video.videoId, {}, (data) => {
|
||||||
data.position = position;
|
let publishedText = new Date(data.published * 1000);
|
||||||
displayVideo(data, 'saved');
|
publishedText = dateFormat(publishedText, "mmm dS, yyyy");
|
||||||
position++;
|
let videoData = {
|
||||||
|
videoId: video.videoId,
|
||||||
|
published: data.published,
|
||||||
|
publishedText: publishedText,
|
||||||
|
description: data.description,
|
||||||
|
viewCount: data.viewCount,
|
||||||
|
title: data.title,
|
||||||
|
lengthSeconds: data.lengthSeconds,
|
||||||
|
videoThumbnails: data.videoThumbnails[4].url,
|
||||||
|
author: data.author,
|
||||||
|
authorId: data.authorId,
|
||||||
|
liveNow: false,
|
||||||
|
paid: false,
|
||||||
|
type: 'video',
|
||||||
|
};
|
||||||
|
|
||||||
|
savedVidsDb.update(
|
||||||
|
{ videoId: data.videoId },
|
||||||
|
videoData, {}, (err, newDoc) => {});
|
||||||
|
|
||||||
|
videoData.position = index;
|
||||||
|
displayVideo(videoData, 'saved');
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
video.position = index;
|
||||||
|
displayVideo(video, 'saved');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
loadingView.seen = false;
|
loadingView.seen = false;
|
||||||
|
|
Loading…
Reference in New Issue