Added docks.

This commit is contained in:
retoor 2025-01-29 17:08:40 +01:00
parent 9e89e27c66
commit af399e3b72
3 changed files with 29 additions and 10 deletions

View File

@ -345,13 +345,18 @@ class Socket extends EventHandler {
}
class App extends EventHandler {
rooms = []
rest = rest
ws = null
rpc = null
class NotificationAudio {
constructor(timeout){
if(!timeout)
timeout = 500
this.schedule = new Schedule(timeout)
}
sounds = ["/audio/soundfx.d_beep3.mp3"]
playSound(soundIndex) {
play(soundIndex) {
this.schedule.delay(() => {
if (!soundIndex)
soundIndex = 0
@ -364,17 +369,30 @@ class App extends EventHandler {
.catch((error) => {
console.error("Notification failed:", error);
});
})
}
}
class App extends EventHandler {
rooms = []
rest = rest
ws = null
rpc = null
audio = null
constructor() {
super()
this.rooms.push(new Room("General"))
this.ws = new Socket()
this.rpc = this.ws.client
const me = this
this.audio = new NotificationAudio(500)
this.ws.addEventListener("channel-message", (data) => {
me.emit(data.channel_uid, data)
})
}
playSound(index){
this.audio.play(index)
}
async benchMark(times, message) {
if (!times)
times = 100

View File

@ -55,7 +55,7 @@ class MessageListElement extends HTMLElement {
const text = document.createElement("div")
text.classList.add("text")
if(message.html)
text.innerHTML = this.linkifyText(message.html)
text.innerHTML = message.html
const time = document.createElement("div")
time.classList.add("time")
time.textContent = message.created_at

View File

@ -17,8 +17,8 @@ class Schedule {
this.interval = null
}
cancelDelay() {
clearTimeout(this.interval)
this.interval = null
clearTimeout(this.timeOut)
this.timeOut = null
}
repeat(func){
if(this.interval){
@ -35,9 +35,10 @@ class Schedule {
}
const me = this
this.timeOut = setTimeout(()=>{
func(me.timeOutCount)
clearTimeout(me.timeOut)
me.timeOut = null
func(me.timeOutCount)
me.cancelDelay()
me.timeOutCount = 0
}, this.msDelay)