mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 10:55:55 +01:00
fix initial document setup
This commit is contained in:
@@ -5,55 +5,11 @@ const enexImportService = require('../../services/import/enex');
|
||||
const opmlImportService = require('../../services/import/opml');
|
||||
const tarImportService = require('../../services/import/tar');
|
||||
const singleImportService = require('../../services/import/single');
|
||||
const messagingService = require('../../services/messaging');
|
||||
const cls = require('../../services/cls');
|
||||
const path = require('path');
|
||||
const noteCacheService = require('../../services/note_cache');
|
||||
const log = require('../../services/log');
|
||||
|
||||
class ImportContext {
|
||||
constructor(importId, safeImport) {
|
||||
// importId is to distinguish between different import events - it is possible (though not recommended)
|
||||
// to have multiple imports going at the same time
|
||||
this.importId = importId;
|
||||
|
||||
this.safeImport = safeImport;
|
||||
|
||||
// // count is mean to represent count of exported notes where practical, otherwise it's just some measure of progress
|
||||
this.progressCount = 0;
|
||||
this.lastSentCountTs = Date.now();
|
||||
}
|
||||
|
||||
async increaseProgressCount() {
|
||||
this.progressCount++;
|
||||
|
||||
if (Date.now() - this.lastSentCountTs >= 500) {
|
||||
this.lastSentCountTs = Date.now();
|
||||
|
||||
await messagingService.sendMessageToAllClients({
|
||||
importId: this.importId,
|
||||
type: 'import-progress-count',
|
||||
progressCount: this.progressCount
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async importFinished(noteId) {
|
||||
await messagingService.sendMessageToAllClients({
|
||||
importId: this.importId,
|
||||
type: 'import-finished',
|
||||
noteId: noteId
|
||||
});
|
||||
}
|
||||
|
||||
// must remaing non-static
|
||||
async reportError(message) {
|
||||
await messagingService.sendMessageToAllClients({
|
||||
type: 'import-error',
|
||||
message: message
|
||||
});
|
||||
}
|
||||
}
|
||||
const ImportContext = require('../../services/import_context');
|
||||
|
||||
async function importToBranch(req) {
|
||||
let {parentNoteId, importId, safeImport} = req.params;
|
||||
|
||||
Reference in New Issue
Block a user