mirror of
https://github.com/zadam/trilium.git
synced 2025-06-05 01:18:44 +02:00
renamed openTabs to openNoteContexts
This commit is contained in:
parent
17128c5874
commit
3f8bf7cacc
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
getTabState() {
|
||||
getPojoState() {
|
||||
if (!this.notePath && this.hoistedNoteId === 'root') {
|
||||
// keeping empty hoisted tab is esp. important for mobile (e.g. opened launcher config)
|
||||
return null;
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user