Removed pyc files.
This commit is contained in:
parent
d93d48ef7e
commit
da72a15068
@ -49,10 +49,8 @@ class ChatWindowElement extends HTMLElement {
|
||||
})
|
||||
const me = this
|
||||
channelElement.addEventListener("message",(message)=>{
|
||||
console.info("ROCKSTARTSS")
|
||||
setTimeout(()=>{
|
||||
message.detail.element.scrollIntoView({behavior: 'smooth'})
|
||||
},10)
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ class MessageListElement extends HTMLElement {
|
||||
room = null
|
||||
url = null
|
||||
container = null
|
||||
messageEventSchedule = null
|
||||
constructor() {
|
||||
super()
|
||||
this.attachShadow({ mode: 'open' });
|
||||
@ -40,6 +41,7 @@ class MessageListElement extends HTMLElement {
|
||||
element.appendChild(avatar)
|
||||
element.appendChild(messageContent)
|
||||
|
||||
|
||||
|
||||
|
||||
message.element = element
|
||||
@ -61,8 +63,12 @@ class MessageListElement extends HTMLElement {
|
||||
this.messages.push(obj)
|
||||
this.container.appendChild(element)
|
||||
const me = this
|
||||
this.dispatchEvent(new CustomEvent("message", {detail:obj,bubbles:true}))
|
||||
|
||||
this.messageEventSchedule.delay(() => {
|
||||
me.dispatchEvent(new CustomEvent("message", {detail:obj,bubbles:true}))
|
||||
})
|
||||
|
||||
|
||||
return obj
|
||||
}
|
||||
scrollBottom(){
|
||||
@ -77,7 +83,7 @@ class MessageListElement extends HTMLElement {
|
||||
this.container = document.createElement('div')
|
||||
//this.container.classList.add("chat-messages")
|
||||
this.component.appendChild(this.container)
|
||||
|
||||
this.messageEventSchedule = new Schedule(500)
|
||||
this.messages = []
|
||||
this.channel_uid = this.getAttribute("channel")
|
||||
const me = this
|
||||
|
45
src/snek/static/schedule.js
Normal file
45
src/snek/static/schedule.js
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
|
||||
class Schedule {
|
||||
|
||||
constructor(msDelay) {
|
||||
if(!msDelay){
|
||||
msDelay = 100
|
||||
}
|
||||
this.msDelay = msDelay
|
||||
this._once = false
|
||||
this.timeOutCount = 0;
|
||||
this.timeOut = null
|
||||
this.interval = null
|
||||
}
|
||||
cancelRepeat() {
|
||||
clearInterval(this.interval)
|
||||
this.interval = null
|
||||
}
|
||||
cancelDelay() {
|
||||
clearTimeout(this.interval)
|
||||
this.interval = null
|
||||
}
|
||||
repeat(func){
|
||||
if(this.interval){
|
||||
return false
|
||||
}
|
||||
this.interval = setInterval(()=>{
|
||||
func()
|
||||
}, this.msDelay)
|
||||
}
|
||||
delay(func) {
|
||||
this.timeOutCount++
|
||||
if(this.timeOut){
|
||||
this.cancelDelay()
|
||||
}
|
||||
const me = this
|
||||
this.timeOut = setTimeout(()=>{
|
||||
clearTimeout(me.timeOut)
|
||||
me.timeOut = null
|
||||
me.cancelDelay()
|
||||
me.timeOutCount = 0
|
||||
}, this.msDelay)
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Snek</title>
|
||||
<script src="/schedule.js"></script>
|
||||
<script src="/app.js"></script>
|
||||
<script src="/models.js"></script>
|
||||
<script src="/message-list.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user