Skip to content

Commit

Permalink
fix: resolve #207, #208
Browse files Browse the repository at this point in the history
  • Loading branch information
Su-Yong committed Aug 31, 2023
1 parent 760f3df commit f9c0f5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
12 changes: 5 additions & 7 deletions renderer/components/PlayingInfoProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import alsong from 'alsong';
import {
Accessor, batch,
createContext,
createDeferred,
createEffect,
createSignal,
JSX,
Expand Down Expand Up @@ -117,17 +118,14 @@ const PlayingInfoProvider = (props: { children: JSX.Element }) => {

onCleanup(() => window.ipcRenderer.off('update', originalData));

createEffect(on([title, coverUrl, lyricMapper], async () => {
createEffect(on(createDeferred(() => title() && coverUrl()), async () => {
const data = originalData();
const mapper = lyricMapper();

if (!data) return;
let coverUrl = data.cover_url;
if (!coverUrl) {
coverUrl = 'unknown';
}
const coverDataURL = data.cover_url ?? 'unknown';

const id: number | undefined = mapper[`${data.title}:${coverUrl}`];
const id: number | undefined = mapper[`${data.title}:${coverDataURL}`];
const lyricInfo = await (async (): Promise<LyricInfo | null> => {
const alsongLyric = (
id
Expand All @@ -144,8 +142,8 @@ const PlayingInfoProvider = (props: { children: JSX.Element }) => {
useMapper: !!id,
kind: 'default',
data: {
...data,
lyric: data.lyrics,
...data
},
} as const;
}
Expand Down
11 changes: 1 addition & 10 deletions renderer/main/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ const useProximityStyle = () => {
setDistance(Math.hypot(x - targetAnchorX(), y - targetAnchorY()));
};

const onMouseLeave = () => {
if (fullDimmedOpacity() === 1) {
return;
}

setDistance(1);
};

const proximityOpacity = () => {
if (distance() > 0.5) {
return 1;
Expand All @@ -72,14 +64,13 @@ const useProximityStyle = () => {
};

const [element, elementRef] = createSignal<HTMLDivElement | null>(null);
createRenderEffect(on([proximityOpacity], () => {
createRenderEffect(on(proximityOpacity, () => {
element()?.animate([{ opacity: proximityOpacity() }], { duration: 500, fill: 'forwards' });
}));

return {
ref: elementRef,
onMouseMove,
onMouseLeave,
};
};

Expand Down

0 comments on commit f9c0f5d

Please sign in to comment.