Fixed audio notification
This commit is contained in:
parent
a06e3f404a
commit
99fc9118b3
@ -26,6 +26,7 @@ dependencies = [
|
|||||||
"cryptography",
|
"cryptography",
|
||||||
"requests",
|
"requests",
|
||||||
"asyncssh",
|
"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 {
|
class RESTClient {
|
||||||
debug = false
|
debug = false
|
||||||
@ -379,6 +303,7 @@ class App extends EventHandler {
|
|||||||
ws = null
|
ws = null
|
||||||
rpc = null
|
rpc = null
|
||||||
audio = null
|
audio = null
|
||||||
|
user = {}
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
this.rooms.push(new Room("General"))
|
this.rooms.push(new Room("General"))
|
||||||
@ -389,6 +314,7 @@ class App extends EventHandler {
|
|||||||
this.ws.addEventListener("channel-message", (data) => {
|
this.ws.addEventListener("channel-message", (data) => {
|
||||||
me.emit(data.channel_uid, data)
|
me.emit(data.channel_uid, data)
|
||||||
})
|
})
|
||||||
|
this.user = await this.rpc.getUser(null)
|
||||||
}
|
}
|
||||||
playSound(index){
|
playSound(index){
|
||||||
this.audio.play(index)
|
this.audio.play(index)
|
||||||
|
@ -6,10 +6,12 @@ class ChatWindowElement extends HTMLElement {
|
|||||||
super();
|
super();
|
||||||
this.attachShadow({ mode: 'open' });
|
this.attachShadow({ mode: 'open' });
|
||||||
this.component = document.createElement('section');
|
this.component = document.createElement('section');
|
||||||
|
this.app = app
|
||||||
this.shadowRoot.appendChild(this.component);
|
this.shadowRoot.appendChild(this.component);
|
||||||
}
|
}
|
||||||
|
get user() {
|
||||||
|
return this.app.user
|
||||||
|
}
|
||||||
async connectedCallback() {
|
async connectedCallback() {
|
||||||
const link = document.createElement('link')
|
const link = document.createElement('link')
|
||||||
link.rel = 'stylesheet'
|
link.rel = 'stylesheet'
|
||||||
@ -61,7 +63,8 @@ class ChatWindowElement extends HTMLElement {
|
|||||||
})
|
})
|
||||||
const me = this
|
const me = this
|
||||||
channelElement.addEventListener("message",(message)=>{
|
channelElement.addEventListener("message",(message)=>{
|
||||||
app.playSound(0)
|
if(me.user.uid != message.detail.user_uid)
|
||||||
|
app.playSound(0)
|
||||||
message.detail.element.scrollIntoView()
|
message.detail.element.scrollIntoView()
|
||||||
|
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user