Enhance security and offline functionality
- Implement stricter security measures in the Electron app, including navigation blocking, URL validation, and external request handling. - Add offline mode handling and UI improvements in components like `ScribeFooterBar` and `AddNewBookForm`. - Refactor `DeleteBook` logic to include offline sync methods. - Improve user feedback for online/offline states and synchronization errors.
This commit is contained in:
@@ -162,6 +162,7 @@ export default function AddNewBookForm({setCloseForm}: { setCloseForm: Dispatch<
|
||||
bookId: bookId,
|
||||
...bookData
|
||||
};
|
||||
console.log(isCurrentlyOffline())
|
||||
if (isCurrentlyOffline()){
|
||||
setLocalOnlyBooks((prevBooks: SyncedBook[]): SyncedBook[] => [...prevBooks, {
|
||||
id: book.bookId,
|
||||
|
||||
@@ -99,6 +99,7 @@ export default function BookList() {
|
||||
session.isConnected,
|
||||
accessToken,
|
||||
offlineMode.isDatabaseInitialized,
|
||||
offlineMode.isOffline,
|
||||
booksToSyncFromServer,
|
||||
booksToSyncToServer,
|
||||
serverOnlyBooks,
|
||||
@@ -350,9 +351,8 @@ export default function BookList() {
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-full">
|
||||
<div className="text-center p-8 max-w-lg">
|
||||
<div
|
||||
className="w-24 h-24 bg-primary/20 text-primary rounded-2xl flex items-center justify-center mx-auto mb-6 shadow-lg animate-pulse">
|
||||
<FontAwesomeIcon icon={faBook} className={'w-12 h-12'}/>
|
||||
<div className="w-24 h-24 bg-primary/20 text-primary rounded-2xl flex items-center justify-center mx-auto mb-6 shadow-lg">
|
||||
<FontAwesomeIcon icon={faBook} size={'3x'}/>
|
||||
</div>
|
||||
<h2 className="text-4xl font-['ADLaM_Display'] mb-4 text-text-primary">{t("bookList.welcomeWritingWorkshop")}</h2>
|
||||
<p className="text-muted mb-6 text-lg leading-relaxed">
|
||||
|
||||
@@ -3,7 +3,6 @@ import {faTrash} from "@fortawesome/free-solid-svg-icons";
|
||||
import {useContext, useState} from "react";
|
||||
import System from "@/lib/models/System";
|
||||
import {SessionContext} from "@/context/SessionContext";
|
||||
import {BookProps} from "@/lib/models/Book";
|
||||
import {LangContext, LangContextProps} from "@/context/LangContext";
|
||||
import {AlertContext, AlertContextProps} from "@/context/AlertContext";
|
||||
import AlertBox from "@/components/AlertBox";
|
||||
@@ -43,6 +42,9 @@ export default function DeleteBook({bookId}: DeleteBookProps) {
|
||||
id: bookId,
|
||||
});
|
||||
} else {
|
||||
response = await window.electron.invoke<boolean>('db:book:delete', {
|
||||
id: bookId,
|
||||
});
|
||||
response = await System.authDeleteToServer<boolean>(
|
||||
`book/delete`,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user