Skip to content

Commit

Permalink
Merge pull request #7 from YoussifHassan8/suggestion
Browse files Browse the repository at this point in the history
Suggestion
  • Loading branch information
Mohab96 authored Aug 9, 2024
2 parents 74b7a35 + c460914 commit 1aa016d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ async function get_problems() {

available_problems = shuffle(available_problems);

if (available_problems.length < problems_cnt) {
if (available_problems.length === 0) {
Swal.fire({
icon: "error",
title: "Oops...",
Expand All @@ -434,8 +434,17 @@ async function get_problems() {

return false;
}

let final_problems = available_problems.slice(0, problems_cnt);
let final_problems = available_problems.slice(
0,
Math.min(problems_cnt, available_problems.length)
);
if (available_problems.length < problems_cnt) {
Swal.fire({
icon: "warning",
title: "Limited Results",
text: `Only ${available_problems.length} problems are available, but you requested ${problems_cnt} problems. Please adjust your filters or check back later.`,
});
}

return final_problems;
}
Expand Down

0 comments on commit 1aa016d

Please sign in to comment.