touch protected session during note update

This commit is contained in:
zadam 2020-04-25 11:09:07 +02:00
parent ac608b9334
commit 71d248cd87
6 changed files with 18 additions and 7 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "trilium",
"version": "0.41.4-beta",
"version": "0.41.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -39,9 +39,16 @@ function touchProtectedSession() {
}
}
function touchProtectedSessionIfNecessary(note) {
if (note && note.isProtected && isProtectedSessionAvailable()) {
touchProtectedSession();
}
}
export default {
setProtectedSessionId,
resetProtectedSession,
isProtectedSessionAvailable,
touchProtectedSession
touchProtectedSession,
touchProtectedSessionIfNecessary
};

View File

@ -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', {

View File

@ -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 {

View File

@ -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);
});
}

View File

@ -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});
});
}