forked from noxious/client
Notifications bug fix
This commit is contained in:
parent
01bbd94a3e
commit
356cb94cc2
@ -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
|
||||
})
|
||||
})
|
||||
|
@ -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 }
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user