mirror of
https://github.com/koodo-reader/koodo-reader.git
synced 2026-06-16 11:50:41 -04:00
feat: Enhance delete icon functionality and sidebar styling
- Added logic to handle bookmark deletion in the DeleteIcon component, checking if the current bookmark matches the recorded location before deletion. - Updated the mapStateToProps in the DeleteIcon index file to include currentBook from the Redux store. - Modified DeleteIconProps interface to include currentBook of type BookModel. - Adjusted padding in the Sidebar component for better UI alignment. - Updated sidebar CSS to refine height calculation for improved layout.
This commit is contained in:
2
src/assets/lib/kookit.min.js
vendored
2
src/assets/lib/kookit.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -6,6 +6,7 @@ import toast from "react-hot-toast";
|
||||
import DatabaseService from "../../utils/storage/databaseService";
|
||||
import { ConfigService } from "../../assets/lib/kookit-extra-browser.min";
|
||||
import ConfigUtil from "../../utils/file/configUtil";
|
||||
import { book } from "../../store/reducers";
|
||||
|
||||
class DeleteIcon extends React.Component<DeleteIconProps, DeleteIconStates> {
|
||||
constructor(props: DeleteIconProps) {
|
||||
@@ -27,6 +28,28 @@ class DeleteIcon extends React.Component<DeleteIconProps, DeleteIconStates> {
|
||||
return;
|
||||
}
|
||||
if (this.props.mode === "bookmarks") {
|
||||
let bookLocation: {
|
||||
text: string;
|
||||
count: string;
|
||||
chapterTitle: string;
|
||||
chapterDocIndex: string;
|
||||
chapterHref: string;
|
||||
percentage: string;
|
||||
cfi: string;
|
||||
} = ConfigService.getObjectConfig(
|
||||
this.props.currentBook.key,
|
||||
"recordLocation",
|
||||
{}
|
||||
);
|
||||
let bookmark = await DatabaseService.getRecord(
|
||||
this.props.itemKey,
|
||||
"bookmarks"
|
||||
);
|
||||
if (!bookmark) return;
|
||||
console.log(bookmark, bookLocation);
|
||||
if (bookLocation.percentage === bookmark.percentage) {
|
||||
this.props.handleShowBookmark(false);
|
||||
}
|
||||
DatabaseService.deleteRecord(this.props.itemKey, "bookmarks").then(() => {
|
||||
deleteFunc();
|
||||
toast.success(this.props.t("Deletion successful"));
|
||||
|
||||
@@ -10,6 +10,7 @@ import { withTranslation } from "react-i18next";
|
||||
const mapStateToProps = (state: stateType) => {
|
||||
return {
|
||||
htmlBook: state.reader.htmlBook,
|
||||
currentBook: state.book.currentBook,
|
||||
};
|
||||
};
|
||||
const actionCreator = {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import BookModel from "../../models/Book";
|
||||
export interface DeleteIconProps {
|
||||
mode: string;
|
||||
index: number;
|
||||
tagName: string;
|
||||
itemKey: string;
|
||||
currentBook: BookModel;
|
||||
handleFetchNotes: () => void;
|
||||
handleFetchBookmarks: () => void;
|
||||
renderHighlighters: () => void;
|
||||
|
||||
@@ -437,7 +437,7 @@ class Sidebar extends React.Component<SidebarProps, SidebarState> {
|
||||
)}
|
||||
</div>
|
||||
{/* Stats button at the bottom */}
|
||||
<div className="side-menu-about" style={{ paddingBottom: 12 }}>
|
||||
<div className="side-menu-about" style={{ paddingBottom: 8 }}>
|
||||
<div
|
||||
className={"side-menu-selector"}
|
||||
style={{ cursor: "pointer" }}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
position: relative;
|
||||
top: 85px;
|
||||
width: 210px;
|
||||
height: calc(100% - 155px);
|
||||
height: calc(100% - 145px);
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user