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>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
(cherry picked from commit fc03a93)
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
  • Loading branch information
Pytal authored and nextcloud-command committed Jun 27, 2022
1 parent 3008908 commit 57c2a8a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
14 changes: 7 additions & 7 deletions apps/settings/js/vue-settings-personal-info.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<Actions
class="actions-email"
:aria-label="t('settings', 'Email options')"
:disabled="deleteDisabled"
:force-menu="true">
<ActionButton
:aria-label="deleteEmailLabel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
<span v-else>
{{ primaryEmail.value || t('settings', 'No email address set') }}
</span>
<!-- 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 @@ -77,7 +78,7 @@ export default {

data() {
return {
additionalEmails,
additionalEmails: additionalEmails.map(properties => ({ ...properties, key: this.generateUniqueKey() })),
displayNameChangeSupported,
primaryEmail,
isValidForm: true,
Expand Down Expand Up @@ -110,7 +111,7 @@ export default {
methods: {
onAddAdditionalEmail() {
if (this.$refs.form?.checkValidity()) {
this.additionalEmails.push({ value: '', scope: DEFAULT_ADDITIONAL_EMAIL_SCOPE })
this.additionalEmails.push({ value: '', scope: DEFAULT_ADDITIONAL_EMAIL_SCOPE, key: this.generateUniqueKey() })
this.$nextTick(() => this.updateFormValidity())
}
},
Expand Down Expand Up @@ -172,6 +173,10 @@ export default {
updateFormValidity() {
this.isValidForm = this.$refs.form?.checkValidity()
},

generateUniqueKey() {
return Math.random().toString(36).substring(2)
},
},
}
</script>
Expand Down

0 comments on commit 57c2a8a

Please sign in to comment.