Skip to content

Commit

Permalink
replace .map().indexOf() with .findIndex()
Browse files Browse the repository at this point in the history
  • Loading branch information
rocka committed Feb 8, 2024
1 parent 636ab32 commit 4200adb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/renderer/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ export function clearRadio({ commit, dispatch }) {
*/
export async function getRadio({ commit }) {
const resp = await Api.getRadioE();
const tracks = []
const tracks = [];
if (resp.code === 200) {
const a = { source: { name: 'radio' } };
tracks.push(...resp.data.map(t => new Track(t, a)));
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/store/modules/radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ const mutations = {
}
for (const t of tracks) {
if (trackIdSet.has(t.id)) {
const duplicate = state.list.map(s => s.id).indexOf(t.id);
const duplicate = state.list.findIndex(s => s.id === t.id);
state.list.splice(duplicate, 1);
if (duplicate < state.index) state.index--;
if (duplicate <= state.index) state.index--;
} else {
trackIdSet.add(t.id);
}
Expand Down

0 comments on commit 4200adb

Please sign in to comment.