mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
renamed openTabs to openNoteContexts
This commit is contained in:
parent
17128c5874
commit
3f8bf7cacc
@ -1,5 +1,4 @@
|
|||||||
- isDeleted = 0 by default
|
- isDeleted = 0 by default
|
||||||
- rename openTabs to openNoteContexts
|
|
||||||
- unify readOnly handling to a single attribute:
|
- unify readOnly handling to a single attribute:
|
||||||
* readOnly - like now
|
* readOnly - like now
|
||||||
* readOnly=auto - like without readOnly (used to override inherited readOnly)
|
* readOnly=auto - like without readOnly (used to override inherited readOnly)
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
UPDATE options SET name = 'openNoteContexts' WHERE name = 'openTabs';
|
||||||
|
UPDATE entity_changes SET entityId = 'openNoteContexts' WHERE entityName = 'options' AND entityId = 'openTabs';
|
@ -179,7 +179,7 @@ class NoteContext extends Component {
|
|||||||
return appContext.tabManager.activeNtxId === this.ntxId;
|
return appContext.tabManager.activeNtxId === this.ntxId;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTabState() {
|
getPojoState() {
|
||||||
if (!this.notePath && this.hoistedNoteId === 'root') {
|
if (!this.notePath && this.hoistedNoteId === 'root') {
|
||||||
// keeping empty hoisted tab is esp. important for mobile (e.g. opened launcher config)
|
// keeping empty hoisted tab is esp. important for mobile (e.g. opened launcher config)
|
||||||
return null;
|
return null;
|
||||||
|
@ -26,12 +26,12 @@ export default class TabManager extends Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const openTabs = this.noteContexts
|
const openNoteContexts = this.noteContexts
|
||||||
.map(nc => nc.getTabState())
|
.map(nc => nc.getPojoState())
|
||||||
.filter(t => !!t);
|
.filter(t => !!t);
|
||||||
|
|
||||||
await server.put('options', {
|
await server.put('options', {
|
||||||
openTabs: JSON.stringify(openTabs)
|
openNoteContexts: JSON.stringify(openNoteContexts)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -50,17 +50,17 @@ export default class TabManager extends Component {
|
|||||||
|
|
||||||
async loadTabs() {
|
async loadTabs() {
|
||||||
try {
|
try {
|
||||||
const tabsToOpen = appContext.isMainWindow
|
const noteContextsToOpen = appContext.isMainWindow
|
||||||
? (options.getJson('openTabs') || [])
|
? (options.getJson('openNoteContexts') || [])
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
// preload all notes at once
|
// preload all notes at once
|
||||||
await froca.getNotes([
|
await froca.getNotes([
|
||||||
...tabsToOpen.map(tab => treeService.getNoteIdFromNotePath(tab.notePath)),
|
...noteContextsToOpen.map(tab => treeService.getNoteIdFromNotePath(tab.notePath)),
|
||||||
...tabsToOpen.map(tab => tab.hoistedNoteId),
|
...noteContextsToOpen.map(tab => tab.hoistedNoteId),
|
||||||
], true);
|
], 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
|
if (utils.isMobile()) { // mobile frontend doesn't have tabs so show only the active tab
|
||||||
return !!openTab.active;
|
return !!openTab.active;
|
||||||
}
|
}
|
||||||
@ -81,22 +81,22 @@ export default class TabManager extends Component {
|
|||||||
// resolve before opened tabs can change this
|
// resolve before opened tabs can change this
|
||||||
const parsedFromUrl = treeService.parseNavigationStateFromAddress();
|
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
|
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',
|
notePath: parsedFromUrl.notePath || 'root',
|
||||||
ntxId: parsedFromUrl.ntxId,
|
ntxId: parsedFromUrl.ntxId,
|
||||||
active: true,
|
active: true,
|
||||||
hoistedNoteId: parsedFromUrl.hoistedNoteId || 'root',
|
hoistedNoteId: parsedFromUrl.hoistedNoteId || 'root',
|
||||||
viewScope: parsedFromUrl.viewScope || {}
|
viewScope: parsedFromUrl.viewScope || {}
|
||||||
});
|
});
|
||||||
} else if (!filteredTabs.find(tab => tab.active)) {
|
} else if (!filteredNoteContexts.find(tab => tab.active)) {
|
||||||
filteredTabs[0].active = true;
|
filteredNoteContexts[0].active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.tabsUpdate.allowUpdateWithoutChange(async () => {
|
await this.tabsUpdate.allowUpdateWithoutChange(async () => {
|
||||||
for (const tab of filteredTabs) {
|
for (const tab of filteredNoteContexts) {
|
||||||
await this.openContextWithNote(tab.notePath, {
|
await this.openContextWithNote(tab.notePath, {
|
||||||
activate: tab.active,
|
activate: tab.active,
|
||||||
ntxId: tab.ntxId,
|
ntxId: tab.ntxId,
|
||||||
@ -119,7 +119,7 @@ export default class TabManager extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
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
|
// try to recover
|
||||||
await this.openEmptyTab();
|
await this.openEmptyTab();
|
||||||
|
@ -26,7 +26,7 @@ async function processEntityChanges(entityChanges) {
|
|||||||
} else if (ec.entityName === 'note_revisions') {
|
} else if (ec.entityName === 'note_revisions') {
|
||||||
loadResults.addNoteRevision(ec.entityId, ec.noteId, ec.componentId);
|
loadResults.addNoteRevision(ec.entityId, ec.noteId, ec.componentId);
|
||||||
} else if (ec.entityName === 'options') {
|
} else if (ec.entityName === 'options') {
|
||||||
if (ec.entity.name === 'openTabs') {
|
if (ec.entity.name === 'openNoteContexts') {
|
||||||
continue; // only noise
|
continue; // only noise
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ const processedEntityChangeIds = new Set();
|
|||||||
function logRows(entityChanges) {
|
function logRows(entityChanges) {
|
||||||
const filteredRows = entityChanges.filter(row =>
|
const filteredRows = entityChanges.filter(row =>
|
||||||
!processedEntityChangeIds.has(row.id)
|
!processedEntityChangeIds.has(row.id)
|
||||||
&& (row.entityName !== 'options' || row.entityId !== 'openTabs'));
|
&& (row.entityName !== 'options' || row.entityId !== 'openNoteContexts'));
|
||||||
|
|
||||||
if (filteredRows.length > 0) {
|
if (filteredRows.length > 0) {
|
||||||
console.debug(utils.now(), "Frontend update data: ", filteredRows);
|
console.debug(utils.now(), "Frontend update data: ", filteredRows);
|
||||||
|
@ -24,7 +24,7 @@ const ALLOWED_OPTIONS = new Set([
|
|||||||
'detailFontFamily',
|
'detailFontFamily',
|
||||||
'monospaceFontSize',
|
'monospaceFontSize',
|
||||||
'monospaceFontFamily',
|
'monospaceFontFamily',
|
||||||
'openTabs',
|
'openNoteContexts',
|
||||||
'noteInfoWidget',
|
'noteInfoWidget',
|
||||||
'attributesWidget',
|
'attributesWidget',
|
||||||
'linkMapWidget',
|
'linkMapWidget',
|
||||||
@ -102,8 +102,8 @@ function update(name, value) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name !== 'openTabs') {
|
if (name !== 'openNoteContexts') {
|
||||||
log.info(`Updating option ${name} to ${value}`);
|
log.info(`Updating option '${name}' to '${value}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
optionService.setOption(name, value);
|
optionService.setOption(name, value);
|
||||||
|
@ -4,7 +4,7 @@ const build = require('./build');
|
|||||||
const packageJson = require('../../package');
|
const packageJson = require('../../package');
|
||||||
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
||||||
|
|
||||||
const APP_DB_VERSION = 219;
|
const APP_DB_VERSION = 220;
|
||||||
const SYNC_VERSION = 30;
|
const SYNC_VERSION = 30;
|
||||||
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ function initDocumentOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initNotSyncedOptions(initialized, opts = {}) {
|
function initNotSyncedOptions(initialized, opts = {}) {
|
||||||
optionService.createOption('openTabs', JSON.stringify([
|
optionService.createOption('openNoteContexts', JSON.stringify([
|
||||||
{
|
{
|
||||||
notePath: 'root',
|
notePath: 'root',
|
||||||
active: true
|
active: true
|
||||||
@ -104,7 +104,7 @@ function initStartupOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.TRILIUM_START_NOTE_ID || process.env.TRILIUM_SAFE_MODE) {
|
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',
|
notePath: process.env.TRILIUM_START_NOTE_ID || 'root',
|
||||||
active: true
|
active: true
|
||||||
|
@ -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 startNoteId = sql.getValue("SELECT noteId FROM branches WHERE parentNoteId = 'root' AND isDeleted = 0 ORDER BY notePosition");
|
||||||
|
|
||||||
const optionService = require("./options");
|
const optionService = require("./options");
|
||||||
optionService.setOption('openTabs', JSON.stringify([
|
optionService.setOption('openNoteContexts', JSON.stringify([
|
||||||
{
|
{
|
||||||
notePath: startNoteId,
|
notePath: startNoteId,
|
||||||
active: true
|
active: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user