mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-30 10:36:35 +02:00
Open the note from URL even if Joplin isn't running
This commit is contained in:
parent
00504898f2
commit
61161039c8
@ -30,12 +30,14 @@ export default class ElectronAppWrapper {
|
||||
private buildDir_: string = null;
|
||||
private rendererProcessQuitReply_: RendererProcessQuitReply = null;
|
||||
private pluginWindows_: PluginWindows = {};
|
||||
private initialUrl_: string = null;
|
||||
|
||||
constructor(electronApp: any, env: string, profilePath: string, isDebugMode: boolean) {
|
||||
constructor(electronApp: any, env: string, profilePath: string, isDebugMode: boolean, initialUrl: string) {
|
||||
this.electronApp_ = electronApp;
|
||||
this.env_ = env;
|
||||
this.isDebugMode_ = isDebugMode;
|
||||
this.profilePath_ = profilePath;
|
||||
this.initialUrl_ = initialUrl;
|
||||
}
|
||||
|
||||
electronApp() {
|
||||
@ -183,6 +185,8 @@ export default class ElectronAppWrapper {
|
||||
// save the response and try quit again.
|
||||
this.rendererProcessQuitReply_ = args;
|
||||
this.electronApp_.quit();
|
||||
} else if (message === 'getInitialUrl' && this.initialUrl_) {
|
||||
this.openUrl(this.initialUrl_);
|
||||
}
|
||||
});
|
||||
|
||||
@ -328,7 +332,7 @@ export default class ElectronAppWrapper {
|
||||
win.focus();
|
||||
if (process.platform !== 'darwin') {
|
||||
const url = argv.find((arg) => arg.startsWith('joplin://'));
|
||||
if (url) this.onUrl(url);
|
||||
if (url) this.openUrl(url);
|
||||
}
|
||||
});
|
||||
|
||||
@ -358,11 +362,11 @@ export default class ElectronAppWrapper {
|
||||
});
|
||||
|
||||
this.electronApp_.on('open-url', (_event: any, url: string) => {
|
||||
this.onUrl(url);
|
||||
});
|
||||
this.openUrl(url);
|
||||
});
|
||||
}
|
||||
|
||||
async onUrl(url: string) {
|
||||
async openUrl(url: string) {
|
||||
this.win_.webContents.send('asynchronous-message', 'openUrl', {
|
||||
url: url,
|
||||
});
|
||||
|
@ -41,7 +41,6 @@ import RevisionService from '@joplin/lib/services/RevisionService';
|
||||
import MigrationService from '@joplin/lib/services/MigrationService';
|
||||
import { loadCustomCss, injectCustomStyles } from '@joplin/lib/CssUtils';
|
||||
// import populateDatabase from '@joplin/lib/services/debug/populateDatabase';
|
||||
const ipcRenderer = require('electron').ipcRenderer;
|
||||
|
||||
const commands = [
|
||||
require('./gui/MainScreen/commands/editAlarm'),
|
||||
@ -162,14 +161,6 @@ class Application extends BaseApplication {
|
||||
super();
|
||||
|
||||
this.bridge_nativeThemeUpdated = this.bridge_nativeThemeUpdated.bind(this);
|
||||
|
||||
ipcRenderer.on('asynchronous-message', (_event: any, message: string, args: any) => {
|
||||
if (message === 'openUrl') {
|
||||
const noteId = (args.url as string).substring('joplin://'.length);
|
||||
CommandService.instance().execute('openNote', noteId);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
hasGui() {
|
||||
|
@ -185,6 +185,15 @@ class MainScreenComponent extends React.Component<Props, State> {
|
||||
this.layoutModeListenerKeyDown = this.layoutModeListenerKeyDown.bind(this);
|
||||
|
||||
window.addEventListener('resize', this.window_resize);
|
||||
|
||||
ipcRenderer.on('asynchronous-message', (_event: any, message: string, args: any) => {
|
||||
if (message === 'openUrl') {
|
||||
console.log(`openUrl ${args.url}`);
|
||||
const noteId = (args.url as string).substring('joplin://'.length);
|
||||
CommandService.instance().execute('openNote', noteId);
|
||||
}
|
||||
});
|
||||
ipcRenderer.send('asynchronous-message', 'getInitialUrl');
|
||||
}
|
||||
|
||||
private updateLayoutPluginViews(layout: LayoutItem, plugins: PluginStates) {
|
||||
|
@ -44,7 +44,9 @@ if (env === 'dev' && process.platform === 'win32') {
|
||||
electronApp.setAsDefaultProtocolClient('joplin');
|
||||
}
|
||||
|
||||
const wrapper = new ElectronAppWrapper(electronApp, env, profilePath, isDebugMode);
|
||||
const initialUrl = process.argv.find((arg) => arg.startsWith('joplin://'));
|
||||
|
||||
const wrapper = new ElectronAppWrapper(electronApp, env, profilePath, isDebugMode, initialUrl);
|
||||
|
||||
initBridge(wrapper);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user