Skip to content

Build your personal knowledge base with Trilium Notes

renamed openTabs to openNoteContexts

zadam3f8bf7cacc5d
diff --git a/db/TODO.txt b/db/TODO.txt
index db29e44f33..0803aab056 100644
--- a/db/TODO.txt
+++ b/db/TODO.txt
@@ -1,5 +1,4 @@
- isDeleted = 0 by default
-- rename openTabs to openNoteContexts
- unify readOnly handling to a single attribute:
* readOnly - like now
* readOnly=auto - like without readOnly (used to override inherited readOnly)
diff --git a/db/migrations/0220__rename_openTabs_to_openNoteContexts.sql b/db/migrations/0220__rename_openTabs_to_openNoteContexts.sql
new file mode 100644
index 0000000000..c4d719bce4
--- /dev/null
+++ b/db/migrations/0220__rename_openTabs_to_openNoteContexts.sql
@@ -0,0 +1,2 @@
+UPDATE options SET name = 'openNoteContexts' WHERE name = 'openTabs';
+UPDATE entity_changes SET entityId = 'openNoteContexts' WHERE entityName = 'options' AND entityId = 'openTabs';
diff --git a/src/public/app/components/note_context.js b/src/public/app/components/note_context.js
index 87cc72f439..4284410d7e 100644
--- a/src/public/app/components/note_context.js
+++ b/src/public/app/components/note_context.js
@@ -179,7 +179,7 @@ class NoteContext extends Component {
return appContext.tabManager.activeNtxId === this.ntxId;
}
- getTabState() {
+ getPojoState() {
if (!this.notePath && this.hoistedNoteId === 'root') {
// keeping empty hoisted tab is esp. important for mobile (e.g. opened launcher config)
return null;
diff --git a/src/public/app/components/tab_manager.js b/src/public/app/components/tab_manager.js
index 91148cff12..a2b9dd9917 100644
--- a/src/public/app/components/tab_manager.js
+++ b/src/public/app/components/tab_manager.js
@@ -26,12 +26,12 @@ export default class TabManager extends Component {
return;
}
- const openTabs = this.noteContexts
- .map(nc => nc.getTabState())
+ const openNoteContexts = this.noteContexts
+ .map(nc => nc.getPojoState())
.filter(t => !!t);
await server.put('options', {
- openTabs: JSON.stringify(openTabs)
+ openNoteContexts: JSON.stringify(openNoteContexts)
});
});
@@ -50,17 +50,17 @@ export default class TabManager extends Component {
async loadTabs() {
try {
- const tabsToOpen = appContext.isMainWindow
- ? (options.getJson('openTabs') || [])
+ const noteContextsToOpen = appContext.isMainWindow
+ ? (options.getJson('openNoteContexts') || [])
: [];
// preload all notes at once
await froca.getNotes([
- ...tabsToOpen.map(tab => treeService.getNoteIdFromNotePath(tab.notePath)),
- ...tabsToOpen.map(tab => tab.hoistedNoteId),
+ ...noteContextsToOpen.map(tab => treeService.getNoteIdFromNotePath(tab.notePath)),
+ ...noteContextsToOpen.map(tab => tab.hoistedNoteId),
], true);
- const filteredTabs = tabsToOpen.filter(openTab => {
+ const filteredNoteContexts = noteContextsToOpen.filter(openTab => {
if (utils.isMobile()) { // mobile frontend doesn't have tabs so show only the active tab
return !!openTab.active;
}
@@ -81,22 +81,22 @@ export default class TabManager extends Component {
// resolve before opened tabs can change this
const parsedFromUrl = treeService.parseNavigationStateFromAddress();
- if (filteredTabs.length === 0) {
+ if (filteredNoteContexts.length === 0) {
parsedFromUrl.ntxId = parsedFromUrl.ntxId || NoteContext.generateNtxId(); // generate already here, so that we later know which one to activate
- filteredTabs.push({
+ filteredNoteContexts.push({
notePath: parsedFromUrl.notePath || 'root',
ntxId: parsedFromUrl.ntxId,
active: true,
hoistedNoteId: parsedFromUrl.hoistedNoteId || 'root',
viewScope: parsedFromUrl.viewScope || {}
});
- } else if (!filteredTabs.find(tab => tab.active)) {
- filteredTabs[0].active = true;
+ } else if (!filteredNoteContexts.find(tab => tab.active)) {
+ filteredNoteContexts[0].active = true;
}
await this.tabsUpdate.allowUpdateWithoutChange(async () => {
- for (const tab of filteredTabs) {
+ for (const tab of filteredNoteContexts) {
await this.openContextWithNote(tab.notePath, {
activate: tab.active,
ntxId: tab.ntxId,
@@ -119,7 +119,7 @@ export default class TabManager extends Component {
}
}
catch (e) {
- logError(`Loading tabs '${options.get('openTabs')}' failed: ${e.message} ${e.stack}`);
+ logError(`Loading note contexts '${options.get('openNoteContexts')}' failed: ${e.message} ${e.stack}`);
// try to recover
await this.openEmptyTab();
diff --git a/src/public/app/services/froca_updater.js b/src/public/app/services/froca_updater.js
index 52f0b33fc5..1e09a0bbba 100644
--- a/src/public/app/services/froca_updater.js
+++ b/src/public/app/services/froca_updater.js
@@ -26,7 +26,7 @@ async function processEntityChanges(entityChanges) {
} else if (ec.entityName === 'note_revisions') {
loadResults.addNoteRevision(ec.entityId, ec.noteId, ec.componentId);
} else if (ec.entityName === 'options') {
- if (ec.entity.name === 'openTabs') {
+ if (ec.entity.name === 'openNoteContexts') {
continue; // only noise
}
diff --git a/src/public/app/services/ws.js b/src/public/app/services/ws.js
index 265274ce22..cc77164a1a 100644
--- a/src/public/app/services/ws.js
+++ b/src/public/app/services/ws.js
@@ -53,7 +53,7 @@ const processedEntityChangeIds = new Set();
function logRows(entityChanges) {
const filteredRows = entityChanges.filter(row =>
!processedEntityChangeIds.has(row.id)
- && (row.entityName !== 'options' || row.entityId !== 'openTabs'));
+ && (row.entityName !== 'options' || row.entityId !== 'openNoteContexts'));
if (filteredRows.length > 0) {
console.debug(utils.now(), "Frontend update data: ", filteredRows);
diff --git a/src/routes/api/options.js b/src/routes/api/options.js
index c5c772d5e6..b522ad7b2b 100644
--- a/src/routes/api/options.js
+++ b/src/routes/api/options.js
@@ -24,7 +24,7 @@ const ALLOWED_OPTIONS = new Set([
'detailFontFamily',
'monospaceFontSize',
'monospaceFontFamily',
- 'openTabs',
+ 'openNoteContexts',
'noteInfoWidget',
'attributesWidget',
'linkMapWidget',
@@ -102,8 +102,8 @@ function update(name, value) {
return false;
}
- if (name !== 'openTabs') {
- log.info(`Updating option ${name} to ${value}`);
+ if (name !== 'openNoteContexts') {
+ log.info(`Updating option '${name}' to '${value}'`);
}
optionService.setOption(name, value);
diff --git a/src/services/app_info.js b/src/services/app_info.js
index 1a4313229e..fdd8b50a01 100644
--- a/src/services/app_info.js
+++ b/src/services/app_info.js
@@ -4,7 +4,7 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');
-const APP_DB_VERSION = 219;
+const APP_DB_VERSION = 220;
const SYNC_VERSION = 30;
const CLIPPER_PROTOCOL_VERSION = "1.0";
diff --git a/src/services/options_init.js b/src/services/options_init.js
index c22a0567f1..2a3a705d07 100644
--- a/src/services/options_init.js
+++ b/src/services/options_init.js
@@ -11,7 +11,7 @@ function initDocumentOptions() {
}
function initNotSyncedOptions(initialized, opts = {}) {
- optionService.createOption('openTabs', JSON.stringify([
+ optionService.createOption('openNoteContexts', JSON.stringify([
{
notePath: 'root',
active: true
@@ -104,7 +104,7 @@ function initStartupOptions() {
}
if (process.env.TRILIUM_START_NOTE_ID || process.env.TRILIUM_SAFE_MODE) {
- optionService.setOption('openTabs', JSON.stringify([
+ optionService.setOption('openNoteContexts', JSON.stringify([
{
notePath: process.env.TRILIUM_START_NOTE_ID || 'root',
active: true
diff --git a/src/services/sql_init.js b/src/services/sql_init.js
index ad8761add0..847a96f08f 100644
--- a/src/services/sql_init.js
+++ b/src/services/sql_init.js
@@ -106,7 +106,7 @@ async function createInitialDatabase() {
const startNoteId = sql.getValue("SELECT noteId FROM branches WHERE parentNoteId = 'root' AND isDeleted = 0 ORDER BY notePosition");
const optionService = require("./options");
- optionService.setOption('openTabs', JSON.stringify([
+ optionService.setOption('openNoteContexts', JSON.stringify([
{
notePath: startNoteId,
active: true