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); transform: rotate(180deg);
direction: ltr; direction: ltr;
} }
#messageEntryTemplate{
display: none;
}

View File

@ -81,6 +81,10 @@
</div> </div>
</section> </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> <br>
<div class="columns chatContent"> <div class="columns chatContent">
@ -91,10 +95,6 @@
</div> </div>
<div class="column chatBox has-text-light has-background-dark is-four-fifths"> <div class="column chatBox has-text-light has-background-dark is-four-fifths">
<span class="chatFeed"> <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> </span>
<div class="field has-addons"> <div class="field has-addons">
<p class="control chatInput"> <p class="control chatInput">

View File

@ -16,16 +16,21 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/> along with this program. If not, see <https://www.gnu.org/licenses/>
*/ */
chatMessages = [] chatMessages = {}
let Message = class { let Message = class {
constructor(text, peer, outgoing){ constructor(text, peer, outgoing){
this.text = text // raw message string this.text = text // raw message string
this.peer = peer // peer by public key this.peer = peer // peer by public key
this.outgoing = outgoing // boolean. false = outgoing message this.outgoing = outgoing // boolean. false = outgoing message
this.time = new Date().toISOString() this.time = new Date().toISOString() // store message time
//this.tempIdentifier = Math.floor(Math.random() * 100000000000000000); this.tempIdentifier = Math.floor(Math.random() * 100000000000000000) // assign a random id, doesnt need to be secure
chatMessages.push(this)
// 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(){}