work on chat

This commit is contained in:
Kevin Froman 2019-08-19 01:04:35 -05:00
parent 995d380b9f
commit d548723f90
3 changed files with 19 additions and 10 deletions

View File

@ -60,3 +60,7 @@
transform: rotate(180deg);
direction: ltr;
}
#messageEntryTemplate{
display: none;
}

View File

@ -81,6 +81,10 @@
</div>
</section>
<div class="messageEntry" id="messageEntryTemplate">
<span class="from has-text-primary">Jenny</span>
<div class="messageContent">I'll stay right here</div>
</div>
<br>
<div class="columns chatContent">
@ -91,10 +95,6 @@
</div>
<div class="column chatBox has-text-light has-background-dark is-four-fifths">
<span class="chatFeed">
<div class="messageEntry">
<span class="from has-text-primary">Jenny</span>
<div class="messageContent">I'll stay right here</div>
</div>
</span>
<div class="field has-addons">
<p class="control chatInput">

View File

@ -16,16 +16,21 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
*/
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
//let addMessage = function(){}
// Add the message to the peer message feed object chatMessages
if (chatMessages.hasOwnProperty(peer)){
chatMessages[peer].push(this)
}
else{
chatMessages[peer] = [this]
}
}
}