Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
silversonicaxel committed Aug 27, 2024
1 parent 85de09f commit f02a5ab
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
22 changes: 10 additions & 12 deletions src/components/ScrobbleItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,9 @@ export default function ScrobbleItem({

const parsedComplete = highlight;

const textComplete = renderToStaticMarkup((
<span className="scrobbled-item-cleanup">
{parsedComplete}
</span>
));
const textComplete = renderToStaticMarkup(<span className="scrobbled-item-cleanup">{parsedComplete}</span>);

const itemComplete = replaceLastOccurrence(
parsedItem,
parsedComplete,
textComplete
);
const itemComplete = replaceLastOccurrence(parsedItem, parsedComplete, textComplete);

return itemComplete;
};
Expand Down Expand Up @@ -249,15 +241,21 @@ export default function ScrobbleItem({
songInfo = (
<Label className="d-flex align-items-center mb-0" htmlFor={scrobbleItemInputId}>
{!!settings?.showTrackNumbers && scrobble.trackNumber && <span className="me-1">{scrobble.trackNumber}.</span>}
<span className="song flex-grow-1 pe-2 truncate" dangerouslySetInnerHTML={{ __html: getCompleteItem(songFullTitle, cleanupPattern) }}></span>
<span
className="song flex-grow-1 pe-2 truncate"
dangerouslySetInnerHTML={{ __html: getCompleteItem(songFullTitle, cleanupPattern) }}
></span>
{timeOrDuration}
</Label>
);
} else {
// FULL view
songInfo = (
<>
<span className="song" dangerouslySetInnerHTML={{ __html: getCompleteItem(songFullTitle, cleanupPattern) }}></span>
<span
className="song"
dangerouslySetInnerHTML={{ __html: getCompleteItem(songFullTitle, cleanupPattern) }}
></span>
<Label className="d-flex mb-0" htmlFor={scrobbleItemInputId}>
<small className="text-muted flex-grow-1 truncate album">
{scrobble.album && (
Expand Down
3 changes: 2 additions & 1 deletion src/domains/scrobbleAlbum/partials/Tracklist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ export default function Tracklist({ albumInfo, tracks }: { albumInfo: Album | nu
.reduce((result, track) => {
const newTrack = {
...track,
title: cleanupPatternSmart !== '' ? cleanupLastEndStringOccurrence(track.title, cleanupPatternSmart) : track.title,
title:
cleanupPatternSmart !== '' ? cleanupLastEndStringOccurrence(track.title, cleanupPatternSmart) : track.title,
album: albumInfo?.name || '',
albumArtist: albumInfo?.artist || '',
timestamp: rollingTimestamp,
Expand Down
6 changes: 1 addition & 5 deletions src/domains/scrobbleAlbum/partials/TracklistCleanupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ export function TracklistCleanupForm({ onCleanupPatternChange }: TracklistCleanu
/>
</div>
<div className="col-6">
<Input
className="form-control-sm form-control"
id="albumCleanupPattern"
onChange={onCleanupPatternChange}
/>
<Input className="form-control-sm form-control" id="albumCleanupPattern" onChange={onCleanupPatternChange} />
</div>
<div className="col-12">
<Alert
Expand Down
4 changes: 3 additions & 1 deletion src/utils/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ describe('`cleanupLastEndStringOccurrence` helper', () => {

it('returns full string without the last with extra alphabetic characters', () => {
expect(cleanupLastEndStringOccurrence('live forever (remastered)', '(remastered)')).toBe('live forever');
expect(cleanupLastEndStringOccurrence('Dazed and Confused - 3/23/69 Top Gear;Remaster', ' - 3/23/69 Top Gear;Remaster')).toBe('Dazed and Confused');
expect(
cleanupLastEndStringOccurrence('Dazed and Confused - 3/23/69 Top Gear;Remaster', ' - 3/23/69 Top Gear;Remaster')
).toBe('Dazed and Confused');
});

it('returns full string if cleanup pattern is not at end of string', () => {
Expand Down
6 changes: 2 additions & 4 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ export function replaceLastOccurrence(fullString: string, lastString: string, re
return fullString;
}

return (
`${fullString.substring(0, lastStringIndex)}${replaceString}${fullString.substring(lastStringIndex + lastString.length)}`
);
};
return `${fullString.substring(0, lastStringIndex)}${replaceString}${fullString.substring(lastStringIndex + lastString.length)}`;
}

export function cleanupLastEndStringOccurrence(fullString: string, pattern: string) {
if (fullString.endsWith(pattern)) {
Expand Down

0 comments on commit f02a5ab

Please sign in to comment.