From d548723f9025318f218fef1a1e2d231d5ebae74e Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Mon, 19 Aug 2019 01:04:35 -0500 Subject: [PATCH] work on chat --- onionr/static-data/www/chat/css/convos.css | 4 ++++ onionr/static-data/www/chat/index.html | 8 ++++---- onionr/static-data/www/chat/js/messages.js | 17 +++++++++++------ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/onionr/static-data/www/chat/css/convos.css b/onionr/static-data/www/chat/css/convos.css index d174c192..3606ea18 100644 --- a/onionr/static-data/www/chat/css/convos.css +++ b/onionr/static-data/www/chat/css/convos.css @@ -60,3 +60,7 @@ transform: rotate(180deg); direction: ltr; } + +#messageEntryTemplate{ + display: none; +} \ No newline at end of file diff --git a/onionr/static-data/www/chat/index.html b/onionr/static-data/www/chat/index.html index 35de8648..e2ee745d 100755 --- a/onionr/static-data/www/chat/index.html +++ b/onionr/static-data/www/chat/index.html @@ -81,6 +81,10 @@ +
+ Jenny +
I'll stay right here
+

@@ -91,10 +95,6 @@
-
- Jenny -
I'll stay right here
-

diff --git a/onionr/static-data/www/chat/js/messages.js b/onionr/static-data/www/chat/js/messages.js index 41329b7b..a5a7a596 100644 --- a/onionr/static-data/www/chat/js/messages.js +++ b/onionr/static-data/www/chat/js/messages.js @@ -16,16 +16,21 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -chatMessages = [] +chatMessages = {} let Message = class { constructor(text, peer, outgoing){ this.text = text // raw message string this.peer = peer // peer by public key this.outgoing = outgoing // boolean. false = outgoing message - this.time = new Date().toISOString() - //this.tempIdentifier = Math.floor(Math.random() * 100000000000000000); - chatMessages.push(this) + this.time = new Date().toISOString() // store message time + this.tempIdentifier = Math.floor(Math.random() * 100000000000000000) // assign a random id, doesnt need to be secure + + // Add the message to the peer message feed object chatMessages + if (chatMessages.hasOwnProperty(peer)){ + chatMessages[peer].push(this) + } + else{ + chatMessages[peer] = [this] + } } } - -//let addMessage = function(){} \ No newline at end of file