check user is known on addFriend modal

This commit is contained in:
Christian Fehmer 2025-09-11 13:53:16 +02:00 committed by Christian Fehmer
parent 5dd4e57bd1
commit d08db79036

View file

@ -65,7 +65,27 @@ export async function addFriend(friendName: string): Promise<true | string> {
const addFriendModal = new SimpleModal({
id: "addFriend",
title: "Add a friend",
inputs: [{ placeholder: "user name", type: "text", initVal: "" }],
inputs: [
{
placeholder: "user name",
type: "text",
initVal: "",
validation: {
isValid: async (name: string) => {
const checkNameResponse = await Ape.users.getNameAvailability({
params: { name: name },
});
return (
(checkNameResponse.status === 200 &&
!checkNameResponse.body.data.available) ||
"Unknown user"
);
},
debounceDelay: 1000,
},
},
],
buttonText: "request",
onlineOnly: true,
execFn: async (_thisPopup, friendName) => {