mirror of https://github.com/FreeTubeApp/FreeTube
[Fix] History taking up too many resources
This commit is contained in:
parent
635c500418
commit
db29528e64
|
@ -62,14 +62,23 @@ function showHistory(){
|
|||
historyDb.find({}).sort({
|
||||
timeWatched: -1
|
||||
}).exec((err, docs) => {
|
||||
let position = 0;
|
||||
docs.forEach((video) => {
|
||||
invidiousAPI('videos', video.videoId, {}, (data) => {
|
||||
data.position = position;
|
||||
|
||||
if (docs.length < 100) {
|
||||
for (let i = 0; i < docs.length; i++) {
|
||||
invidiousAPI('videos', docs[i].videoId, {}, (data) => {
|
||||
data.position = i;
|
||||
displayVideo(data, 'history');
|
||||
position++;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
else{
|
||||
for (let i = 0; i < 100; i++) {
|
||||
invidiousAPI('videos', docs[i].videoId, {}, (data) => {
|
||||
data.position = i;
|
||||
displayVideo(data, 'history');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
loadingView.seen = false;
|
||||
});
|
||||
|
|
|
@ -169,8 +169,10 @@ let init = function () {
|
|||
* Quit the application
|
||||
*/
|
||||
let allWindowsClosed = function () {
|
||||
win.webContents.session.clearStorageData([], (data) => {});
|
||||
win.webContents.session.clearCache((data) => {});
|
||||
if (win !== null) {
|
||||
win.webContents.session.clearStorageData([], (data) => {});
|
||||
win.webContents.session.clearCache((data) => {});
|
||||
}
|
||||
app.quit();
|
||||
};
|
||||
|
||||
|
|
|
@ -122,14 +122,22 @@ function showSavedVideos() {
|
|||
savedVidsDb.find({}).sort({
|
||||
timeSaved: -1
|
||||
}).exec((err, docs) => {
|
||||
let position = 0;
|
||||
docs.forEach((video) => {
|
||||
invidiousAPI('videos', video.videoId, {}, (data) => {
|
||||
data.position = position;
|
||||
displayVideo(data, 'saved');
|
||||
position++;
|
||||
});
|
||||
});
|
||||
if (docs.length < 100) {
|
||||
for (let i = 0; i < docs.length; i++) {
|
||||
invidiousAPI('videos', docs[i].videoId, {}, (data) => {
|
||||
data.position = i;
|
||||
displayVideo(data, 'saved');
|
||||
});
|
||||
}
|
||||
}
|
||||
else{
|
||||
for (let i = 0; i < 100; i++) {
|
||||
invidiousAPI('videos', docs[i].videoId, {}, (data) => {
|
||||
data.position = i;
|
||||
displayVideo(data, 'saved');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
loadingView.seen = false;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue