From 4ce826b59e45b7190e2018bf5afa729f160e8eb8 Mon Sep 17 00:00:00 2001 From: Preston Date: Fri, 25 Sep 2020 21:56:54 -0400 Subject: [PATCH] Prevent subscriptions from showing up twice on OPML and NewPipe imports --- .../components/data-settings/data-settings.js | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/data-settings/data-settings.js b/src/renderer/components/data-settings/data-settings.js index 6708f9e4..4ce094f8 100644 --- a/src/renderer/components/data-settings/data-settings.js +++ b/src/renderer/components/data-settings/data-settings.js @@ -171,8 +171,8 @@ export default Vue.extend({ const primaryProfile = JSON.parse(JSON.stringify(this.profileList[0])) // filter out subscriptions that already exist before concatenating profileObject.subscriptions = profileObject.subscriptions.filter(newSub => { - const existingSub = primaryProfile.subscriptions.find(existingSub => existingSub.id === newSub.id) - return !existingSub // return false if sub already exists in default profile + const subExists = primaryProfile.subscriptions.find(existingSub => existingSub.id === newSub.id) + return !subExists // return false if sub already exists in default profile }) primaryProfile.subscriptions = primaryProfile.subscriptions.concat(profileObject.subscriptions) this.updateProfile(primaryProfile) @@ -265,7 +265,13 @@ export default Vue.extend({ thumbnail: channelInfo.authorThumbnails[1].url } - subscriptions.push(subscription) + const subExists = primaryProfile.subscriptions.findIndex((sub) => { + return sub.id === subscription.id || sub.name === subscription.name + }) + + if (subExists === -1) { + subscriptions.push(subscription) + } } count++ @@ -362,7 +368,13 @@ export default Vue.extend({ thumbnail: channelInfo.authorThumbnails[1].url } - subscriptions.push(subscription) + const subExists = primaryProfile.subscriptions.findIndex((sub) => { + return sub.id === subscription.id || sub.name === subscription.name + }) + + if (subExists === -1) { + subscriptions.push(subscription) + } } count++