{attachments.length ? (
- attachments.map(attachment =>
)
+ attachments.map(attachment =>
)
) : (
{t("attachment_list.no_attachments")}
@@ -69,7 +73,46 @@ function AttachmentListHeader({ noteId }: { noteId: string }) {
)
}
-function AttachmentDetail({ attachment, isFullDetail }: { attachment: FAttachment, isFullDetail?: boolean }) {
+/**
+ * Displays information about a single attachment.
+ */
+export function AttachmentDetail({ note, viewScope }: TypeWidgetProps) {
+ const [ attachment, setAttachment ] = useState(undefined);
+
+ useEffect(() => {
+ if (!viewScope?.attachmentId) return;
+ froca.getAttachment(viewScope.attachmentId).then(setAttachment);
+ }, [ viewScope ]);
+
+ return (
+
+
+ {t("attachment_detail.owning_note")}{" "}
+
+ {t("attachment_detail.you_can_also_open")}{" "}
+
+
+
+
+
+ {attachment !== null ? (
+ attachment &&
+ ) : (
+
{t("attachment_detail.attachment_deleted")}
+ )}
+
+
+ )
+}
+
+function AttachmentInfo({ attachment, isFullDetail }: { attachment: FAttachment, isFullDetail?: boolean }) {
const contentWrapper = useRef(null);
useEffect(() => {
diff --git a/apps/client/src/widgets/type_widgets_old/attachment_detail.ts b/apps/client/src/widgets/type_widgets_old/attachment_detail.ts
deleted file mode 100644
index 9dbfa5210..000000000
--- a/apps/client/src/widgets/type_widgets_old/attachment_detail.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-import TypeWidget from "./type_widget.js";
-import AttachmentDetailWidget from "../attachment_detail.js";
-import linkService from "../../services/link.js";
-import froca from "../../services/froca.js";
-import utils from "../../services/utils.js";
-import { t } from "../../services/i18n.js";
-import type FNote from "../../entities/fnote.js";
-import type { EventData } from "../../components/app_context.js";
-
-const TPL = /*html*/`
-`;
-
-export default class AttachmentDetailTypeWidget extends TypeWidget {
- $wrapper!: JQuery;
- $linksWrapper!: JQuery;
-
- static getType() {
- return "attachmentDetail";
- }
-
- doRender() {
- this.$widget = $(TPL);
- this.$wrapper = this.$widget.find(".attachment-wrapper");
- this.$linksWrapper = this.$widget.find(".links-wrapper");
-
- super.doRender();
- }
-
- async doRefresh(note: Parameters[0]) {
- this.$wrapper.empty();
- this.children = [];
-
- const $helpButton = $(`
-