minor refactor, cleanup

This commit is contained in:
Nystik
2026-03-11 22:08:30 +01:00
parent 2b9ebf1fbd
commit 9789be6d70
38 changed files with 259 additions and 379 deletions

View File

@@ -1,38 +1,40 @@
// Shim for remote.dialog
// Obsidian uses: showOpenDialog, showSaveDialog, showMessageBox, showErrorBox
export const dialogShim = {
async showOpenDialog(browserWindow, options) {
// TODO: implement custom modal UI with server-side file listing
console.log('[shim:dialog] showOpenDialog (stub):', options);
// TODO: implement custom modal with server-side file listing
console.log("[shim:dialog] showOpenDialog (stub):", options);
return { canceled: true, filePaths: [] };
},
async showSaveDialog(browserWindow, options) {
// TODO: implement custom modal UI
console.log('[shim:dialog] showSaveDialog (stub):', options);
// TODO: implement custom modal
console.log("[shim:dialog] showSaveDialog (stub):", options);
return { canceled: true, filePath: undefined };
},
async showMessageBox(browserWindow, options) {
// TODO: implement custom modal matching Electron's return format
// For now, use browser confirm/alert as rough approximation
if (typeof browserWindow === 'object' && !options) {
if (typeof browserWindow === "object" && !options) {
options = browserWindow;
}
console.log('[shim:dialog] showMessageBox:', options);
console.log("[shim:dialog] showMessageBox:", options);
const message = options.message || '';
const detail = options.detail || '';
const buttons = options.buttons || ['OK'];
const message = options.message || "";
const detail = options.detail || "";
const buttons = options.buttons || ["OK"];
// Simple fallback: use confirm for 2-button, alert for 1-button
if (buttons.length <= 1) {
alert(message + (detail ? '\n\n' + detail : ''));
alert(message + (detail ? "\n\n" + detail : ""));
return { response: 0, checkboxChecked: false };
}
const result = confirm(message + (detail ? '\n\n' + detail : '') + '\n\n[OK] = "' + buttons[0] + '", [Cancel] = "' + buttons[1] + '"');
const result = confirm(
message +
(detail ? "\n\n" + detail : "") +
'\n\n[OK] = "' +
buttons[0] +
'", [Cancel] = "' +
buttons[1] +
'"',
);
return {
response: result ? 0 : 1,
checkboxChecked: false,
@@ -40,7 +42,7 @@ export const dialogShim = {
},
showErrorBox(title, content) {
console.error('[shim:dialog] Error:', title, content);
alert(title + '\n\n' + content);
console.error("[shim:dialog] Error:", title, content);
alert(title + "\n\n" + content);
},
};