Skip to content

Commit 2b22056

Browse files
committed
feat: add duplicate removal logic in profiles store during disk sync
1 parent 403fc94 commit 2b22056

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

frontend/src/stores/profiles.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ export const useProfilesStore = defineStore('profiles', () => {
3535
}
3636

3737
if (needsDiskSync) {
38+
// Remove duplicates
39+
profiles.value = profiles.value.reduce((p, c) => {
40+
const x = p.find((item) => item.id === c.id)
41+
if (!x) {
42+
return p.concat([c])
43+
} else {
44+
return p
45+
}
46+
}, [] as IProfile[])
47+
3848
await saveProfiles()
3949
const { alert } = useAlert()
4050
alert('Tip', 'The old profiles have been upgraded. Please adjust manually if necessary.')

0 commit comments

Comments
 (0)