mirror of
https://github.com/ranaldsgift/KefinTweaks.git
synced 2026-11-05 15:52:47 +01:00
Cache Season and Episode counts to improve performance on 10.11.x
This commit is contained in:
1 parent
cec038bddf
commit
336a3cbaf8
1 file changed
+15
-4
+15
-4
@@ -216,8 +216,15 @@
|
||||
async function getSeasonsCount(item, includeSpecials = false) {
|
||||
if (!seriesSeasonsCountCache.has(item.Id)) {
|
||||
// Get Seasons from apiHelper.getQuery
|
||||
const data = await apiHelper.getQuery(`${ApiClient.serverAddress()}/Shows/${item.Id}/Seasons?UserId=${ApiClient.getCurrentUserId()}`);
|
||||
let seasons = data.Items || [];
|
||||
const response = await apiHelper.getQuery(`${ApiClient.serverAddress()}/Shows/${item.Id}/Seasons`, { useCache: true });
|
||||
|
||||
if (!response.data) {
|
||||
response.data = await response.dataPromise;
|
||||
}
|
||||
|
||||
const data = response.data;
|
||||
|
||||
let seasons = data.Items || data ||[];
|
||||
|
||||
if (!includeSpecials) {
|
||||
seasons = seasons.filter(season => season.IndexNumber !== 0);
|
||||
@@ -232,8 +239,12 @@
|
||||
async function getEpisodesCount(seriesId, seasonIndex = null, includeSpecials = false) {
|
||||
|
||||
if (!seriesSeasonEpisodeCountCache.has(seriesId)) {
|
||||
const data = await apiHelper.getQuery(`${ApiClient.serverAddress()}/Shows/${seriesId}/Episodes?UserId=${ApiClient.getCurrentUserId()}`);
|
||||
let episodes = data.Items || [];
|
||||
const response = await apiHelper.getQuery(`${ApiClient.serverAddress()}/Shows/${seriesId}/Episodes`, { useCache: true });
|
||||
if (!response.data) {
|
||||
response.data = await response.dataPromise;
|
||||
}
|
||||
const data = response.data;
|
||||
let episodes = data.Items || data || [];
|
||||
|
||||
// Create a Season:EpisodesCount map
|
||||
const seasonEpisodeCountMap = new Map();
|
||||
|
||||
Reference in new issue
Block a user