Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve: cover (ui) #115

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/data/store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { path } from "@tauri-apps/api";
import { appConfigDir, audioDir, downloadDir } from "@tauri-apps/api/path";
import {
appConfigDir,
audioDir,
downloadDir,
pictureDir,
} from "@tauri-apps/api/path";
import * as fs from "@tauri-apps/plugin-fs";
import { type, type OsType } from "@tauri-apps/plugin-os";
import type {
Expand Down Expand Up @@ -139,6 +144,7 @@ export const nextUpSong: Writable<Song> = writable(null);
export const songsJustAdded: Writable<Song[]> = writable([]);
export const songJustAdded = writable(false);
export const shouldShowToast = writable(true);
export const rightClickedAlbum: Writable<Album> = writable(null);
export const rightClickedTrack: Writable<Song> = writable(null);
export const rightClickedTracks: Writable<Song[]> = writable(null);
export const playerTime = writable(0);
Expand Down Expand Up @@ -395,6 +401,13 @@ export const waveformPeaks: Writable<WaveformPlayerState> = writable({
*/
export const lastWrittenSongs: Writable<Song[]> = writable([]);

export const artworkDirectory: Writable<string> = writable(
localStorage.getItem("artworkDirectory"),
);
artworkDirectory.subscribe((val) =>
localStorage.setItem("artworkDirectory", val),
);

async function init() {
// Set OS
const osType = await type();
Expand Down Expand Up @@ -435,6 +448,10 @@ async function init() {
queue.subscribe(async (songs) => {
await writeQueueToFile(songs);
});

if (!get(artworkDirectory)) {
artworkDirectory.set(await pictureDir());
}
}

export const streamInfo: Writable<StreamInfo> = writable({
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const en = {
artworkTooltipTitle: "🎨 Artwork priority",
artworkTooltipBody:
"<h3 style='margin:0'>🎨 Artwork priority</h3><br/>First, Musicat looks for artwork encoded in the file metadata, which you can overwrite by clicking this square (png and jpg supported). <br/><br/>If there is none, it will look for a file in the album folder called <i>cover.jpg, folder.jpg</i> or <i>artwork.jpg</i> (you can change this list of filenames in Settings).<br/><br/>Otherwise, it will look for any image in the album folder and use that.",
encodedInFile: "Encoded in file",
encodedInFile: "In metadata",
bit: "bit",
noMetadata: "Song has no metadata",
unsupportedFormat:
Expand Down
1 change: 1 addition & 0 deletions src/lib/albums/AlbumDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
class="texture"
src="images/textures/soft-wallpaper.png"
loading="lazy"
on:contextmenu|preventDefault={() => {}}
async
/>
<div class="artwork-frame">
Expand Down
5 changes: 4 additions & 1 deletion src/lib/albums/AlbumMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import {
popupOpen,
userSettings,
rightClickedAlbum,
rightClickedTrack,
rightClickedTracks,
} from "../../data/store";
Expand Down Expand Up @@ -123,9 +124,11 @@
if (songs.length === 1) {
$rightClickedTracks = [];
$rightClickedTrack = song;
$rightClickedAlbum = null;
} else {
$rightClickedTracks = songs;
$rightClickedTrack = null;
$rightClickedAlbum = album;
}

close();
Expand Down Expand Up @@ -232,7 +235,7 @@
<MenuOption text={result.error || result.success} isDisabled />
{/if}
<MenuOption
onClick={compose(searchArtworkOnBrave, song)}
onClick={compose(searchArtworkOnBrave, album)}
text="Search for artwork on Brave"
/>
{#if song.artist}
Expand Down
12 changes: 10 additions & 2 deletions src/lib/info/CountrySection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@
let originCountryEdited = originCountry;

async function fetchFromWikipedia() {
originCountryEdited = null;
if (isFetchingOriginCountry) {
return;
}

isFetchingOriginCountry = true;
originCountryEdited = null;

const country = await findCountryByArtist(
($rightClickedTrack || $rightClickedTracks[0]).artist,
);

console.log("country", country);
if (country) {
originCountryEdited = country;
Expand Down Expand Up @@ -81,7 +87,9 @@
onClick={fetchFromWikipedia}
isLoading={isFetchingOriginCountry}
text={$LL.trackInfo.fetchFromWikipedia()}
icon="tabler:world-download"
icon={isFetchingOriginCountry
? "line-md:loading-loop"
: "tabler:world-download"}
theme="transparent"
/>
</div>
Expand Down
Loading