From 36c87b7fa0140eb4cd6a16146764dc2c29dc1f8d Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 26 Aug 2019 20:21:43 +0200 Subject: [PATCH] renamed "messagingService" to "ws" --- src/public/javascripts/desktop.js | 4 ++-- src/public/javascripts/dialogs/export.js | 4 ++-- src/public/javascripts/dialogs/import.js | 4 ++-- src/public/javascripts/services/attributes.js | 6 +++--- src/public/javascripts/services/info.js | 6 +++--- src/public/javascripts/services/note_detail.js | 6 +++--- src/public/javascripts/services/sidebar.js | 6 +++--- src/public/javascripts/services/tree.js | 12 ++++++------ src/public/javascripts/services/tree_builder.js | 4 ++-- src/public/javascripts/services/tree_cache.js | 4 ++-- src/public/javascripts/services/tree_context_menu.js | 4 ++-- .../javascripts/services/{messaging.js => ws.js} | 0 src/public/javascripts/widgets/attributes.js | 6 +++--- src/routes/api/clipper.js | 4 ++-- src/routes/api/export.js | 8 ++++---- src/services/backend_script_api.js | 6 +++--- src/services/consistency_checks.js | 6 +++--- src/services/content_hash.js | 4 ++-- src/services/import_context.js | 6 +++--- src/services/{messaging.js => ws.js} | 0 src/www | 4 ++-- 21 files changed, 52 insertions(+), 52 deletions(-) rename src/public/javascripts/services/{messaging.js => ws.js} (100%) rename src/services/{messaging.js => ws.js} (100%) diff --git a/src/public/javascripts/desktop.js b/src/public/javascripts/desktop.js index f17740ca9..02fd9a7ba 100644 --- a/src/public/javascripts/desktop.js +++ b/src/public/javascripts/desktop.js @@ -2,7 +2,7 @@ import cloning from './services/cloning.js'; import contextMenu from './services/tree_context_menu.js'; import dragAndDropSetup from './services/drag_and_drop.js'; import link from './services/link.js'; -import messagingService from './services/messaging.js'; +import ws from './services/ws.js'; import noteDetailService from './services/note_detail.js'; import noteType from './services/note_type.js'; import protectedSessionService from './services/protected_session.js'; @@ -71,7 +71,7 @@ window.onerror = function (msg, url, lineNo, columnNo, error) { ].join(' - '); } - messagingService.logError(message); + ws.logError(message); return false; }; diff --git a/src/public/javascripts/dialogs/export.js b/src/public/javascripts/dialogs/export.js index 749614dfd..65929e3fe 100644 --- a/src/public/javascripts/dialogs/export.js +++ b/src/public/javascripts/dialogs/export.js @@ -1,6 +1,6 @@ import treeUtils from "../services/tree_utils.js"; import utils from "../services/utils.js"; -import messagingService from "../services/messaging.js"; +import ws from "../services/ws.js"; import infoService from "../services/info.js"; const $dialog = $("#export-dialog"); @@ -112,7 +112,7 @@ $('input[name=export-subtree-format]').change(function () { } }); -messagingService.subscribeToMessages(async message => { +ws.subscribeToMessages(async message => { if (message.type === 'export-error') { infoService.showError(message.message); $dialog.modal('hide'); diff --git a/src/public/javascripts/dialogs/import.js b/src/public/javascripts/dialogs/import.js index 47e39821a..d7d6edd4a 100644 --- a/src/public/javascripts/dialogs/import.js +++ b/src/public/javascripts/dialogs/import.js @@ -3,7 +3,7 @@ import utils from '../services/utils.js'; import treeUtils from "../services/tree_utils.js"; import server from "../services/server.js"; import infoService from "../services/info.js"; -import messagingService from "../services/messaging.js"; +import ws from "../services/ws.js"; const $dialog = $("#import-dialog"); const $form = $("#import-form"); @@ -117,7 +117,7 @@ function boolToString($el) { return $el.is(":checked") ? "true" : "false"; } -messagingService.subscribeToMessages(async message => { +ws.subscribeToMessages(async message => { if (message.type === 'import-error') { infoService.showError(message.message); $dialog.modal('hide'); diff --git a/src/public/javascripts/services/attributes.js b/src/public/javascripts/services/attributes.js index 3bbd947f6..5a62e60f9 100644 --- a/src/public/javascripts/services/attributes.js +++ b/src/public/javascripts/services/attributes.js @@ -1,6 +1,6 @@ import server from "./server.js"; import utils from "./utils.js"; -import messagingService from "./messaging.js"; +import ws from "./ws.js"; import treeUtils from "./tree_utils.js"; import noteAutocompleteService from "./note_autocomplete.js"; import linkService from "./link.js"; @@ -179,7 +179,7 @@ class Attributes { .append($openButton)); } else { - messagingService.logError("Unknown labelType=" + definitionAttr.labelType); + ws.logError("Unknown labelType=" + definitionAttr.labelType); } } else if (valueAttr.type === 'relation') { @@ -197,7 +197,7 @@ class Attributes { $input.setSelectedPath(valueAttr.value); } else { - messagingService.logError("Unknown attribute type=" + valueAttr.type); + ws.logError("Unknown attribute type=" + valueAttr.type); return; } diff --git a/src/public/javascripts/services/info.js b/src/public/javascripts/services/info.js index c3eb76f8f..2df8ed600 100644 --- a/src/public/javascripts/services/info.js +++ b/src/public/javascripts/services/info.js @@ -1,4 +1,4 @@ -import messagingService from "./messaging.js"; +import ws from "./ws.js"; import utils from "./utils.js"; function showMessage(message) { @@ -13,7 +13,7 @@ function showMessage(message) { function showAndLogError(message, delay = 10000) { showError(message, delay); - messagingService.logError(message); + ws.logError(message); } function showError(message, delay = 10000) { @@ -44,7 +44,7 @@ function getNotifySettings(type, delay) { } function throwError(message) { - messagingService.logError(message); + ws.logError(message); throw new Error(message); } diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js index f374fbc35..c53d7446a 100644 --- a/src/public/javascripts/services/note_detail.js +++ b/src/public/javascripts/services/note_detail.js @@ -1,7 +1,7 @@ import treeService from './tree.js'; import TabContext from './tab_context.js'; import server from './server.js'; -import messagingService from "./messaging.js"; +import ws from "./ws.js"; import treeCache from "./tree_cache.js"; import NoteFull from "../entities/note_full.js"; import bundleService from "./bundle.js"; @@ -353,7 +353,7 @@ function fireDetailLoaded() { detailLoadedListeners = []; } -messagingService.subscribeToOutsideSyncMessages(syncData => { +ws.subscribeToOutsideSyncMessages(syncData => { const noteIdsToRefresh = new Set(); syncData @@ -370,7 +370,7 @@ messagingService.subscribeToOutsideSyncMessages(syncData => { } }); -messagingService.subscribeToAllSyncMessages(syncData => { +ws.subscribeToAllSyncMessages(syncData => { for (const tc of tabContexts) { tc.syncDataReceived(syncData); } diff --git a/src/public/javascripts/services/sidebar.js b/src/public/javascripts/services/sidebar.js index 4a8b8dbe7..17155b5f4 100644 --- a/src/public/javascripts/services/sidebar.js +++ b/src/public/javascripts/services/sidebar.js @@ -1,5 +1,5 @@ import bundleService from "./bundle.js"; -import messagingService from "./messaging.js"; +import ws from "./ws.js"; import optionsService from "./options.js"; class Sidebar { @@ -83,7 +83,7 @@ class Sidebar { } } catch (e) { - messagingService.logError(`Error while creating widget ${widgetClass.name}: ${e.message}`); + ws.logError(`Error while creating widget ${widgetClass.name}: ${e.message}`); } } @@ -95,7 +95,7 @@ class Sidebar { this.$widgetContainer.append($el); } catch (e) { - messagingService.logError(`Error while loading widget ${widget.widgetName}: ${e.message}`); + ws.logError(`Error while loading widget ${widget.widgetName}: ${e.message}`); } } } diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index ae721f867..5ffd5241d 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -1,6 +1,6 @@ import contextMenuWidget from './context_menu.js'; import dragAndDropSetup from './drag_and_drop.js'; -import messagingService from './messaging.js'; +import ws from './ws.js'; import noteDetailService from './note_detail.js'; import protectedSessionHolder from './protected_session_holder.js'; import treeUtils from './tree_utils.js'; @@ -126,7 +126,7 @@ async function getNodeFromPath(notePath, expand = false, expandOpts = {}) { foundChildNode = findChildNode(parentNode, childNoteId); if (!foundChildNode) { - messagingService.logError(`Can't find node for child node of noteId=${childNoteId} for parent of noteId=${parentNode.data.noteId} and hoistedNoteId=${hoistedNoteId}, requested path is ${notePath}`); + ws.logError(`Can't find node for child node of noteId=${childNoteId} for parent of noteId=${parentNode.data.noteId} and hoistedNoteId=${hoistedNoteId}, requested path is ${notePath}`); return; } } @@ -233,7 +233,7 @@ async function getRunPath(notePath) { const parents = await child.getParentNotes(); if (!parents) { - messagingService.logError("No parents found for " + childNoteId); + ws.logError("No parents found for " + childNoteId); return; } @@ -258,7 +258,7 @@ async function getRunPath(notePath) { break; } else { - messagingService.logError("No parents, can't activate node."); + ws.logError("No parents, can't activate node."); return; } } @@ -738,7 +738,7 @@ async function showTree() { initFancyTree(tree); } -messagingService.subscribeToMessages(message => { +ws.subscribeToMessages(message => { if (message.type === 'refresh-tree') { reload(); } @@ -753,7 +753,7 @@ messagingService.subscribeToMessages(message => { } }); -messagingService.subscribeToOutsideSyncMessages(syncData => { +ws.subscribeToOutsideSyncMessages(syncData => { if (syncData.some(sync => sync.entityName === 'branches') || syncData.some(sync => sync.entityName === 'notes')) { diff --git a/src/public/javascripts/services/tree_builder.js b/src/public/javascripts/services/tree_builder.js index 16a1c4708..2f8c8ef24 100644 --- a/src/public/javascripts/services/tree_builder.js +++ b/src/public/javascripts/services/tree_builder.js @@ -3,7 +3,7 @@ import utils from "./utils.js"; import Branch from "../entities/branch.js"; import server from "./server.js"; import treeCache from "./tree_cache.js"; -import messagingService from "./messaging.js"; +import ws from "./ws.js"; import hoistedNoteService from "./hoisted_note.js"; async function prepareTree() { @@ -100,7 +100,7 @@ async function prepareRealBranch(parentNote) { const childBranches = await parentNote.getChildBranches(); if (!childBranches) { - messagingService.logError(`No children for ${parentNote}. This shouldn't happen.`); + ws.logError(`No children for ${parentNote}. This shouldn't happen.`); return; } diff --git a/src/public/javascripts/services/tree_cache.js b/src/public/javascripts/services/tree_cache.js index 33497180e..a3fdf203c 100644 --- a/src/public/javascripts/services/tree_cache.js +++ b/src/public/javascripts/services/tree_cache.js @@ -2,7 +2,7 @@ import utils from "./utils.js"; import Branch from "../entities/branch.js"; import NoteShort from "../entities/note_short.js"; import infoService from "./info.js"; -import messagingService from "./messaging.js"; +import ws from "./ws.js"; import server from "./server.js"; /** @@ -107,7 +107,7 @@ class TreeCache { return noteIds.map(noteId => { if (!this.notes[noteId] && !silentNotFoundError) { - messagingService.logError(`Can't find note "${noteId}"`); + ws.logError(`Can't find note "${noteId}"`); return null; } diff --git a/src/public/javascripts/services/tree_context_menu.js b/src/public/javascripts/services/tree_context_menu.js index b407f476a..aa636882b 100644 --- a/src/public/javascripts/services/tree_context_menu.js +++ b/src/public/javascripts/services/tree_context_menu.js @@ -1,5 +1,5 @@ import treeService from './tree.js'; -import messagingService from './messaging.js'; +import ws from './ws.js'; import protectedSessionService from './protected_session.js'; import treeChangesService from './branches.js'; import treeUtils from './tree_utils.js'; @@ -153,7 +153,7 @@ class TreeContextMenu { hoistedNoteService.unhoist(); } else { - messagingService.logError("Unknown command: " + cmd); + ws.logError("Unknown command: " + cmd); } } } diff --git a/src/public/javascripts/services/messaging.js b/src/public/javascripts/services/ws.js similarity index 100% rename from src/public/javascripts/services/messaging.js rename to src/public/javascripts/services/ws.js diff --git a/src/public/javascripts/widgets/attributes.js b/src/public/javascripts/widgets/attributes.js index eda7c1db3..3f800b19a 100644 --- a/src/public/javascripts/widgets/attributes.js +++ b/src/public/javascripts/widgets/attributes.js @@ -1,6 +1,6 @@ import utils from "../services/utils.js"; import linkService from "../services/link.js"; -import messagingService from "../services/messaging.js"; +import ws from "../services/ws.js"; import StandardWidget from "./standard_widget.js"; class AttributesWidget extends StandardWidget { @@ -71,12 +71,12 @@ class AttributesWidget extends StandardWidget { $container.append(await linkService.createNoteLink(attribute.value)); $container.append(" "); } else { - messagingService.logError(`Relation ${attribute.attributeId} has empty target`); + ws.logError(`Relation ${attribute.attributeId} has empty target`); } } else if (attribute.type === 'label-definition' || attribute.type === 'relation-definition') { $container.append(attribute.name + " definition "); } else { - messagingService.logError("Unknown attr type: " + attribute.type); + ws.logError("Unknown attr type: " + attribute.type); } } } diff --git a/src/routes/api/clipper.js b/src/routes/api/clipper.js index 4a3904c2c..5be97ea45 100644 --- a/src/routes/api/clipper.js +++ b/src/routes/api/clipper.js @@ -5,7 +5,7 @@ const dateNoteService = require('../../services/date_notes'); const dateUtils = require('../../services/date_utils'); const imageService = require('../../services/image'); const appInfo = require('../../services/app_info'); -const messagingService = require('../../services/messaging'); +const ws = require('../../services/ws.js'); const log = require('../../services/log'); const utils = require('../../services/utils'); const path = require('path'); @@ -102,7 +102,7 @@ async function addImagesToNote(images, note, content) { async function openNote(req) { if (utils.isElectron()) { - messagingService.sendMessageToAllClients({ + ws.sendMessageToAllClients({ type: 'open-note', noteId: req.params.noteId }); diff --git a/src/routes/api/export.js b/src/routes/api/export.js index 59d6a20d3..4117800c1 100644 --- a/src/routes/api/export.js +++ b/src/routes/api/export.js @@ -4,7 +4,7 @@ const tarExportService = require('../../services/export/tar'); const singleExportService = require('../../services/export/single'); const opmlExportService = require('../../services/export/opml'); const repository = require("../../services/repository"); -const messagingService = require("../../services/messaging"); +const ws = require("../../services/ws.js"); const log = require("../../services/log"); class ExportContext { @@ -23,7 +23,7 @@ class ExportContext { if (Date.now() - this.lastSentCountTs >= 500) { this.lastSentCountTs = Date.now(); - await messagingService.sendMessageToAllClients({ + await ws.sendMessageToAllClients({ exportId: this.exportId, type: 'export-progress-count', progressCount: this.progressCount @@ -32,7 +32,7 @@ class ExportContext { } async exportFinished() { - await messagingService.sendMessageToAllClients({ + await ws.sendMessageToAllClients({ exportId: this.exportId, type: 'export-finished' }); @@ -40,7 +40,7 @@ class ExportContext { // must remaing non-static async reportError(message) { - await messagingService.sendMessageToAllClients({ + await ws.sendMessageToAllClients({ type: 'export-error', message: message }); diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.js index 9de17d977..377b58d4d 100644 --- a/src/services/backend_script_api.js +++ b/src/services/backend_script_api.js @@ -10,7 +10,7 @@ const repository = require('./repository'); const axios = require('axios'); const dayjs = require('dayjs'); const cloningService = require('./cloning'); -const messagingService = require('./messaging'); +const ws = require('./ws.js'); const appInfo = require('./app_info'); const searchService = require('./search'); @@ -211,7 +211,7 @@ function BackendScriptApi(currentNote, apiParams) { this.createNoteAndRefresh = async function(parentNoteId, title, content, extraOptions) { await noteService.createNote(parentNoteId, title, content, extraOptions); - messagingService.refreshTree(); + ws.refreshTree(); }; /** @@ -307,7 +307,7 @@ function BackendScriptApi(currentNote, apiParams) { * * @returns {Promise} */ - this.refreshTree = messagingService.refreshTree; + this.refreshTree = ws.refreshTree; /** * @return {{syncVersion, appVersion, buildRevision, dbVersion, dataDirectory, buildDate}|*} - object representing basic info about running Trilium version diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index cd8b6a8f9..ed2e55815 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -3,7 +3,7 @@ const sql = require('./sql'); const sqlInit = require('./sql_init'); const log = require('./log'); -const messagingService = require('./messaging'); +const ws = require('./ws.js'); const syncMutexService = require('./sync_mutex'); const repository = require('./repository'); const cls = require('./cls'); @@ -381,13 +381,13 @@ async function runChecks() { }); if (fixedIssues) { - messagingService.refreshTree(); + ws.refreshTree(); } if (unrecoverableConsistencyErrors) { log.info(`Consistency checks failed (took ${elapsedTimeMs}ms)`); - messagingService.sendMessageToAllClients({type: 'consistency-checks-failed'}); + ws.sendMessageToAllClients({type: 'consistency-checks-failed'}); } else { log.info(`All consistency checks passed (took ${elapsedTimeMs}ms)`); diff --git a/src/services/content_hash.js b/src/services/content_hash.js index c89322817..e1ffc29ce 100644 --- a/src/services/content_hash.js +++ b/src/services/content_hash.js @@ -4,7 +4,7 @@ const sql = require('./sql'); const utils = require('./utils'); const log = require('./log'); const eventLogService = require('./event_log'); -const messagingService = require('./messaging'); +const ws = require('./ws.js'); const ApiToken = require('../entities/api_token'); const Branch = require('../entities/branch'); const Note = require('../entities/note'); @@ -60,7 +60,7 @@ async function checkContentHashes(otherHashes) { if (key !== 'recent_notes') { // let's not get alarmed about recent notes which get updated often and can cause failures in race conditions - await messagingService.sendMessageToAllClients({type: 'sync-hash-check-failed'}); + await ws.sendMessageToAllClients({type: 'sync-hash-check-failed'}); } } } diff --git a/src/services/import_context.js b/src/services/import_context.js index 5d2935ddd..ea29f5c75 100644 --- a/src/services/import_context.js +++ b/src/services/import_context.js @@ -1,6 +1,6 @@ "use strict"; -const messagingService = require('./messaging'); +const ws = require('./ws.js'); // importId => ImportContext const importContexts = {}; @@ -36,7 +36,7 @@ class ImportContext { if (Date.now() - this.lastSentCountTs >= 500) { this.lastSentCountTs = Date.now(); - await messagingService.sendMessageToAllClients({ + await ws.sendMessageToAllClients({ importId: this.importId, type: 'import-progress-count', progressCount: this.progressCount @@ -46,7 +46,7 @@ class ImportContext { // must remaing non-static async reportError(message) { - await messagingService.sendMessageToAllClients({ + await ws.sendMessageToAllClients({ type: 'import-error', message: message }); diff --git a/src/services/messaging.js b/src/services/ws.js similarity index 100% rename from src/services/messaging.js rename to src/services/ws.js diff --git a/src/www b/src/www index d775fce35..26375f40a 100755 --- a/src/www +++ b/src/www @@ -21,7 +21,7 @@ const https = require('https'); const config = require('./services/config'); const log = require('./services/log'); const appInfo = require('./services/app_info'); -const messagingService = require('./services/messaging'); +const ws = require('./services/ws.js'); const utils = require('./services/utils'); const sqlInit = require('./services/sql_init'); const port = require('./services/port'); @@ -77,7 +77,7 @@ async function startTrilium() { httpServer.on('error', onError); httpServer.on('listening', () => debug('Listening on port' + httpServer.address().port)); - sqlInit.dbReady.then(() => messagingService.init(httpServer, sessionParser)); + sqlInit.dbReady.then(() => ws.init(httpServer, sessionParser)); if (utils.isElectron()) { const electronRouting = require('./routes/electron');