Skip to content

Commit

Permalink
Merge pull request #114 from AlexSciFier/1.4.18
Browse files Browse the repository at this point in the history
1.4.18
  • Loading branch information
AlexSciFier authored Dec 4, 2024
2 parents c6ddac1 + c8bce6e commit 2cdbadb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neonlink-frontend",
"version": "1.4.17",
"version": "1.4.18",
"private": true,
"type": "module",
"dependencies": {
Expand Down
16 changes: 5 additions & 11 deletions frontend/src/pages/addBookmark/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export default function AddPage() {
const [url, setUrl] = useState("");
const [complete, setComplete] = useState(false);
const [error, setError] = useState();
const [urlError, setUrlError] = useState();

const urlRef = useRef(null);

Expand Down Expand Up @@ -91,8 +90,8 @@ export default function AddPage() {
};

async function fetchUrl() {
setUrlError(undefined);
if (url === "") return;
if (!url.startsWith("http")) return;

setIsLoading(true);
let res;
Expand All @@ -108,10 +107,9 @@ export default function AddPage() {
setFormData({ ...formData, ...(await res.json()), tags: formData.tags });
setIsLoading(false);
} else {
console.error("error", res.statusText, res.status);
let body = await res.json();
let reason = body.message;
notify("Error", reason, "error");
console.error(reason);
setIsLoading(false);
}
}
Expand Down Expand Up @@ -148,14 +146,12 @@ export default function AddPage() {
try {
new URL(url);
} catch (error) {
setUrl("https://" + url);
if (url !== "" && !url.startsWith("http")) setUrl("https://" + url);
}
};

function isButtonDisabled() {
return error || urlError || sending || isLoading || url === ""
? true
: false;
return error || sending || isLoading || url === "" ? true : false;
}

if (complete) {
Expand Down Expand Up @@ -226,9 +222,7 @@ export default function AddPage() {
))}
</select>
<div className="flex justify-between">
<div className="text-red-600">
{error?.message || urlError || ""}
</div>
<div className="text-red-600">{error?.message || ""}</div>
<button
className={BUTTON_BASE_CLASS + "flex gap-2 items-center"}
type="submit"
Expand Down

0 comments on commit 2cdbadb

Please sign in to comment.