Friends: Match behavior with online friend requests when only one request is pending

This commit is contained in:
Mia 2021-07-16 22:22:14 -05:00
parent 3316bf3ffb
commit 34f9e33116
2 changed files with 16 additions and 3 deletions

View File

@ -27,8 +27,21 @@ export const Friends = new class {
const friendRequests = await Chat.Friends.getRequests(user);
const pendingCount = friendRequests.received.size;
if (pendingCount < 1) return;
sendPM(`/nonotify You have ${pendingCount} friend requests pending!`, user.id);
sendPM(`/raw <button class="button" name="send" value="/j view-friends-received">View</button></div>`, user.id);
if (pendingCount === 1) {
let buf = Utils.html`/uhtml sent,<button class="button" name="send" value="/friends accept ${user.id}">Accept</button> | `;
buf += Utils.html`<button class="button" name="send" value="/friends reject ${user.id}">Deny</button><br /> `;
buf += `<small>(You can also stop this user from sending you friend requests with <code>/ignore</code>)</small>`;
sendPM(Utils.html`/html <span class="username">${user.name}</span> sent you a friend request!`, user.id);
sendPM(buf, user.id);
sendPM(
`/raw <small>Note: If this request is accepted, your friend will be notified when you come online, ` +
`and you will be notified when they do, unless you opt out of receiving them.</small>`,
user.id
);
} else {
sendPM(`/nonotify You have ${pendingCount} friend requests pending!`, user.id);
sendPM(`/raw <button class="button" name="send" value="/j view-friends-received">View</button></div>`, user.id);
}
}
async notifyConnection(user: User) {
const connected = await Chat.Friends.getLastLogin(user.id);

View File

@ -182,7 +182,7 @@ export class FriendsDatabase {
const result = await this.transaction('send', [user.id, receiverID]);
if (receiver) {
sendPM(`/text ${Utils.escapeHTML(user.name)} sent you a friend request!`, receiver.id);
sendPM(`/html <span class="username">${user.name}</span> sent you a friend request!`, receiver.id);
sendPM(buf, receiver.id);
sendPM(disclaimer, receiver.id);
}