Update serverfolder enable/disable

This commit is contained in:
jeffvli
2022-10-27 00:58:59 -07:00
parent 88e716b970
commit cbbf3087ff
8 changed files with 157 additions and 14 deletions
+4 -4
View File
@@ -13,7 +13,7 @@ export enum AlbumSort {
RATING = 'rating',
}
const include = (options: { songs?: boolean; user?: AuthUser }) => {
const include = (user: AuthUser, options: { songs?: boolean }) => {
// Prisma.AlbumInclude
const props = {
_count: {
@@ -24,17 +24,17 @@ const include = (options: { songs?: boolean; user?: AuthUser }) => {
},
albumArtists: true,
artists: true,
favorites: { where: { userId: options.user?.id } },
favorites: { where: { userId: user?.id } },
genres: true,
images: true,
ratings: {
where: {
userId: options.user?.id,
userId: user?.id,
},
},
server: true,
serverFolders: true,
songs: options?.songs && songHelpers.findMany(),
songs: options?.songs && songHelpers.findMany(user),
};
return props;
+5 -3
View File
@@ -176,6 +176,7 @@ const relatedServerFolders = (items: ServerFolder[]) => {
/* eslint-disable sort-keys-fix/sort-keys-fix */
id: item.id,
name: item.name,
enabled: item.enabled,
remoteId: item.remoteId,
lastScannedAt: item.lastScannedAt,
/* eslint-enable sort-keys-fix/sort-keys-fix */
@@ -266,13 +267,14 @@ const songs = (
) => {
return (
items?.map((item) => {
const url = options.url ? options.url : item.server.serverUrls[0].url;
const customUrl = item.server.serverUrls[0].url;
const baseUrl = customUrl ? customUrl : options.url;
const stream = streamUrl(options.type, {
deviceId: options.deviceId,
remoteId: item.remoteId,
token: options.token,
url: options.url,
url: baseUrl,
userId: options.userId,
});
@@ -294,7 +296,7 @@ const songs = (
item.images,
options.type,
ImageType.PRIMARY,
url,
baseUrl,
item.remoteId
),
releaseDate: item.releaseDate,
+7 -2
View File
@@ -1,4 +1,5 @@
import { Prisma } from '@prisma/client';
import { AuthUser } from '@middleware/authenticate';
const include = () => {
const props: Prisma.SongInclude = {
@@ -16,7 +17,7 @@ const include = () => {
return props;
};
const findMany = () => {
const findMany = (user: AuthUser) => {
const props: Prisma.SongFindManyArgs = {
include: {
album: true,
@@ -26,7 +27,11 @@ const findMany = () => {
images: true,
ratings: true,
server: {
include: { serverUrls: true },
include: {
serverUrls: {
where: { userServerUrls: { some: { userId: user.id } } },
},
},
},
},
orderBy: [