Fixed audio notification
This commit is contained in:
parent
a06e3f404a
commit
99fc9118b3
@ -26,6 +26,7 @@ dependencies = [
|
||||
"cryptography",
|
||||
"requests",
|
||||
"asyncssh",
|
||||
"emoji"
|
||||
"emoji",
|
||||
"pywebpush"
|
||||
]
|
||||
|
||||
|
@ -1,81 +1,5 @@
|
||||
|
||||
|
||||
/*class Message {
|
||||
uid = null
|
||||
author = null
|
||||
avatar = null
|
||||
text = null
|
||||
time = null
|
||||
constructor(uid,avatar,author,text,time){
|
||||
this.uid = uid
|
||||
this.avatar = avatar
|
||||
this.author = author
|
||||
this.text = text
|
||||
this.time = time
|
||||
}
|
||||
|
||||
get links() {
|
||||
if(!this.text)
|
||||
return []
|
||||
let result = []
|
||||
for(let part in this.text.split(/[,; ]/)){
|
||||
if(part.startsWith("http") || part.startsWith("www.") || part.indexOf(".com") || part.indexOf(".net") || part.indexOf(".io") || part.indexOf(".nl")){
|
||||
result.push(part)
|
||||
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
get mentions() {
|
||||
if(!this.text)
|
||||
return []
|
||||
let result = []
|
||||
for(let part in this.text.split(/[,; ]/)){
|
||||
if(part.startsWith("@")){
|
||||
result.push(part)
|
||||
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
class Messages {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class Room {
|
||||
name = null
|
||||
messages = []
|
||||
constructor(name) {
|
||||
this.name = name
|
||||
}
|
||||
setMessages(list) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class InlineAppElement extends HTMLElement {
|
||||
|
||||
constructor() {
|
||||
// this.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Page {
|
||||
elements = []
|
||||
|
||||
}
|
||||
|
||||
class RESTClient {
|
||||
debug = false
|
||||
@ -379,6 +303,7 @@ class App extends EventHandler {
|
||||
ws = null
|
||||
rpc = null
|
||||
audio = null
|
||||
user = {}
|
||||
constructor() {
|
||||
super()
|
||||
this.rooms.push(new Room("General"))
|
||||
@ -389,6 +314,7 @@ class App extends EventHandler {
|
||||
this.ws.addEventListener("channel-message", (data) => {
|
||||
me.emit(data.channel_uid, data)
|
||||
})
|
||||
this.user = await this.rpc.getUser(null)
|
||||
}
|
||||
playSound(index){
|
||||
this.audio.play(index)
|
||||
|
@ -6,10 +6,12 @@ class ChatWindowElement extends HTMLElement {
|
||||
super();
|
||||
this.attachShadow({ mode: 'open' });
|
||||
this.component = document.createElement('section');
|
||||
|
||||
this.app = app
|
||||
this.shadowRoot.appendChild(this.component);
|
||||
}
|
||||
|
||||
get user() {
|
||||
return this.app.user
|
||||
}
|
||||
async connectedCallback() {
|
||||
const link = document.createElement('link')
|
||||
link.rel = 'stylesheet'
|
||||
@ -61,6 +63,7 @@ class ChatWindowElement extends HTMLElement {
|
||||
})
|
||||
const me = this
|
||||
channelElement.addEventListener("message",(message)=>{
|
||||
if(me.user.uid != message.detail.user_uid)
|
||||
app.playSound(0)
|
||||
message.detail.element.scrollIntoView()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user