Skip to content

Commit

Permalink
Merge branch 'master' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
rnbr04 authored Oct 18, 2023
2 parents e9c07f4 + edb8c0c commit 84d14c3
Show file tree
Hide file tree
Showing 17 changed files with 614 additions and 369 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
- [Fishbigger](https://github.com/fishbigger)
- [sleepycatcoding](https://github.com/sleepycatcoding)
- [TheMelmacian](https://github.com/TheMelmacian)
- [v0idMrK](https://github.com/v0idMrK)
- [tehciolo](https://github.com/tehciolo)
- [scampower3](https://github.com/scampower3)

Expand Down
49 changes: 15 additions & 34 deletions src/components/filtermenu/filtermenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ function onInputCommand(e) {
break;
}
}
function saveValues(context, settings, settingsKey, setfilters) {
function saveValues(context, settings, settingsKey) {
context.querySelectorAll('.simpleFilter').forEach(elem => {
if (elem.tagName === 'INPUT') {
setBasicFilter(context, settingsKey + '-filter-' + elem.getAttribute('data-settingname'), elem);
} else {
setBasicFilter(context, settingsKey + '-filter-' + elem.getAttribute('data-settingname'), elem.querySelector('input'));
}
});

// Video type
const videoTypes = [];
context.querySelectorAll('.chkVideoTypeFilter').forEach(elem => {
Expand All @@ -111,6 +119,8 @@ function saveValues(context, settings, settingsKey, setfilters) {
}
});

userSettings.setFilter(settingsKey + '-filter-VideoTypes', videoTypes.join(','));

// Series status
const seriesStatuses = [];
context.querySelectorAll('.chkSeriesStatus').forEach(elem => {
Expand All @@ -119,6 +129,8 @@ function saveValues(context, settings, settingsKey, setfilters) {
}
});

userSettings.setFilter(`${settingsKey}-filter-SeriesStatus`, seriesStatuses.join(','));

// Genres
const genres = [];
context.querySelectorAll('.chkGenreFilter').forEach(elem => {
Expand All @@ -127,38 +139,7 @@ function saveValues(context, settings, settingsKey, setfilters) {
}
});

if (setfilters) {
setfilters((prevState) => ({
...prevState,
StartIndex: 0,
IsPlayed: context.querySelector('.chkPlayed').checked,
IsUnplayed: context.querySelector('.chkUnplayed').checked,
IsFavorite: context.querySelector('.chkFavorite').checked,
IsResumable: context.querySelector('.chkResumable').checked,
Is4K: context.querySelector('.chk4KFilter').checked,
IsHD: context.querySelector('.chkHDFilter').checked,
IsSD: context.querySelector('.chkSDFilter').checked,
Is3D: context.querySelector('.chk3DFilter').checked,
VideoTypes: videoTypes.join(','),
SeriesStatus: seriesStatuses.join(','),
HasSubtitles: context.querySelector('.chkSubtitle').checked,
HasTrailer: context.querySelector('.chkTrailer').checked,
HasSpecialFeature: context.querySelector('.chkSpecialFeature').checked,
HasThemeSong: context.querySelector('.chkThemeSong').checked,
HasThemeVideo: context.querySelector('.chkThemeVideo').checked,
GenreIds: genres.join(',')
}));
} else {
context.querySelectorAll('.simpleFilter').forEach(elem => {
if (elem.tagName === 'INPUT') {
setBasicFilter(context, settingsKey + '-filter-' + elem.getAttribute('data-settingname'), elem);
} else {
setBasicFilter(context, settingsKey + '-filter-' + elem.getAttribute('data-settingname'), elem.querySelector('input'));
}
});

userSettings.setFilter(settingsKey + '-filter-GenreIds', genres.join(','));
}
userSettings.setFilter(settingsKey + '-filter-GenreIds', genres.join(','));
}
function bindCheckboxInput(context, on) {
const elems = context.querySelectorAll('.checkboxList-verticalwrap');
Expand Down Expand Up @@ -289,7 +270,7 @@ class FilterMenu {
}

if (submitted) {
saveValues(dlg, options.settings, options.settingsKey, options.setfilters);
saveValues(dlg, options.settings, options.settingsKey);
return resolve();
}
return resolve();
Expand Down
10 changes: 9 additions & 1 deletion src/components/itemContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import itemHelper from './itemHelper';
import { playbackManager } from './playback/playbackmanager';
import ServerConnections from './ServerConnections';
import toast from './toast/toast';
import * as userSettings from '../scripts/settings/userSettings';

export function getCommands(options) {
const item = options.item;
Expand Down Expand Up @@ -589,9 +590,16 @@ function play(item, resume, queue, queueNext) {
serverId: item.ServerId
});
} else {
const sortParentId = 'items-' + (item.IsFolder ? item.Id : item.ParentId) + '-Folder';
const sortValues = userSettings.getSortValuesLegacy(sortParentId);

playbackManager[method]({
items: [item],
startPositionTicks: startPosition
startPositionTicks: startPosition,
queryOptions: {
SortBy: sortValues.sortBy,
SortOrder: sortValues.sortOrder
}
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/mediainfo/mediainfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ export function getMediaInfoHtml(item, options = {}) {
if (item.EndDate) {
try {
const endYear = datetime.toLocaleString(datetime.parseISO8601Date(item.EndDate).getFullYear(), { useGrouping: false });

if (endYear !== item.ProductionYear) {
text += `-${endYear}`;
/* At this point, text will contain only the start year */
if (endYear !== text) {
text += ` - ${endYear}`;
}
} catch (e) {
console.error('error parsing date:', item.EndDate);
Expand Down
19 changes: 10 additions & 9 deletions src/components/playback/playbackmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { PluginType } from '../../types/plugin.ts';
import { includesAny } from '../../utils/container.ts';
import { getItems } from '../../utils/jellyfin-apiclient/getItems.ts';
import { getItemBackdropImageUrl } from '../../utils/jellyfin-apiclient/backdropImage';
import merge from 'lodash-es/merge';

const UNLIMITED_ITEMS = -1;

Expand Down Expand Up @@ -145,7 +146,7 @@ function createStreamInfoFromUrlItem(item) {
}

function mergePlaybackQueries(obj1, obj2) {
const query = Object.assign(obj1, obj2);
const query = merge({}, obj1, obj2);

const filters = query.Filters ? query.Filters.split(',') : [];
if (filters.indexOf('IsNotFolder') === -1) {
Expand Down Expand Up @@ -1798,23 +1799,23 @@ class PlaybackManager {
SortBy: options.shuffle ? 'Random' : null
});
} else if (firstItem.Type === 'MusicArtist') {
promise = getItemsForPlayback(serverId, {
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
ArtistIds: firstItem.Id,
Filters: 'IsNotFolder',
Recursive: true,
SortBy: options.shuffle ? 'Random' : 'SortName',
MediaTypes: 'Audio'
});
}, queryOptions));
} else if (firstItem.MediaType === 'Photo') {
promise = getItemsForPlayback(serverId, {
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
ParentId: firstItem.ParentId,
Filters: 'IsNotFolder',
// Setting this to true may cause some incorrect sorting
Recursive: false,
SortBy: options.shuffle ? 'Random' : 'SortName',
MediaTypes: 'Photo,Video',
Limit: UNLIMITED_ITEMS
}).then(function (result) {
}, queryOptions)).then(function (result) {
const playbackItems = result.Items;

let index = playbackItems.map(function (i) {
Expand All @@ -1830,7 +1831,7 @@ class PlaybackManager {
return Promise.resolve(result);
});
} else if (firstItem.Type === 'PhotoAlbum') {
promise = getItemsForPlayback(serverId, {
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
ParentId: firstItem.Id,
Filters: 'IsNotFolder',
// Setting this to true may cause some incorrect sorting
Expand All @@ -1839,15 +1840,15 @@ class PlaybackManager {
// Only include Photos because we do not handle mixed queues currently
MediaTypes: 'Photo',
Limit: UNLIMITED_ITEMS
});
}, queryOptions));
} else if (firstItem.Type === 'MusicGenre') {
promise = getItemsForPlayback(serverId, {
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
GenreIds: firstItem.Id,
Filters: 'IsNotFolder',
Recursive: true,
SortBy: options.shuffle ? 'Random' : 'SortName',
MediaTypes: 'Audio'
});
}, queryOptions));
} else if (firstItem.Type === 'Series' || firstItem.Type === 'Season') {
const apiClient = ServerConnections.getApiClient(firstItem.ServerId);

Expand Down
12 changes: 11 additions & 1 deletion src/components/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import dom from '../scripts/dom';
import recordingHelper from './recordingcreator/recordinghelper';
import ServerConnections from './ServerConnections';
import toast from './toast/toast';
import * as userSettings from '../scripts/settings/userSettings';

function playAllFromHere(card, serverId, queue) {
const parent = card.parentNode;
Expand Down Expand Up @@ -177,6 +178,10 @@ function executeAction(card, target, action) {

const item = getItemInfoFromCard(card);

const itemsContainer = dom.parentWithClass(card, 'itemsContainer');

const sortParentId = 'items-' + (item.IsFolder ? item.Id : itemsContainer?.getAttribute('data-parentid')) + '-Folder';

const serverId = item.ServerId;
const type = item.Type;

Expand All @@ -200,12 +205,17 @@ function executeAction(card, target, action) {
});
} else if (action === 'play' || action === 'resume') {
const startPositionTicks = parseInt(card.getAttribute('data-positionticks') || '0', 10);
const sortValues = userSettings.getSortValuesLegacy(sortParentId, 'SortName');

if (playbackManager.canPlay(item)) {
playbackManager.play({
ids: [playableItemId],
startPositionTicks: startPositionTicks,
serverId: serverId
serverId: serverId,
queryOptions: {
SortBy: sortValues.sortBy,
SortOrder: sortValues.sortOrder
}
});
} else {
console.warn('Unable to play item', item);
Expand Down
21 changes: 6 additions & 15 deletions src/components/sortmenu/sortmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function onSubmit(e) {
function initEditor(context, settings) {
context.querySelector('form').addEventListener('submit', onSubmit);

context.querySelector('.selectSortOrder').value = settings.SortOrder;
context.querySelector('.selectSortBy').value = settings.SortBy;
context.querySelector('.selectSortOrder').value = settings.sortOrder;
context.querySelector('.selectSortBy').value = settings.sortBy;
}

function centerFocus(elem, horiz, on) {
Expand All @@ -37,18 +37,9 @@ function fillSortBy(context, options) {
}).join('');
}

function saveValues(context, settingsKey, setSortValues) {
if (setSortValues) {
setSortValues((prevState) => ({
...prevState,
StartIndex: 0,
SortBy: context.querySelector('.selectSortBy').value,
SortOrder: context.querySelector('.selectSortOrder').value
}));
} else {
userSettings.setFilter(settingsKey + '-sortorder', context.querySelector('.selectSortOrder').value);
userSettings.setFilter(settingsKey + '-sortby', context.querySelector('.selectSortBy').value);
}
function saveValues(context, settingsKey) {
userSettings.setFilter(settingsKey + '-sortorder', context.querySelector('.selectSortOrder').value);
userSettings.setFilter(settingsKey + '-sortby', context.querySelector('.selectSortBy').value);
}

class SortMenu {
Expand Down Expand Up @@ -104,7 +95,7 @@ class SortMenu {
}

if (submitted) {
saveValues(dlg, options.settingsKey, options.setSortValues);
saveValues(dlg, options.settingsKey);
resolve();
return;
}
Expand Down
26 changes: 7 additions & 19 deletions src/components/viewSettings/viewSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,13 @@ function initEditor(context, settings) {
context.querySelector('.selectImageType').value = settings.imageType || 'primary';
}

function saveValues(context, settings, settingsKey, setviewsettings) {
if (setviewsettings) {
setviewsettings((prevState) => ({
...prevState,
StartIndex: 0,
imageType: context.querySelector('.selectImageType').value,
showTitle: context.querySelector('.chkShowTitle').checked || false,
showYear: context.querySelector('.chkShowYear').checked || false,
cardLayout: context.querySelector('.chkEnableCardLayout').checked || false
}));
} else {
const elems = context.querySelectorAll('.viewSetting-checkboxContainer');
for (const elem of elems) {
userSettings.set(settingsKey + '-' + elem.getAttribute('data-settingname'), elem.querySelector('input').checked);
}

userSettings.set(settingsKey + '-imageType', context.querySelector('.selectImageType').value);
function saveValues(context, settings, settingsKey) {
const elems = context.querySelectorAll('.viewSetting-checkboxContainer');
for (const elem of elems) {
userSettings.set(settingsKey + '-' + elem.getAttribute('data-settingname'), elem.querySelector('input').checked);
}

userSettings.set(settingsKey + '-imageType', context.querySelector('.selectImageType').value);
}

function centerFocus(elem, horiz, on) {
Expand Down Expand Up @@ -112,7 +101,6 @@ class ViewSettings {
dlg.querySelector('.selectImageType').addEventListener('change', function () {
showIfAllowed(dlg, '.chkTitleContainer', this.value !== 'list' && this.value !== 'banner');
showIfAllowed(dlg, '.chkYearContainer', this.value !== 'list' && this.value !== 'banner');
showIfAllowed(dlg, '.chkCardLayoutContainer', this.value !== 'list' && this.value !== 'banner');
});

dlg.querySelector('.btnCancel').addEventListener('click', function () {
Expand All @@ -137,7 +125,7 @@ class ViewSettings {
}

if (submitted) {
saveValues(dlg, options.settings, options.settingsKey, options.setviewsettings);
saveValues(dlg, options.settings, options.settingsKey);
return resolve();
}

Expand Down
7 changes: 0 additions & 7 deletions src/components/viewSettings/viewSettings.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@
<span>${GroupBySeries}</span>
</label>
</div>

<div class="checkboxContainer viewSetting viewSetting-checkboxContainer hide chkCardLayoutContainer" data-settingname="cardLayout">
<label>
<input is="emby-checkbox" type="checkbox" class="chkEnableCardLayout" />
<span>${EnableCardLayout}</span>
</label>
</div>
</div>
</form>
</div>
Expand Down
10 changes: 6 additions & 4 deletions src/controllers/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,13 @@ class ItemsView {
const currentItem = self.currentItem;

if (currentItem && !self.hasFilters) {
const values = self.getSortValues();
playbackManager.play({
items: [currentItem],
queryOptions: {
SortBy: values.sortBy,
SortOrder: values.sortOrder
},
autoplay: true
});
} else {
Expand Down Expand Up @@ -960,10 +965,7 @@ class ItemsView {

getSortValues() {
const basekey = this.getSettingsKey();
return {
sortBy: userSettings.getFilter(basekey + '-sortby') || this.getDefaultSortBy(),
sortOrder: userSettings.getFilter(basekey + '-sortorder') === 'Descending' ? 'Descending' : 'Ascending'
};
return userSettings.getSortValuesLegacy(basekey, this.getDefaultSortBy());
}

getDefaultSortBy() {
Expand Down
Loading

0 comments on commit 84d14c3

Please sign in to comment.