mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
state management fixes
This commit is contained in:
parent
ff1d312a43
commit
650d9e0b27
@ -1,4 +1,4 @@
|
||||
FROM node:12.6.0-alpine
|
||||
FROM node:12.9.1-alpine
|
||||
|
||||
# Create app directory
|
||||
WORKDIR /usr/src/app
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PKG_DIR=dist/trilium-linux-x64-server
|
||||
NODE_VERSION=12.6.0
|
||||
NODE_VERSION=12.9.1
|
||||
|
||||
rm -r $PKG_DIR
|
||||
mkdir $PKG_DIR
|
||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -3127,9 +3127,9 @@
|
||||
"integrity": "sha512-PcW2a0tyTuPHz3tWyYqtK6r1fZ3gp+3Sop8Ph+ZYN81Ob5rwmbHEzaqs10N3BEsaGTkh/ooniXK+WwszGlc2+Q=="
|
||||
},
|
||||
"electron": {
|
||||
"version": "6.0.4",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-6.0.4.tgz",
|
||||
"integrity": "sha512-zrPi36etADOAjxnVX6TxRNKSWaBscMLd9S7AB+qISzI0dnYIDKycHpc2mB+5QWBd/8cR4m/1NLNTqNhX5KKGFg==",
|
||||
"version": "6.0.5",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-6.0.5.tgz",
|
||||
"integrity": "sha512-B3gjUvvXxVH4QnmGEMYne83lG2XJNbNe0FPwVDhzA9FkapnBgvrsE/Fz6NFXTaZm6zSdC2ut1j38rfSTFvUtDA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "^10.12.18",
|
||||
|
@ -77,7 +77,7 @@
|
||||
"xml2js": "0.4.19"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "6.0.4",
|
||||
"electron": "6.0.5",
|
||||
"electron-builder": "21.2.0",
|
||||
"electron-compile": "6.4.4",
|
||||
"electron-installer-debian": "2.0.0",
|
||||
|
@ -16,7 +16,7 @@ const linkOverlays = [
|
||||
export default class LinkMap {
|
||||
constructor(note, $linkMapContainer, options = {}) {
|
||||
this.note = note;
|
||||
this.options = $.extend({
|
||||
this.options = Object.assign({
|
||||
maxDepth: 10,
|
||||
maxNotes: 30,
|
||||
zoom: 1.0
|
||||
@ -39,7 +39,7 @@ export default class LinkMap {
|
||||
}
|
||||
|
||||
async loadNotesAndRelations(options = {}) {
|
||||
this.options = $.extend(this.options, options);
|
||||
this.options = Object.assign(this.options, options);
|
||||
|
||||
this.cleanup();
|
||||
|
||||
|
@ -183,6 +183,8 @@ async function renderComponent(ctx) {
|
||||
ctx.$noteTitle.show(); // this can be hidden by empty detail
|
||||
ctx.$noteTitle.removeAttr("readonly"); // this can be set by protected session service
|
||||
|
||||
await ctx.initComponent();
|
||||
|
||||
await ctx.getComponent().render();
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,9 @@ class Sidebar {
|
||||
constructor(ctx, state = {}) {
|
||||
/** @property {TabContext} */
|
||||
this.ctx = ctx;
|
||||
this.state = state;
|
||||
this.state = Object.assign({
|
||||
widgets: []
|
||||
}, state);
|
||||
this.widgets = [];
|
||||
this.rendered = false;
|
||||
this.$sidebar = ctx.$tabContent.find(".note-detail-sidebar");
|
||||
@ -73,10 +75,8 @@ class Sidebar {
|
||||
}
|
||||
|
||||
for (const widgetClass of widgetClasses) {
|
||||
const state = (this.state.widgets || []).find(s => s.name === widgetClass.name);
|
||||
|
||||
try {
|
||||
const widget = new widgetClass(this.ctx, options, state);
|
||||
const widget = new widgetClass(this.ctx, options, this.state);
|
||||
|
||||
if (await widget.isEnabled()) {
|
||||
this.widgets.push(widget);
|
||||
|
@ -20,14 +20,16 @@ class StandardWidget {
|
||||
/**
|
||||
* @param {TabContext} ctx
|
||||
* @param {Options} options
|
||||
* @param {object} state
|
||||
* @param {object} sidebarState
|
||||
*/
|
||||
constructor(ctx, options, state) {
|
||||
constructor(ctx, options, sidebarState) {
|
||||
this.ctx = ctx;
|
||||
this.state = state;
|
||||
// construct in camelCase
|
||||
this.widgetName = this.constructor.name.substr(0, 1).toLowerCase() + this.constructor.name.substr(1);
|
||||
this.widgetOptions = options.getJson(this.widgetName) || {};
|
||||
this.state = sidebarState.widgets.find(s => s.name === this.widgetName) || {
|
||||
expanded: this.widgetOptions.expanded
|
||||
};
|
||||
}
|
||||
|
||||
getWidgetTitle() { return "Untitled widget"; }
|
||||
@ -47,7 +49,7 @@ class StandardWidget {
|
||||
this.$bodyWrapper = this.$widget.find('.body-wrapper');
|
||||
this.$bodyWrapper.attr('id', widgetId);
|
||||
|
||||
if ((this.state && this.state.expanded) || (!this.state && this.widgetOptions.expanded)) {
|
||||
if (this.state.expanded) {
|
||||
this.$bodyWrapper.collapse("show");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user