From c262b67626758268dff411b24de36f8c8a22c64b Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Mon, 4 Mar 2019 21:16:33 -0600 Subject: [PATCH] fixed UI sentbox --- .../default-plugins/pms/mailapi.py | 3 +++ onionr/static-data/www/mail/mail.js | 21 ++++++++++++------- onionr/static-data/www/mail/sendmail.js | 4 +++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/onionr/static-data/default-plugins/pms/mailapi.py b/onionr/static-data/default-plugins/pms/mailapi.py index 31f6f18e..766ae724 100644 --- a/onionr/static-data/default-plugins/pms/mailapi.py +++ b/onionr/static-data/default-plugins/pms/mailapi.py @@ -20,6 +20,7 @@ import sys, os, json from flask import Response, request, redirect, Blueprint, abort import core +from onionrusers import contactmanager sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) import loadinbox, sentboxdb @@ -54,5 +55,7 @@ def list_sentbox(): if sentbox_list_copy[x]['hash'] in deleted: x -= 1 sentbox_list.pop(x) + else: + sentbox_list[x]['name'] = contactmanager.ContactManager(c, sentbox_list[x]['peer'], saveUser=False).get_info('name') return json.dumps(sentbox_list) \ No newline at end of file diff --git a/onionr/static-data/www/mail/mail.js b/onionr/static-data/www/mail/mail.js index 8a4b2057..57c5fa40 100755 --- a/onionr/static-data/www/mail/mail.js +++ b/onionr/static-data/www/mail/mail.js @@ -191,36 +191,41 @@ function getSentbox(){ .then(function(resp) { var keys = []; var entry = document.createElement('div') - var entryUsed; for(var k in resp) keys.push(k); if (keys.length == 0){ threadPart.innerHTML = "nothing to show here yet." } for (var i = 0; i < keys.length; i++){ var entry = document.createElement('div') - var obj = resp[i]; + var obj = resp[i] var toLabel = document.createElement('span') toLabel.innerText = 'To: ' var toEl = document.createElement('input') var preview = document.createElement('span') var deleteBtn = document.createElement('button') + var message = resp[i]['message'] deleteBtn.classList.add('deleteBtn', 'dangerBtn') deleteBtn.innerText = 'X' toEl.readOnly = true - toEl.value = resp[i]['peer'] + if (resp[i]['name'] == null){ + toEl.value = resp[i]['peer'] + } + else{ + toEl.value = resp[i]['name'] + } preview.innerText = '(' + resp[i]['subject'] + ')' entry.setAttribute('data-hash', resp[i]['hash']) entry.appendChild(deleteBtn) entry.appendChild(toLabel) entry.appendChild(toEl) entry.appendChild(preview) - entryUsed = resp[i]['message'] - entry.onclick = function(){ + entry.onclick = (function(tree, el, msg) {return function() { console.log(resp) - if (! entry.target.classList.contains('deleteBtn')){ - showSentboxWindow(toEl.value, entryUsed) + if (! entry.classList.contains('deleteBtn')){ + showSentboxWindow(el.value, msg) } - } + };})(entry, toEl, message); + deleteBtn.onclick = function(){ entry.parentNode.removeChild(entry); deleteMessage(entry.getAttribute('data-hash')) diff --git a/onionr/static-data/www/mail/sendmail.js b/onionr/static-data/www/mail/sendmail.js index abece988..704574e6 100755 --- a/onionr/static-data/www/mail/sendmail.js +++ b/onionr/static-data/www/mail/sendmail.js @@ -27,6 +27,7 @@ function sendMail(to, message, subject){ //postData = {"postData": '{"to": "' + to + '", "message": "' + message + '"}'} // galaxy brain postData = {'message': message, 'to': to, 'type': 'pm', 'encrypt': true, 'meta': JSON.stringify({'subject': subject})} postData = JSON.stringify(postData) + sendForm.style.display = 'none' fetch('/insertblock', { method: 'POST', body: postData, @@ -36,6 +37,8 @@ function sendMail(to, message, subject){ }}) .then((resp) => resp.text()) // Transform the data into json .then(function(data) { + sendForm.style.display = 'block' + alert('Queued for sending!') }) } @@ -51,7 +54,6 @@ sendForm.onsubmit = function(){ return false } } - sendMail(to.value, messageContent.value, subject.value) return false }