Skip to content

Commit

Permalink
Use unique key to prevent email component reuse
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Jun 10, 2022
1 parent 2ee948e commit 2948c5e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@

<Actions class="email__actions"
:aria-label="t('settings', 'Email options')"
:disabled="deleteDisabled"
:force-menu="true">
<ActionButton :aria-label="deleteEmailLabel"
:close-after-click="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@

<template v-if="additionalEmails.length">
<em class="additional-emails-label">{{ t('settings', 'Additional emails') }}</em>
<!-- TODO use unique key for additional email when uniqueness can be guaranteed, see https://github.com/nextcloud/server/issues/26866 -->
<Email v-for="(additionalEmail, index) in additionalEmails"
:key="index"
:key="additionalEmail.key"
:index="index"
:scope.sync="additionalEmail.scope"
:email.sync="additionalEmail.value"
Expand Down Expand Up @@ -85,7 +86,7 @@ export default {
data() {
return {
accountProperty: ACCOUNT_PROPERTY_READABLE_ENUM.EMAIL,
additionalEmails,
additionalEmails: additionalEmails.map(properties => ({ ...properties, key: this.generateUniqueKey() })),
displayNameChangeSupported,
primaryEmail,
savePrimaryEmailScope,
Expand Down Expand Up @@ -119,7 +120,7 @@ export default {
methods: {
onAddAdditionalEmail() {
if (this.isValidSection) {
this.additionalEmails.push({ value: '', scope: DEFAULT_ADDITIONAL_EMAIL_SCOPE })
this.additionalEmails.push({ value: '', scope: DEFAULT_ADDITIONAL_EMAIL_SCOPE, key: this.generateUniqueKey() })
}
},

Expand Down Expand Up @@ -184,6 +185,10 @@ export default {
this.logger.error(errorMessage, error)
}
},

generateUniqueKey() {
return Math.random().toString(36).substring(2)
},
},
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions dist/settings-vue-settings-personal-info.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-personal-info.js.map

Large diffs are not rendered by default.

0 comments on commit 2948c5e

Please sign in to comment.