Removing remaining artistLoaded, albumLoaded, etc in favor of itemLoaded for consistent pipeline; Looking at search

This commit is contained in:
James Barnsley
2020-09-13 20:59:46 +12:00
parent f254170b2f
commit 449b32a384
30 changed files with 579 additions and 465 deletions

View File

@ -369,20 +369,26 @@ let isObject = function (value) {
* @param key = string (the string to lookup)
* @return boolean
* */
const isLoading = function (load_queue = [], keys = []) {
// Loop all of our load queue items
for (const load_queue_key in load_queue) {
// Make sure it's not a root object method
if (load_queue.hasOwnProperty(load_queue_key)) {
// Loop all the keys we're looking for
for (let i = 0; i < keys.length; i++) {
if (load_queue[load_queue_key].includes(keys[i])) {
return true;
}
}
const isLoading = function (load_queue = {}, keys = []) {
if (!load_queue || !keys) return false;
const queue_keys = Object.keys(load_queue);
const matches = keys.reduce((acc, key) => {
let regex = '';
try {
regex = new RegExp(key);
} catch {
console.error('Invalid regular expression', keys);
return acc;
}
}
return false;
return [
...acc,
...(queue_keys.filter((qk) => qk.match(regex))),
];
}, []);
return matches.length > 0;
};