refactor(layout): use note.isContentAvailable()

This commit is contained in:
Elian Doran 2025-12-14 22:51:50 +02:00
parent 19709f749a
commit 16374aaf1d
No known key found for this signature in database

View File

@ -3,7 +3,6 @@ import { useContext } from "preact/hooks";
import FNote from "../../entities/fnote"; import FNote from "../../entities/fnote";
import { t } from "../../services/i18n"; import { t } from "../../services/i18n";
import { downloadFileNote, openNoteExternally } from "../../services/open"; import { downloadFileNote, openNoteExternally } from "../../services/open";
import protected_session_holder from "../../services/protected_session_holder";
import ActionButton from "../react/ActionButton"; import ActionButton from "../react/ActionButton";
import { FormFileUploadActionButton } from "../react/FormFileUpload"; import { FormFileUploadActionButton } from "../react/FormFileUpload";
import { ParentComponent } from "../react/react_utils"; import { ParentComponent } from "../react/react_utils";
@ -63,13 +62,11 @@ function ImageActions(props: NoteActionsCustomProps) {
function UploadNewRevisionButton({ note, onChange }: NoteActionsCustomProps & { function UploadNewRevisionButton({ note, onChange }: NoteActionsCustomProps & {
onChange: (files: FileList | null) => void; onChange: (files: FileList | null) => void;
}) { }) {
const canAccessProtectedNote = !note?.isProtected || protected_session_holder.isProtectedSessionAvailable();
return ( return (
<FormFileUploadActionButton <FormFileUploadActionButton
icon="bx bx-folder-open" icon="bx bx-folder-open"
text={t("image_properties.upload_new_revision")} text={t("image_properties.upload_new_revision")}
disabled={!canAccessProtectedNote} disabled={!note.isContentAvailable()}
onChange={onChange} onChange={onChange}
/> />
); );
@ -87,13 +84,11 @@ function OpenExternallyButton({ note }: NoteActionsCustomProps) {
} }
function DownloadFileButton({ note }: NoteActionsCustomProps) { function DownloadFileButton({ note }: NoteActionsCustomProps) {
const canAccessProtectedNote = !note?.isProtected || protected_session_holder.isProtectedSessionAvailable();
return ( return (
<ActionButton <ActionButton
icon="bx bx-download" icon="bx bx-download"
text={t("file_properties.download")} text={t("file_properties.download")}
disabled={!canAccessProtectedNote} disabled={!note.isContentAvailable()}
onClick={() => downloadFileNote(note.noteId)} onClick={() => downloadFileNote(note.noteId)}
/> />
); );