mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Convert ??= to ||=, put startIndex check in class toggle
This commit is contained in:
parent
9d9670bdd0
commit
408a52961a
1 changed files with 4 additions and 6 deletions
|
@ -61,13 +61,13 @@ function renderList(elem, apiClient, result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadData(instance, elem, apiClient, startIndex, limit) {
|
function reloadData(instance, elem, apiClient, startIndex, limit) {
|
||||||
startIndex ??= parseInt(elem.getAttribute('data-activitystartindex') || '0', 10);
|
startIndex ||= parseInt(elem.getAttribute('data-activitystartindex') || '0', 10);
|
||||||
limit ||= parseInt(elem.getAttribute('data-activitylimit') || '7', 10);
|
limit ||= parseInt(elem.getAttribute('data-activitylimit') || '7', 10);
|
||||||
const minDate = new Date();
|
const minDate = new Date();
|
||||||
const hasUserId = toBoolean(elem.getAttribute('data-useractivity'), true);
|
const hasUserId = toBoolean(elem.getAttribute('data-useractivity'), true);
|
||||||
const daysOffset = hasUserId ? 1 : 7; // one day back if user id, otherwise one week
|
const daysOffset = hasUserId ? 1 : 7; // one day back if user id, otherwise one week
|
||||||
// TODO: Use date-fns
|
// TODO: Use date-fns
|
||||||
minDate.setTime(minDate.getTime() - dateOffset * 24 * 60 * 60 * 1000);
|
minDate.setTime(minDate.getTime() - daysOffset * 24 * 60 * 60 * 1000);
|
||||||
|
|
||||||
ApiClient.getJSON(ApiClient.getUrl('System/ActivityLog/Entries', {
|
ApiClient.getJSON(ApiClient.getUrl('System/ActivityLog/Entries', {
|
||||||
startIndex: startIndex,
|
startIndex: startIndex,
|
||||||
|
@ -77,10 +77,8 @@ function reloadData(instance, elem, apiClient, startIndex, limit) {
|
||||||
})).then(function (result) {
|
})).then(function (result) {
|
||||||
elem.setAttribute('data-activitystartindex', startIndex);
|
elem.setAttribute('data-activitystartindex', startIndex);
|
||||||
elem.setAttribute('data-activitylimit', limit);
|
elem.setAttribute('data-activitylimit', limit);
|
||||||
if (startIndex === 0) {
|
|
||||||
const activityContainer = dom.parentWithClass(elem, 'activityContainer');
|
const activityContainer = dom.parentWithClass(elem, 'activityContainer');
|
||||||
activityContainer?.classList.toggle('hide', result.Items.length === 0);
|
activityContainer?.classList.toggle('hide', result.Items.length === 0 && startIndex === 0);
|
||||||
}
|
|
||||||
|
|
||||||
instance.items = result.Items;
|
instance.items = result.Items;
|
||||||
renderList(elem, apiClient, result);
|
renderList(elem, apiClient, result);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue