1
0
forked from noxious/client

Notifications bug fix

This commit is contained in:
Dennis Postma 2024-06-06 19:17:02 +02:00
parent 01bbd94a3e
commit 356cb94cc2
3 changed files with 10 additions and 10 deletions

View File

@ -24,7 +24,6 @@ function closeNotification(id: string) {
function setupNotificationListener(connection: any) {
connection.on('notification', (data: { message: string }) => {
notifications.addNotification({
id: Math.random().toString(16),
message: data.message
})
})

View File

@ -15,14 +15,12 @@ export async function register(username: string, password: string, socketStore =
}
export async function login(username: string, password: string, socketStore = useSocketStore()) {
const response = await axios.post(`${config.server_endpoint}/login`, { username, password })
console.log(response.status, response.data);
if (response.status !== 200) {
return { error: response.data.message }
try {
const response = await axios.post(`${config.server_endpoint}/login`, { username, password })
useCookies().set('token', response.data.token as string)
await socketStore.setupSocketConnection()
return { success: true }
} catch (error: any) {
return { error: error.response.data.message }
}
useCookies().set('token', response.data.token as string)
await socketStore.setupSocketConnection()
return { success: true }
}

View File

@ -10,6 +10,9 @@ export const useNotificationStore: StoreDefinition = defineStore('notifications'
},
actions: {
addNotification(notification: Notification) {
if (!notification.id) {
notification.id = Math.random().toString(16)
}
this.notifications.push(notification)
},
removeNotification(id: string) {