Merge pull request #3559 from thornbill/remove-equality-funcs

Remove custom equality check functions
This commit is contained in:
Bill Thornton 2022-04-19 16:27:48 -04:00 committed by GitHub
commit 054587d9ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 26 deletions

View File

@ -1,10 +1,12 @@
import isEqual from 'lodash-es/isEqual';
import browser from '../../scripts/browser'; import browser from '../../scripts/browser';
import { playbackManager } from '../playback/playbackmanager'; import { playbackManager } from '../playback/playbackmanager';
import dom from '../../scripts/dom'; import dom from '../../scripts/dom';
import * as userSettings from '../../scripts/settings/userSettings'; import * as userSettings from '../../scripts/settings/userSettings';
import './backdrop.scss';
import ServerConnections from '../ServerConnections'; import ServerConnections from '../ServerConnections';
import './backdrop.scss';
/* eslint-disable indent */ /* eslint-disable indent */
function enableAnimation() { function enableAnimation() {
@ -217,28 +219,6 @@ import ServerConnections from '../ServerConnections';
return list; return list;
} }
function arraysEqual(a, b) {
if (a === b) {
return true;
}
if (a == null || b == null) {
return false;
}
if (a.length !== b.length) {
return false;
}
// If you don't care about the order of the elements inside
// the array, you should sort both arrays here.
for (let i = 0; i < a.length; ++i) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
function enabled() { function enabled() {
return userSettings.enableBackdrops(); return userSettings.enableBackdrops();
} }
@ -259,7 +239,7 @@ import ServerConnections from '../ServerConnections';
} }
function startRotation(images, enableImageRotation) { function startRotation(images, enableImageRotation) {
if (arraysEqual(images, currentRotatingImages)) { if (isEqual(images, currentRotatingImages)) {
return; return;
} }

View File

@ -1,6 +1,8 @@
import { intervalToDuration } from 'date-fns'; import { intervalToDuration } from 'date-fns';
import DOMPurify from 'dompurify'; import DOMPurify from 'dompurify';
import escapeHtml from 'escape-html'; import escapeHtml from 'escape-html';
import isEqual from 'lodash-es/isEqual';
import { appHost } from '../../components/apphost'; import { appHost } from '../../components/apphost';
import loading from '../../components/loading/loading'; import loading from '../../components/loading/loading';
import { appRouter } from '../../components/appRouter'; import { appRouter } from '../../components/appRouter';
@ -1375,10 +1377,9 @@ function renderChildren(page, item) {
const childrenItemsContainer = page.querySelector('.childrenItemsContainer'); const childrenItemsContainer = page.querySelector('.childrenItemsContainer');
if (item.Type == 'MusicAlbum') { if (item.Type == 'MusicAlbum') {
const equalSet = (arr1, arr2) => arr1.every(x => arr2.indexOf(x) !== -1) && arr1.length === arr2.length;
let showArtist = false; let showArtist = false;
for (const track of result.Items) { for (const track of result.Items) {
if (!equalSet(track.ArtistItems.map(x => x.Id), track.AlbumArtists.map(x => x.Id))) { if (!isEqual(track.ArtistItems.map(x => x.Id).sort(), track.AlbumArtists.map(x => x.Id).sort())) {
showArtist = true; showArtist = true;
break; break;
} }