Skip to content

Commit

Permalink
Merge pull request #14 from AlexSciFier/links-window-fixes
Browse files Browse the repository at this point in the history
Various fixes for links page
  • Loading branch information
AlexSciFier authored Nov 19, 2022
2 parents 43ed454 + df397dd commit f060de4
Show file tree
Hide file tree
Showing 14 changed files with 281 additions and 114 deletions.
190 changes: 105 additions & 85 deletions frontend/package-lock.json

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

9 changes: 8 additions & 1 deletion frontend/src/context/bookmarkList.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ export function BookMarkListProvider({ children }) {
abortController.current.abort();
}

async function fetchBookmarks({ offset = 0, limit = 25, query, tag }) {
async function fetchBookmarks({
offset = 0,
limit = 25,
query,
tag,
category,
}) {
setIsBookmarksLoading(true);
setErrorBookmarks(undefined);

Expand All @@ -30,6 +36,7 @@ export function BookMarkListProvider({ children }) {
searchParams.append("limit", limit);
if (query) searchParams.append("q", query);
if (tag) searchParams.append("tag", tag);
if (category) searchParams.append("category", category);
let res = await getJSON(
`/api/bookmarks/?${searchParams.toString()}`,
abortController.current.signal
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/helpers/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const APP_NAME = "NeonLink";
export const VERSION = "1.2.2";
export const VERSION = "1.2.3";
export const DEF_MAX_ITEMS = 20;
export const DEF_COLUMNS = 3;
export const CARD_HEADER_STYLE = [
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/pages/link/components/BookmarksHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useBookMarkList } from "../../../context/bookmarkList";
import { DEF_MAX_ITEMS } from "../../../helpers/constants";
import { useLocalStorage } from "../../../hooks/useLocalStorage";
import { useRef } from "react";
import { useSearchParams } from "react-router-dom";

export default function BookmarksHeader() {
const [query, setQuery] = useState("");
Expand All @@ -13,6 +14,7 @@ export default function BookmarksHeader() {

const { fetchBookmarks } = useBookMarkList();
const [maxItemsInList] = useLocalStorage("maxItemsInList", DEF_MAX_ITEMS);
const [searchParams] = useSearchParams();

const firstUpdate = useRef(true);
useEffect(() => {
Expand All @@ -25,7 +27,10 @@ export default function BookmarksHeader() {
}, [delayedQuery, query]);

function updateBookmarkList() {
fetchBookmarks({ offset: 0, limit: maxItemsInList, query });
let tag = searchParams.get("tag");
let category = searchParams.get("category");

fetchBookmarks({ offset: 0, limit: maxItemsInList, query, tag, category });
}

return (
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/pages/link/components/BookmarksList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ export default function BookmarksList() {
let offset = (page - 1) * limit;

let tag = searchParams.get("tag");
if (tag) {
fetchBookmarks({ offset, limit, tag });
let category = searchParams.get("category")

if (tag || category) {
fetchBookmarks({ offset, limit, tag, category });
return;
}
fetchBookmarks({ offset, limit });
Expand Down
Loading

0 comments on commit f060de4

Please sign in to comment.