Skip to content

Commit

Permalink
if have only one option immediately save
Browse files Browse the repository at this point in the history
  • Loading branch information
itamarshubin committed Mar 18, 2024
1 parent 918edf0 commit 4689fa1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/constants/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,29 @@ export const createAlertSubscription = async (msg: Message) => {
"לא נמצא משתמש עם שם כזה, הזן שם אחר או 'בטל' כדי להפסיק את הפעולה"
);
}
let response = "";

if (matches.length === 1) {
const userRef = await getUserRef(msg);

const userToAdd = matches[0];
if (!userToAdd) {
return client.sendMessage(
msg.from,
"הזן מספר תקין או כתוב 'בטל' בשביל להפסיק את הפעולה"
);
}
await updateDoc(userToAdd.ref, {
subscribedUsers: arrayUnion(userRef.ref),
});
await updateDoc(userRef.ref, { subscribedTo: arrayUnion(userToAdd.ref) });
client.sendMessage(
msg.from,
`תקבל הודעה כש${userToAdd.data().name} יעדכן על מצב ההגעה שלו`
);
delete sessionedAddSubscribersAlert[msg.from];
}

let response = "נמצאו מספר תוצאות. \n";
matches.forEach((match, index) => {
response += String(
index +
Expand Down

0 comments on commit 4689fa1

Please sign in to comment.