chore(prettier): fix all files

This commit is contained in:
Elian Doran
2025-01-09 18:07:02 +02:00
parent 19ee861699
commit 4cbb529fd4
571 changed files with 23226 additions and 23940 deletions

View File

@@ -11,7 +11,7 @@ import beccaLoader from "../../becca/becca_loader.js";
import log from "../../services/log.js";
import TaskContext from "../../services/task_context.js";
import ValidationError from "../../errors/validation_error.js";
import { Request } from 'express';
import { Request } from "express";
import BNote from "../../becca/entities/bnote.js";
async function importNotesToBranch(req: Request) {
@@ -19,12 +19,12 @@ async function importNotesToBranch(req: Request) {
const { taskId, last } = req.body;
const options = {
safeImport: req.body.safeImport !== 'false',
shrinkImages: req.body.shrinkImages !== 'false',
textImportedAsText: req.body.textImportedAsText !== 'false',
codeImportedAsCode: req.body.codeImportedAsCode !== 'false',
explodeArchives: req.body.explodeArchives !== 'false',
replaceUnderscoresWithSpaces: req.body.replaceUnderscoresWithSpaces !== 'false'
safeImport: req.body.safeImport !== "false",
shrinkImages: req.body.shrinkImages !== "false",
textImportedAsText: req.body.textImportedAsText !== "false",
codeImportedAsCode: req.body.codeImportedAsCode !== "false",
explodeArchives: req.body.explodeArchives !== "false",
replaceUnderscoresWithSpaces: req.body.replaceUnderscoresWithSpaces !== "false"
};
const file = req.file;
@@ -46,19 +46,19 @@ async function importNotesToBranch(req: Request) {
let note: BNote | null; // typically root of the import - client can show it after finishing the import
const taskContext = TaskContext.getInstance(taskId, 'importNotes', options);
const taskContext = TaskContext.getInstance(taskId, "importNotes", options);
try {
if (extension === '.zip' && options.explodeArchives && typeof file.buffer !== "string") {
if (extension === ".zip" && options.explodeArchives && typeof file.buffer !== "string") {
note = await zipImportService.importZip(taskContext, file.buffer, parentNote);
} else if (extension === '.opml' && options.explodeArchives) {
} else if (extension === ".opml" && options.explodeArchives) {
const importResult = await opmlImportService.importOpml(taskContext, file.buffer, parentNote);
if (!Array.isArray(importResult)) {
note = importResult;
} else {
return importResult;
}
} else if (extension === '.enex' && options.explodeArchives) {
} else if (extension === ".enex" && options.explodeArchives) {
const importResult = await enexImportService.importEnex(taskContext, file, parentNote);
if (!Array.isArray(importResult)) {
note = importResult;
@@ -68,8 +68,7 @@ async function importNotesToBranch(req: Request) {
} else {
note = await singleImportService.importSingleFile(taskContext, file, parentNote);
}
}
catch (e: any) {
} catch (e: any) {
const message = `Import failed with following error: '${e.message}'. More details might be in the logs.`;
taskContext.reportError(message);
@@ -84,10 +83,14 @@ async function importNotesToBranch(req: Request) {
if (last === "true") {
// small timeout to avoid race condition (the message is received before the transaction is committed)
setTimeout(() => taskContext.taskSucceeded({
parentNoteId: parentNoteId,
importedNoteId: note?.noteId
}), 1000);
setTimeout(
() =>
taskContext.taskSucceeded({
parentNoteId: parentNoteId,
importedNoteId: note?.noteId
}),
1000
);
}
// import has deactivated note events so becca is not updated, instead we force it to reload
@@ -101,7 +104,7 @@ async function importAttachmentsToNote(req: Request) {
const { taskId, last } = req.body;
const options = {
shrinkImages: req.body.shrinkImages !== 'false',
shrinkImages: req.body.shrinkImages !== "false"
};
const file = req.file;
@@ -111,14 +114,13 @@ async function importAttachmentsToNote(req: Request) {
}
const parentNote = becca.getNoteOrThrow(parentNoteId);
const taskContext = TaskContext.getInstance(taskId, 'importAttachment', options);
const taskContext = TaskContext.getInstance(taskId, "importAttachment", options);
// unlike in note import, we let the events run, because a huge number of attachments is not likely
try {
await singleImportService.importAttachment(taskContext, file, parentNote);
}
catch (e: any) {
} catch (e: any) {
const message = `Import failed with following error: '${e.message}'. More details might be in the logs.`;
taskContext.reportError(message);
@@ -129,9 +131,13 @@ async function importAttachmentsToNote(req: Request) {
if (last === "true") {
// small timeout to avoid race condition (the message is received before the transaction is committed)
setTimeout(() => taskContext.taskSucceeded({
parentNoteId: parentNoteId
}), 1000);
setTimeout(
() =>
taskContext.taskSucceeded({
parentNoteId: parentNoteId
}),
1000
);
}
}