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 9455cd7)
  • Loading branch information
Pytal committed Jun 27, 2022
1 parent 46642ca commit fc03a93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<Actions
class="email__actions"
: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 @@ -48,8 +48,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 @@ -87,7 +88,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 @@ -121,7 +122,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 @@ -186,6 +187,10 @@ export default {
this.logger.error(errorMessage, error)
}
},

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

0 comments on commit fc03a93

Please sign in to comment.