import { ConfirmModal, Focusable, showModal } from "decky-frontend-lib";
import { VFC, useEffect, useState } from "react";
import { ScrollableWindowRelative } from "./ScrollableWindow";
import { t } from "i18next";
interface LogFileProps {
plugin: string;
name: string;
closeModal?: () => void;
}
const uploadConfirmation = (name: string, plugin: string) => {
const confirmModal = {
window.DeckyPluginLoader.callServerMethod("upload_log", { plugin_name: plugin, log_name: name }).then((res) => {
console.log(res)
showModal({res.result}
)
})
}} strTitle={t("LogViewer.uploadConfirm")}>{t("LogViewer.uploadDisclaimer")}
showModal(confirmModal);
}
const LogViewModal: VFC = ({ name, plugin, closeModal }) => {
const [logText, setLogText] = useState("");
useEffect(() => {
window.DeckyPluginLoader.callServerMethod("get_plugin_log_text", {
plugin_name: plugin,
log_name: name,
}).then((text) => {
setLogText(text.result || t("LogViewer.textError"));
});
}, []);
return (
uploadConfirmation(name, plugin)}
>
{logText}
);
};
export default LogViewModal;