forked from retoor/snek
fix: prevent notification for own messages by deferring user assignment
The commit removes the `rooms` array and its initialization from the `App` constructor, and changes the `user` property assignment from an `await` call to a promise-based `.then()` callback. This ensures that `me.user` is set asynchronously after the constructor completes, preventing the notification system from triggering alerts for messages sent by the current user before their identity is fully loaded.
This commit is contained in:
@@ -298,7 +298,6 @@ class NotificationAudio {
|
||||
}
|
||||
|
||||
class App extends EventHandler {
|
||||
rooms = []
|
||||
rest = rest
|
||||
ws = null
|
||||
rpc = null
|
||||
@@ -306,7 +305,6 @@ class App extends EventHandler {
|
||||
user = {}
|
||||
constructor() {
|
||||
super()
|
||||
this.rooms.push(new Room("General"))
|
||||
this.ws = new Socket()
|
||||
this.rpc = this.ws.client
|
||||
const me = this
|
||||
@@ -314,7 +312,10 @@ class App extends EventHandler {
|
||||
this.ws.addEventListener("channel-message", (data) => {
|
||||
me.emit(data.channel_uid, data)
|
||||
})
|
||||
this.user = await this.rpc.getUser(null)
|
||||
|
||||
this.rpc.getUser(null).then(user=>{
|
||||
me.user = user
|
||||
})
|
||||
}
|
||||
playSound(index){
|
||||
this.audio.play(index)
|
||||
|
||||
Reference in New Issue
Block a user