Refactor ScribeFooterBar and page.tsx
- Rename `serverOnlyBooks` to `serverSyncedBooks` for clarity. - Remove unused `SessionContext` import in `ScribeFooterBar`. - Add `shouldRerenderOnTransaction` flag to editor configuration in `page.tsx`. - Clean up redundant `useEffect` hooks and console logs in `ScribeFooterBar`.
This commit is contained in:
@@ -56,6 +56,7 @@ function ScribeContent() {
|
||||
],
|
||||
injectCSS: false,
|
||||
immediatelyRender: false,
|
||||
shouldRerenderOnTransaction: true,
|
||||
});
|
||||
|
||||
const [session, setSession] = useState<SessionProps>({user: null, accessToken: '', isConnected: false});
|
||||
|
||||
@@ -4,7 +4,6 @@ import {useContext, useEffect, useState} from "react";
|
||||
import {Editor} from "@tiptap/react";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {faBook, faChartSimple, faHeart, faSheetPlastic, faHardDrive} from "@fortawesome/free-solid-svg-icons";
|
||||
import {SessionContext} from "@/context/SessionContext";
|
||||
import {useTranslations} from "next-intl";
|
||||
import {AlertContext} from "@/context/AlertContext";
|
||||
import {BookContext} from "@/context/BookContext";
|
||||
@@ -18,7 +17,7 @@ export default function ScribeFooterBar() {
|
||||
const editor: Editor | null = useContext(EditorContext).editor;
|
||||
const {errorMessage} = useContext(AlertContext)
|
||||
const {offlineMode} = useContext<OfflineContextType>(OfflineContext)
|
||||
const {serverOnlyBooks,localOnlyBooks} = useContext<BooksSyncContextProps>(BooksSyncContext);
|
||||
const {localOnlyBooks,serverSyncedBooks} = useContext<BooksSyncContextProps>(BooksSyncContext);
|
||||
|
||||
const [wordsCount, setWordsCount] = useState<number>(0);
|
||||
|
||||
@@ -27,6 +26,7 @@ export default function ScribeFooterBar() {
|
||||
}, [editor?.state.doc.textContent]);
|
||||
|
||||
function getWordCount(): void {
|
||||
console.log(editor)
|
||||
if (editor) {
|
||||
try {
|
||||
const content: string = editor?.state.doc.textContent;
|
||||
@@ -50,12 +50,6 @@ export default function ScribeFooterBar() {
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
console.log(localOnlyBooks.length > 0 || offlineMode.isOffline);
|
||||
console.log(localOnlyBooks.length);
|
||||
console.log(offlineMode.isOffline);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="px-6 py-3 bg-tertiary/90 backdrop-blur-sm border-t border-secondary/50 text-text-primary flex justify-between items-center shadow-lg">
|
||||
@@ -100,7 +94,7 @@ export default function ScribeFooterBar() {
|
||||
!offlineMode.isOffline && <div
|
||||
className="flex items-center gap-2 bg-secondary/50 px-4 py-2 rounded-xl border border-secondary shadow-sm">
|
||||
<FontAwesomeIcon icon={faBook} className={'text-primary w-4 h-4'}/>
|
||||
<span className="text-text-primary font-bold">{serverOnlyBooks.length}</span>
|
||||
<span className="text-text-primary font-bold">{serverSyncedBooks.length}</span>
|
||||
</div>
|
||||
}
|
||||
{(localOnlyBooks.length > 0 || offlineMode.isOffline) && (
|
||||
|
||||
Reference in New Issue
Block a user