Skip to content

Build your personal knowledge base with Trilium Notes

touch protected session during note update

zadam71d248cd876a
diff --git a/package-lock.json b/package-lock.json
index d0dee325c7..dcb55a8927 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "trilium",
- "version": "0.41.4-beta",
+ "version": "0.41.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/src/public/app/services/protected_session_holder.js b/src/public/app/services/protected_session_holder.js
index 0c180e7fe7..7f0dc2a7dd 100644
--- a/src/public/app/services/protected_session_holder.js
+++ b/src/public/app/services/protected_session_holder.js
@@ -39,9 +39,16 @@ function touchProtectedSession() {
}
}
+function touchProtectedSessionIfNecessary(note) {
+ if (note && note.isProtected && isProtectedSessionAvailable()) {
+ touchProtectedSession();
+ }
+}
+
export default {
setProtectedSessionId,
resetProtectedSession,
isProtectedSessionAvailable,
- touchProtectedSession
+ touchProtectedSession,
+ touchProtectedSessionIfNecessary
};
\ No newline at end of file
diff --git a/src/public/app/services/tab_context.js b/src/public/app/services/tab_context.js
index b17df18fd1..dec5ebf0c1 100644
--- a/src/public/app/services/tab_context.js
+++ b/src/public/app/services/tab_context.js
@@ -69,10 +69,7 @@ class TabContext extends Component {
}
}, 5000);
- if (this.note.isProtected && protectedSessionHolder.isProtectedSessionAvailable()) {
- // FIXME: there are probably more places where this should be done
- protectedSessionHolder.touchProtectedSession();
- }
+ protectedSessionHolder.touchProtectedSessionIfNecessary(this.note);
if (triggerSwitchEvent) {
this.triggerEvent('tabNoteSwitched', {
diff --git a/src/public/app/widgets/basic_widget.js b/src/public/app/widgets/basic_widget.js
index 4b5a7dc346..06514edaa3 100644
--- a/src/public/app/widgets/basic_widget.js
+++ b/src/public/app/widgets/basic_widget.js
@@ -57,7 +57,10 @@ class BasicWidget extends Component {
for (const key in this.attrs) {
if (key === 'style') {
if (this.attrs[key]) {
- $widget.attr(key, $widget.attr('style') + ';' + this.attrs[key]);
+ let style = $widget.attr('style');
+ style = style ? `${style}; ${this.attrs[key]}` : this.attrs[key];
+
+ $widget.attr(key, style);
}
}
else {
diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js
index a973370cf0..9523b7b84e 100644
--- a/src/public/app/widgets/note_detail.js
+++ b/src/public/app/widgets/note_detail.js
@@ -61,6 +61,8 @@ export default class NoteDetailWidget extends TabAwareWidget {
const dto = note.dto;
dto.content = this.getTypeWidget().getContent();
+ protectedSessionHolder.touchProtectedSessionIfNecessary(note);
+
await server.put('notes/' + noteId, dto, this.componentId);
});
}
diff --git a/src/public/app/widgets/note_title.js b/src/public/app/widgets/note_title.js
index 074d01ca22..93eb840c30 100644
--- a/src/public/app/widgets/note_title.js
+++ b/src/public/app/widgets/note_title.js
@@ -29,6 +29,8 @@ export default class NoteTitleWidget extends TabAwareWidget {
this.spacedUpdate = new SpacedUpdate(async () => {
const title = this.$noteTitle.val();
+ protectedSessionHolder.touchProtectedSessionIfNecessary(this.note);
+
await server.put(`notes/${this.noteId}/change-title`, {title});
});
}