Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 2 additions & 5 deletions packages/webamp/js/components/MainWindow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import PlaylistToggleButton from "./PlaylistToggleButton";
import Kbps from "./Kbps";
import Khz from "./Khz";
import WorkIndicator from "./work-indicator"

Check failure on line 22 in packages/webamp/js/components/MainWindow/index.tsx

View workflow job for this annotation

GitHub Actions / ci

Insert `;`
import Marquee from "./Marquee";
import MonoStereo from "./MonoStereo";
import Position from "./Position";
Expand Down Expand Up @@ -50,7 +51,7 @@
const loading = useTypedSelector(Selectors.getLoading);
const doubled = useTypedSelector(Selectors.getDoubled);
const llama = useTypedSelector(Selectors.getLlamaMode);
const working = useTypedSelector(Selectors.getWorking);

Check warning on line 54 in packages/webamp/js/components/MainWindow/index.tsx

View workflow job for this annotation

GitHub Actions / ci

'working' is assigned a value but never used. Allowed unused vars must match /^_/u

const className = classnames({
window: true,
Expand Down Expand Up @@ -99,11 +100,7 @@
</div>
<div className="webamp-status">
<ClutterBar />
{!working && <div id="play-pause" />}
<div
id="work-indicator"
className={classnames({ selected: working })}
/>
<WorkIndicator />
<Time />
</div>
<Vis analyser={analyser} />
Expand Down
24 changes: 24 additions & 0 deletions packages/webamp/js/components/MainWindow/work-indicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as React from "react";
import classnames from "classnames";
import { useTypedSelector } from "../../hooks";
import * as Selectors from "../../selectors";
import { MEDIA_STATUS } from "../../constants";

export default function WorkIndicator() {
const kbps = useTypedSelector(Selectors.getKbps);

Check failure on line 8 in packages/webamp/js/components/MainWindow/work-indicator.tsx

View workflow job for this annotation

GitHub Actions / ci

Delete `··`
const khz = useTypedSelector(Selectors.getKhz);

Check failure on line 9 in packages/webamp/js/components/MainWindow/work-indicator.tsx

View workflow job for this annotation

GitHub Actions / ci

Replace `····` with `··`
const mediaStatus = useTypedSelector(Selectors.getMediaStatus);

Check failure on line 10 in packages/webamp/js/components/MainWindow/work-indicator.tsx

View workflow job for this annotation

GitHub Actions / ci

Delete `··`

const working =

Check failure on line 12 in packages/webamp/js/components/MainWindow/work-indicator.tsx

View workflow job for this annotation

GitHub Actions / ci

Delete `··`
mediaStatus === MEDIA_STATUS.PLAYING &&
!(kbps != null &&

Check failure on line 14 in packages/webamp/js/components/MainWindow/work-indicator.tsx

View workflow job for this annotation

GitHub Actions / ci

Replace `⏎····khz·!=·null·&&⏎···` with `·khz·!=·null·&&`
khz != null &&
kbps.trim() !== "0");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this whole expression could become a new selector getIsWorking? That way we would get memoization.

This kbps.trim() !== "0" string comparison seems sus especially given that we do a padded string if kbps is falsy. Are you sure it's "0" and not "00"? Either way, would be much cleaner if we could check this before we transform it into a string.

Very awkward to do "convert nullish/missing into a specific default string" followed by "check for this specific default string to detect if it's nullish/missing.

Better to go up to the source.


return (

Check failure on line 18 in packages/webamp/js/components/MainWindow/work-indicator.tsx

View workflow job for this annotation

GitHub Actions / ci

Delete `··`
<div

Check failure on line 19 in packages/webamp/js/components/MainWindow/work-indicator.tsx

View workflow job for this annotation

GitHub Actions / ci

Replace `····<div⏎········id="work-indicator"⏎········className={classnames({·selected:·working·})}⏎·······` with `<div·id="work-indicator"·className={classnames({·selected:·working·})}`
id="work-indicator"
className={classnames({ selected: working })}
/>
);

Check failure on line 23 in packages/webamp/js/components/MainWindow/work-indicator.tsx

View workflow job for this annotation

GitHub Actions / ci

Delete `··`
}
Loading