Skip to content

Commit

Permalink
Merge pull request #28 from bibliomar/beta
Browse files Browse the repository at this point in the history
Merging latest beta features
  • Loading branch information
Lamarcke authored Mar 14, 2023
2 parents 0517740 + 3b8e489 commit 6e68b07
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 64 deletions.
11 changes: 7 additions & 4 deletions src/components/general/figure/MetadataSelectableFigure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ export default function MetadataSelectableFigure({
threshold: 1000,
detect: LongPressDetectEvents.BOTH,
filterEvents: (event) => {
if (!selectable) {
return false;
} else {
if (selectable) {
return true;
} else {
return false;
}
},
cancelOnMovement: true,
}
);
const { t } = useTranslation();
Expand All @@ -77,7 +78,8 @@ export default function MetadataSelectableFigure({
setOnSelectedBooks(false);
}
};

/** Disabled because EditMode now automatically cleans up the selected books on exit.
* This useEffect detects if a book is already in the selectedBooks list when the editMode is enabled.
useEffect(() => {
if (
!editModeContext.editMode ||
Expand All @@ -102,6 +104,7 @@ export default function MetadataSelectableFigure({
return;
}
}, [editModeContext.editMode]);
*/

const formatAndSize = `${
metadata.extension
Expand Down
4 changes: 4 additions & 0 deletions src/components/general/helpers/useCover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export default function useCover(

setCover(cover);

if (cover === noCoverUrl) {
return;
}

coverTimeout = window.setTimeout(
async () => {
setCoverDone(true);
Expand Down
50 changes: 30 additions & 20 deletions src/components/library/LibraryNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {
UserLibraryContext,
} from "./helpers/libraryFunctions";
import LibraryStatisticsToggle from "./statistics/LibraryStatisticsToggle";
import Break from "../general/Break";

// This component should have an edit button someday.
export default function () {
const userLibraryContext = useContext(UserLibraryContext);
const editModeContext = useContext(EditModeContext);
const editModeActive = editModeContext && editModeContext.editMode;
const numOfBooks = calculateNumOfBooks(userLibraryContext.userLibrary);
const { t } = useTranslation();
return (
Expand Down Expand Up @@ -45,31 +47,39 @@ export default function () {
)}
</div>
</div>
<div className="d-flex flex-wrap mb-2 w-75 align-items-center">
{editModeContext && editModeContext.editMode ? (
<>
<div className="ms-auto">
<div className="d-flex flex-wrap mb-2 w-75 justify-content-end align-items-center">
<div
id="library-navbar-toggle-buttons"
className="d-flex ms-3 me-2"
>
<div className={""}>
<EditModeToggle />
</div>

<div className={"ms-2 me-0"}>
<LibraryFilterToggle />
</div>

<div className={"ms-2"}>
<LibraryStatisticsToggle />
</div>
</div>

<Break />

{editModeActive ? (
<div
id="library-navbar-action-buttons"
className="d-flex ms-3 me-2 mt-2"
>
<div className="">
<EditModeMove />
</div>
<div className={"ms-3"}>
<div className={"ms-2"}>
<EditModeRemove />
</div>
</>
</div>
) : null}

<div
className={
!editModeContext.editMode ? "ms-auto" : "ms-3"
}
>
<EditModeToggle />
</div>
<div className={"ms-2 me-0"}>
<LibraryFilterToggle />
</div>
<div className={"ms-2 me-2"}>
<LibraryStatisticsToggle />
</div>
</div>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/library/helpers/libraryContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { defaultFilters } from "./libraryFunctions";

const EditModeContext = createContext<EditModeContextParams>({
editMode: false,
// eslint-disable-next-line @typescript-eslint/no-empty-function
setEditMode: () => {},
selectedBooksRef: { current: [] },
});

const Filters = createContext<FiltersContextParams>({
filters: defaultFilters,
// eslint-disable-next-line @typescript-eslint/no-empty-function
setFilters: () => {},
});

Expand Down
4 changes: 4 additions & 0 deletions src/components/metadatainfo/info/MetadataInfoLibraryAdd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export default function MetadataInfoLibraryAdd({
</span>
);
}
if (requestError.request.status === 401) {
setRequestStatus(401);
return;
}
}

return (
Expand Down
76 changes: 37 additions & 39 deletions src/components/reader/ReaderLanding.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Navbar from "../general/navbar/Navbar";
import { useContext, useEffect, useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import { MDBBtn } from "mdb-react-ui-kit";
import { MDBBtn, MDBCol, MDBRow } from "mdb-react-ui-kit";
import { Portal } from "react-portal";
import ReaderSendLocalFileModal from "./ReaderSendLocalFileModal";
import localforage from "localforage";
Expand Down Expand Up @@ -31,45 +31,43 @@ export default function ReaderLanding() {
};

return (
<div className="like-body bg-alt">
<div className="container">
<Portal node={document.getElementById("modal-root")}>
<ReaderSendLocalFileModal
modalToggle={sendModal}
setModalToggle={setSendModal}
/>
<ReaderDeleteCacheModal
show={deleteModal}
setShow={setDeleteModal}
onClick={toggleDelete}
agreedOnClick={handleDeleteCache}
/>
</Portal>
<Navbar activeItem="reader" />
<div className="d-flex justify-content-end mt-4 mb-5 me-2">
<MDBBtn
className="me-3"
type="button"
color="danger"
onClick={toggleDelete}
>
{t("reader:limparCacheDoLeitor")}
</MDBBtn>

<MDBBtn
type="button"
color="secondary"
onClick={toggleSend}
>
{t("reader:enviarArquivo")}
</MDBBtn>
</div>
<div
className="d-flex flex-wrap justify-content-center w-100"
style={{ minHeight: "30vh" }}
<div className="container-fluid min-vh-100 d-flex flex-column">
<Portal node={document.getElementById("modal-root")}>
<ReaderSendLocalFileModal
modalToggle={sendModal}
setModalToggle={setSendModal}
/>
<ReaderDeleteCacheModal
show={deleteModal}
setShow={setDeleteModal}
onClick={toggleDelete}
agreedOnClick={handleDeleteCache}
/>
</Portal>
<MDBRow>
<MDBCol>
<Navbar activeItem="reader" />
</MDBCol>
</MDBRow>
<div className="d-flex justify-content-end mt-4 mb-5 me-2">
<MDBBtn
className="me-3"
type="button"
color="danger"
onClick={toggleDelete}
>
<ReaderGreeting />
</div>
{t("reader:limparCacheDoLeitor")}
</MDBBtn>

<MDBBtn type="button" color="secondary" onClick={toggleSend}>
{t("reader:enviarArquivo")}
</MDBBtn>
</div>
<div
className="d-flex flex-wrap justify-content-center w-100"
style={{ minHeight: "30vh" }}
>
<ReaderGreeting />
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ function Search() {
</Helmet>
<div className="row ">
<div className="col mt-3">
<Navbar activeItem="home" badgeText="3.1-MAIN" />
<Navbar activeItem="home" />
</div>
</div>

Expand Down

0 comments on commit 6e68b07

Please sign in to comment.