notice: reworked frontend (bs toasts)

This commit is contained in:
AdrienLSH
2024-03-22 09:24:46 +01:00
parent 382e80c688
commit a0450cf406
3 changed files with 40 additions and 44 deletions

View File

@ -1,5 +1,5 @@
import { navigateTo } from "../../index.js";
import {create_popup} from "../../utils/noticeUtils.js";
import {createNotification} from "../../utils/noticeUtils.js";
class Notice {
constructor(client) {
@ -85,7 +85,7 @@ class Notice {
}
else {
let sender = await this.client.profiles.getProfileId(send.author_id);
create_popup(sender.username + " refuse your invitation");
createNotification(sender.username + " refuse your invitation");
}
}
@ -111,12 +111,12 @@ class Notice {
if (send.author_id == this.client.me.id) {
if (send.status == 200) {
for (let target in send.targets)
return create_popup("Invitation send");
return createNotification("Invitation send");
}
else if (send.status == 444)
return create_popup("User not connected");
return createNotification("User not connected");
else if (send.status == 409)
return create_popup("Already invited");
return createNotification("Already invited");
}
else {
@ -129,7 +129,7 @@ class Notice {
this.data.invited = content;
let sender = await this.client.profiles.getProfileId(send.author_id);
create_popup("Invitation received by " + sender.username);
createNotification("Invitation received by " + sender.username);
if (this.rewrite_invite !== undefined)
this.rewrite_invite();
@ -189,9 +189,9 @@ class Notice {
let my_id = (this.client.me && this.client.me.id) || send.author_id;
if (send.author_id == my_id) {
if (send.status == 400)
create_popup("Friend ask error");
createNotification("Friend ask error");
else if (send.status == 409)
create_popup("Already asked friend");
createNotification("Already asked friend");
}
//if (!send.asked.includes(send.author_id) ||
@ -208,7 +208,7 @@ class Notice {
if (send.author_id != my_id) {
let sender = await this.client.profiles.getProfileId(send.author_id);
if (this.data.asker.includes(send.author_id))
create_popup(sender.username + " ask you as friend");
createNotification(sender.username + " ask you as friend");
if (this.rewrite_profile !== undefined)
await this.rewrite_profile();
}
@ -227,9 +227,9 @@ class Notice {
if (send.author_id == this.client.me.id) {
if (send.status == 400)
create_popup("Error remove Friend");
createNotification("Error remove Friend");
else if (send.status == 409)
create_popup("Not friend, wtf");
createNotification("Not friend, wtf");
}
@ -254,14 +254,14 @@ class Notice {
if (send.author_id == this.client.me.id) {
if (send.status == 400)
create_popup("Error accept Friend");
createNotification("Error accept Friend");
else if (send.status == 404)
create_popup("Not found request Friend");
createNotification("Not found request Friend");
else if (send.status == 409)
create_popup("Already Friend, wtf");
createNotification("Already Friend, wtf");
}
else {
create_popup(sender.username + " accept your friend request");
createNotification(sender.username + " accept your friend request");
}
if (this.rewrite_profile !== undefined)
@ -285,11 +285,11 @@ class Notice {
if (send.author_id == this.client.me.id) {
if (send.status == 400)
create_popup("Error refuse Friend");
createNotification("Error refuse Friend");
else if (send.status == 404)
create_popup("Not found request Friend");
createNotification("Not found request Friend");
else if (send.status == 409)
create_popup("Already Friend, WTF");
createNotification("Already Friend, WTF");
}
if (this.rewrite_profile !== undefined)