diff --git a/src/domains/scrobbleAlbum/partials/Tracklist.tsx b/src/domains/scrobbleAlbum/partials/Tracklist.tsx
index 8d9da59..a1956c2 100644
--- a/src/domains/scrobbleAlbum/partials/Tracklist.tsx
+++ b/src/domains/scrobbleAlbum/partials/Tracklist.tsx
@@ -1,4 +1,4 @@
-import { useState, useEffect, Suspense, useMemo } from 'react';
+import { useState, useEffect, Suspense, useMemo, useCallback, ChangeEventHandler, useContext } from 'react';
import lazyWithPreload from 'react-lazy-with-preload';
import { useDispatch } from 'react-redux';
import { Trans, useTranslation } from 'react-i18next';
@@ -17,7 +17,9 @@ import { enqueueScrobble } from 'store/actions/scrobbleActions';
import { DEFAULT_SONG_DURATION, getAmznLink } from 'Constants';
+import { cleanTitleWithPattern, CleanupPatternContext } from '../CleanupContext';
import { EmptyDiscMessage } from './EmptyDiscMessage';
+import { TracklistFilter } from './TracklistFilter';
import type { Album, DiscogsAlbum } from 'utils/types/album';
import type { Scrobble } from 'utils/types/scrobble';
@@ -41,6 +43,8 @@ export default function Tracklist({ albumInfo, tracks }: { albumInfo: Album | nu
const [useCustomTimestamp, setUseCustomTimestamp] = useState(false);
const [selectedTracks, setSelectedTracks] = useState>(new Set());
const [totalDuration, setTotalDuration] = useState(0);
+ const { cleanupPattern } = useContext(CleanupPatternContext);
+
const albumHasTracks = tracks && tracks.length > 0;
const hasAlbumInfo = !!albumInfo && Object.keys(albumInfo).length > 0;
@@ -112,6 +116,7 @@ export default function Tracklist({ albumInfo, tracks }: { albumInfo: Album | nu
.reduce((result, track) => {
const newTrack = {
...track,
+ title: cleanTitleWithPattern(track.title, cleanupPattern),
album: albumInfo?.name || '',
albumArtist: albumInfo?.artist || '',
timestamp: rollingTimestamp,
@@ -130,7 +135,8 @@ export default function Tracklist({ albumInfo, tracks }: { albumInfo: Album | nu
}
return result;
- }, []);
+ }, [])
+ .filter(({ title }) => title !== '');
enqueueScrobble(dispatch)(tracksToScrobble);
setCanScrobble(selectedTracks.size > 0);
@@ -239,6 +245,7 @@ export default function Tracklist({ albumInfo, tracks }: { albumInfo: Album | nu
)}
+
>(
+ (event) => {
+ const { value } = event.target;
+ setValue(value);
+ setCleanupPattern(strToCleanupPattern(value));
+ },
+ [setCleanupPattern]
+ );
+
+ return (
+
+ );
+}
diff --git a/src/utils/common.test.ts b/src/utils/common.test.ts
index 6f01874..214c16c 100644
--- a/src/utils/common.test.ts
+++ b/src/utils/common.test.ts
@@ -47,12 +47,12 @@ describe('`sanitizeProvider` helper', () => {
it('returns a custom default provider when an invalid one is given', () => {
expect(sanitizeProvider('winamp', 'lastfm')).toBe('lastfm');
});
+});
- describe('`sha256` digest', () => {
- it('returns the correct SHA-256 hash for a given string', () => {
- const str = 'hello world';
- const expectedHash = 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9';
- sha256(str).then((hash) => expect(hash).toBe(expectedHash));
- });
+describe('`sha256` digest', () => {
+ it('returns the correct SHA-256 hash for a given string', () => {
+ const str = 'hello world';
+ const expectedHash = 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9';
+ sha256(str).then((hash) => expect(hash).toBe(expectedHash));
});
});