work on mail settings

This commit is contained in:
Kevin Froman 2020-02-24 04:45:29 -06:00
parent 56e86460d1
commit 6f0ef390a7
6 changed files with 36 additions and 28 deletions

View file

@ -166,18 +166,6 @@
</div>
</div>
</div>
<div class="columns">
<div class="column">
Keep messages when blocks are deleted
</div>
<div class="column is-2">
<div class="field">
<input id="maintainMessagesSetting" type="checkbox"
class="switch is-rounded">
<label for="maintainMessagesSetting"></label>
</div>
</div>
</div>
<div class="columns">
<div class="column">
Inbox notifications

View file

@ -12,6 +12,9 @@ fetch('/config/get/mail', {
document.getElementById('forwardSecrecySetting').checked = false
}
if (mailSettings.use_padding === false){
document.getElementById('messagePaddingSetting').checked = false
document.getElementById('messagePaddingSetting').checked = false
}
if (mailSettings.notificationSetting === false){
document.getElementById('notificationSetting').checked = false
}
})

View file

@ -37,7 +37,7 @@ document.getElementById('forwardSecrecySetting').onchange = function(e){
notificationSetting.onchange = function(e){
let notificationSettings = document.getElementsByClassName('notificationSetting')
var notificationSettings = document.getElementsByClassName('notificationSetting')
if (e.target.checked){
for (i = 0; i < notificationSettings.length; i++){
notificationSettings[i].style.display = "flex"
@ -48,4 +48,19 @@ notificationSetting.onchange = function(e){
notificationSettings[i].style.display = "none"
}
}
var postData = JSON.stringify({"notificationSetting": e.target.checked})
fetch('/config/set/mail', {
method: 'POST',
body: postData,
headers: {
"content-type": "application/json",
"token": webpass
}})
.then((resp) => resp.text())
.then(function(data) {
mailSettings['notificationSetting'] = notificationSetting.checked
PNotify.success({
text: 'Successfully toggled default mail notifications'
})
})
}