small cleanup

AuthorKonata <konata@posteo.jp>
Date
Commit02a821a29a53801a6e15b4bc8537bdedc49013b5
Parentb7d3c71
5 files changed, 5 insertions(+), 10 deletions(-)
▾Mwebclient/src/App.tsx
@@ -377,7 +377,6 @@ const App: Component = () => {
/>
<Playlist
currentDir={currentDir}
playlist={playlist}
setPlaylist={setPlaylist}
playerState={playerState}
▾Mwebclient/src/components/Dialog.css
@@ -17,6 +17,5 @@ dialog {
flex-direction: column;
background-color: var(--color-a);
padding: 1.5rem;
max-height: 90vh;
}
}
▾Mwebclient/src/components/DownloadButton.tsx
@@ -26,7 +26,7 @@ export function DownloadButton(props: DownloadButtonProps) {
onClick={(event) => {
event.stopPropagation();
if (!props.isOffline())
download(props.fileName, props.item, props.currentDir(), props.currentDir, props.options, props.fetchFiles);
download(props.fileName, props.item, props.currentDir(), props.options, props.fetchFiles);
else deleteFile(props.fileName, props.item, props.currentDir(), props.fetchFiles);
}}
>
▾Mwebclient/src/components/Playlist.tsx
@@ -18,7 +18,6 @@ import { DraggableList } from "./DraggableList";
import type { FlatFileListing } from "../App";
interface PlaylistProps {
currentDir: Accessor<string>;
playlist: Accessor<PlaylistItem[]>;
setPlaylist: Setter<PlaylistItem[]>;
playerState: PlayerState;
@@ -78,7 +77,7 @@ export default function Playlist(props: PlaylistProps) {
const downloadPromises = itemsToSync.map((item) => {
const basePath = item.path.split("/").slice(0, -1).join("/");
const fileName = item.path.split("/").toReversed()[0];
return download(fileName, item, basePath, props.currentDir, props.options, props.fetchFiles);
return download(fileName, item, basePath, props.options, props.fetchFiles);
});
await Promise.allSettled(downloadPromises);
toast("Playlist sync completed", "success");
▾Mwebclient/src/offline.ts
@@ -8,7 +8,7 @@ import type {
import { parseMap } from "music-server-shared/mapconversion";
import type { AppOptions, Playlist, PlaylistItem } from "./types";
import { joinPath, toast } from "./utils";
import { createSignal, type Accessor, type ResourceActions, type Signal } from "solid-js";
import { createSignal, type ResourceActions, type Signal } from "solid-js";
import { AsyncSemaphore } from "./semaphore";
import { encodePath } from "music-server-shared/utils";
import type { FlatFileListing } from "./App";
@@ -396,7 +396,6 @@ const downloadSemaphore = new AsyncSemaphore(1);
//concurrency control via the downloadSemaphore
async function downloadFile(
path: string,
currentDir: Accessor<string>,
options: AppOptions,
item: MediaFile,
fetchFiles: ResourceActions<FlatFileListing>,
@@ -461,13 +460,12 @@ export async function download(
fileName: string,
item: MediaFile | Directory,
basePath: string,
currentDir: Accessor<string>,
options: AppOptions,
fetchFiles: ResourceActions<FlatFileListing>,
) {
const fullPath = joinPath(basePath, fileName);
if ("metadata" in item) {
await downloadFile(fullPath, currentDir, options, item, fetchFiles);
await downloadFile(fullPath, options, item, fetchFiles);
} else {
updateProgressAmount(startProgress(fullPath), 1);
try {
@@ -475,7 +473,7 @@ export async function download(
//start downloads for all children to allow them to run in parallel, then wait for the results
const promises: Promise<unknown>[] = [];
for (const [childName, childItem] of await listFiles(fullPath, false, false)) {
promises.push(download(childName, childItem, fullPath, currentDir, options, fetchFiles));
promises.push(download(childName, childItem, fullPath, options, fetchFiles));
}
await Promise.allSettled(promises);
} finally {