Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save sign preference #8215

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ public function index(): TemplateResponse {
'debug',
$this->config->getSystemValue('debug', false)
);

$this->initialStateService->provideInitialState(
'smime-sign-accounts',
$this->preferences->getPreference($this->currentUserId, 'smime-sign-accounts','')
);
$this->initialStateService->provideInitialState(
'ncVersion',
$this->config->getSystemValue('version', '0.0.0')
Expand Down Expand Up @@ -183,6 +186,7 @@ public function index(): TemplateResponse {
'collect-data' => $this->preferences->getPreference($this->currentUserId, 'collect-data', 'true'),
'start-mailbox-id' => $this->preferences->getPreference($this->currentUserId, 'start-mailbox-id'),
'tag-classified-messages' => $this->preferences->getPreference($this->currentUserId, 'tag-classified-messages', 'true'),

]);
$this->initialStateService->provideInitialState(
'prefill_displayName',
Expand Down
38 changes: 34 additions & 4 deletions src/components/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,7 @@
</ActionCheckbox>
<ActionCheckbox v-if="smimeCertificateForCurrentAlias"
:checked="wantsSmimeSign"
@check="wantsSmimeSign = true"
@uncheck="wantsSmimeSign = false">
@change="setSmimeSign($event)">
{{ t('mail', 'Sign message with S/MIME') }}
</ActionCheckbox>
<ActionCheckbox v-if="smimeCertificateForCurrentAlias"
Expand Down Expand Up @@ -623,7 +622,7 @@ export default {
},
},
autoLimit: true,
wantsSmimeSign: this.smimeSign,
wantsSmimeSign: this.smimeSign || this.isSignSet,
wantsSmimeEncrypt: this.smimeEncrypt,
isPickerOpen: false,
}
Expand Down Expand Up @@ -783,7 +782,15 @@ export default {

return this.smimeCertificateForAlias(this.selectedAlias)
},

accountWithSmimeSignSet() {
return this.$store.getters.getPreference('smime-sign-accounts', '').split(',').filter((account) => account !== '')
},
/**
* whether the user set a sign preference for the current account/alias
*/
isSignSet() {
return this.accountWithSmimeSignSet.includes(this.selectedAlias.emailAddress)
},
/**
* Whether the outgoing message should be signed with S/MIME.
*
Expand Down Expand Up @@ -898,6 +905,29 @@ export default {
window.removeEventListener('mailvelope', this.onMailvelopeLoaded)
},
methods: {
setSmimeSign(e) {
console.log(e)
this.wantsSmimeSign = e.target.checked
let value
if (e.target.checked) {
value = [...this.accountWithSmimeSignSet, this.selectedAlias.emailAddress]
} else {
value = this.accountWithSmimeSignSet.filter((email) => email !== this.selectedAlias.emailAddress)
}
console.log(e, value)
this.$store
.dispatch('savePreference', {
key: 'smime-sign-accounts',
value: value.toString(),
})
.then(() => {
showWarning(t('mail', value))
})
.catch((error) => Logger.error('could not save preferences', { error }))
.then((error) => {
showWarning(t('mail', error))
})
},
openPicker() {
this.isPickerOpen = true
},
Expand Down