mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	Merge remote-tracking branch 'origin/master' into m42
# Conflicts: # src/public/app/services/app_context.js
This commit is contained in:
		
							
								
								
									
										1
									
								
								.idea/vcs.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								.idea/vcs.xml
									
									
									
										generated
									
									
									
								
							@@ -2,5 +2,6 @@
 | 
				
			|||||||
<project version="4">
 | 
					<project version="4">
 | 
				
			||||||
  <component name="VcsDirectoryMappings">
 | 
					  <component name="VcsDirectoryMappings">
 | 
				
			||||||
    <mapping directory="" vcs="Git" />
 | 
					    <mapping directory="" vcs="Git" />
 | 
				
			||||||
 | 
					    <mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
 | 
				
			||||||
  </component>
 | 
					  </component>
 | 
				
			||||||
</project>
 | 
					</project>
 | 
				
			||||||
@@ -101,12 +101,6 @@ class AppContext extends Component {
 | 
				
			|||||||
        return $(el).closest(".component").prop('component');
 | 
					        return $(el).closest(".component").prop('component');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async protectedSessionStartedEvent() {
 | 
					 | 
				
			||||||
        await treeCache.loadInitialTree();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        this.triggerEvent('treeCacheReloaded');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    async openInNewWindow(notePath) {
 | 
					    async openInNewWindow(notePath) {
 | 
				
			||||||
        if (utils.isElectron()) {
 | 
					        if (utils.isElectron()) {
 | 
				
			||||||
            const {ipcRenderer} = utils.dynamicRequire('electron');
 | 
					            const {ipcRenderer} = utils.dynamicRequire('electron');
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,10 @@
 | 
				
			|||||||
import treeService from './tree.js';
 | 
					 | 
				
			||||||
import utils from './utils.js';
 | 
					import utils from './utils.js';
 | 
				
			||||||
import server from './server.js';
 | 
					import server from './server.js';
 | 
				
			||||||
import protectedSessionHolder from './protected_session_holder.js';
 | 
					import protectedSessionHolder from './protected_session_holder.js';
 | 
				
			||||||
import toastService from "./toast.js";
 | 
					import toastService from "./toast.js";
 | 
				
			||||||
import ws from "./ws.js";
 | 
					import ws from "./ws.js";
 | 
				
			||||||
import appContext from "./app_context.js";
 | 
					import appContext from "./app_context.js";
 | 
				
			||||||
 | 
					import treeCache from "./tree_cache.js";
 | 
				
			||||||
const $enterProtectedSessionButton = $("#enter-protected-session-button");
 | 
					 | 
				
			||||||
const $leaveProtectedSessionButton = $("#leave-protected-session-button");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
let protectedSessionDeferred = null;
 | 
					let protectedSessionDeferred = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -45,6 +42,10 @@ async function setupProtectedSession(password) {
 | 
				
			|||||||
    protectedSessionHolder.setProtectedSessionId(response.protectedSessionId);
 | 
					    protectedSessionHolder.setProtectedSessionId(response.protectedSessionId);
 | 
				
			||||||
    protectedSessionHolder.touchProtectedSession();
 | 
					    protectedSessionHolder.touchProtectedSession();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    await treeCache.loadInitialTree();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    await appContext.triggerEvent('treeCacheReloaded');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    appContext.triggerEvent('protectedSessionStarted');
 | 
					    appContext.triggerEvent('protectedSessionStarted');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (protectedSessionDeferred !== null) {
 | 
					    if (protectedSessionDeferred !== null) {
 | 
				
			||||||
@@ -54,9 +55,6 @@ async function setupProtectedSession(password) {
 | 
				
			|||||||
        protectedSessionDeferred = null;
 | 
					        protectedSessionDeferred = null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $enterProtectedSessionButton.hide();
 | 
					 | 
				
			||||||
    $leaveProtectedSessionButton.show();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    toastService.showMessage("Protected session has been started.");
 | 
					    toastService.showMessage("Protected session has been started.");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,9 +39,16 @@ function touchProtectedSession() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function touchProtectedSessionIfNecessary(note) {
 | 
				
			||||||
 | 
					    if (note && note.isProtected && isProtectedSessionAvailable()) {
 | 
				
			||||||
 | 
					        touchProtectedSession();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
    setProtectedSessionId,
 | 
					    setProtectedSessionId,
 | 
				
			||||||
    resetProtectedSession,
 | 
					    resetProtectedSession,
 | 
				
			||||||
    isProtectedSessionAvailable,
 | 
					    isProtectedSessionAvailable,
 | 
				
			||||||
    touchProtectedSession
 | 
					    touchProtectedSession,
 | 
				
			||||||
 | 
					    touchProtectedSessionIfNecessary
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@@ -69,10 +69,7 @@ class TabContext extends Component {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }, 5000);
 | 
					        }, 5000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (this.note.isProtected && protectedSessionHolder.isProtectedSessionAvailable()) {
 | 
					        protectedSessionHolder.touchProtectedSessionIfNecessary(this.note);
 | 
				
			||||||
            // FIXME: there are probably more places where this should be done
 | 
					 | 
				
			||||||
            protectedSessionHolder.touchProtectedSession();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (triggerSwitchEvent) {
 | 
					        if (triggerSwitchEvent) {
 | 
				
			||||||
            this.triggerEvent('tabNoteSwitched', {
 | 
					            this.triggerEvent('tabNoteSwitched', {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,7 +57,10 @@ class BasicWidget extends Component {
 | 
				
			|||||||
        for (const key in this.attrs) {
 | 
					        for (const key in this.attrs) {
 | 
				
			||||||
            if (key === 'style') {
 | 
					            if (key === 'style') {
 | 
				
			||||||
                if (this.attrs[key]) {
 | 
					                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 {
 | 
					            else {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,6 +61,8 @@ export default class NoteDetailWidget extends TabAwareWidget {
 | 
				
			|||||||
            const dto = note.dto;
 | 
					            const dto = note.dto;
 | 
				
			||||||
            dto.content = this.getTypeWidget().getContent();
 | 
					            dto.content = this.getTypeWidget().getContent();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            protectedSessionHolder.touchProtectedSessionIfNecessary(note);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            await server.put('notes/' + noteId, dto, this.componentId);
 | 
					            await server.put('notes/' + noteId, dto, this.componentId);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,6 +29,8 @@ export default class NoteTitleWidget extends TabAwareWidget {
 | 
				
			|||||||
        this.spacedUpdate = new SpacedUpdate(async () => {
 | 
					        this.spacedUpdate = new SpacedUpdate(async () => {
 | 
				
			||||||
            const title = this.$noteTitle.val();
 | 
					            const title = this.$noteTitle.val();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            protectedSessionHolder.touchProtectedSessionIfNecessary(this.note);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            await server.put(`notes/${this.noteId}/change-title`, {title});
 | 
					            await server.put(`notes/${this.noteId}/change-title`, {title});
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,12 +5,12 @@ const TPL = `
 | 
				
			|||||||
<div class="btn-group btn-group-xs">
 | 
					<div class="btn-group btn-group-xs">
 | 
				
			||||||
    <button type="button"
 | 
					    <button type="button"
 | 
				
			||||||
            class="btn btn-sm icon-button bx bx-check-shield protect-button"
 | 
					            class="btn btn-sm icon-button bx bx-check-shield protect-button"
 | 
				
			||||||
            title="Protected note can be viewed and edited only after entering password">
 | 
					            title="Set this note as protected which means it will possible to view and edit this note only after entering password">
 | 
				
			||||||
    </button>
 | 
					    </button>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <button type="button"
 | 
					    <button type="button"
 | 
				
			||||||
            class="btn btn-sm icon-button bx bx-shield-x unprotect-button"
 | 
					            class="btn btn-sm icon-button bx bx-shield-x unprotect-button"
 | 
				
			||||||
            title="Not protected note can be viewed without entering password">
 | 
					            title="Set this note as unprotected which will make it viewable and editable without entering password">
 | 
				
			||||||
    </button>
 | 
					    </button>
 | 
				
			||||||
</div>`;``;
 | 
					</div>`;``;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,7 @@ async function loginSync(req) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // login token is valid for 5 minutes
 | 
					    // login token is valid for 5 minutes
 | 
				
			||||||
    if (Math.abs(timestamp.getTime() - now.getTime()) > 5 * 60 * 1000) {
 | 
					    if (Math.abs(timestamp.getTime() - now.getTime()) > 5 * 60 * 1000) {
 | 
				
			||||||
        return [400, { message: 'Auth request time is out of sync' }];
 | 
					        return [400, { message: 'Auth request time is out of sync, please check that both client and server have correct time.' }];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const syncVersion = req.body.syncVersion;
 | 
					    const syncVersion = req.body.syncVersion;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user