1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-14 18:27:44 +02:00

Chore: Set type of main BrowserWindow, and fixed popup calls

This commit is contained in:
Laurent Cozic 2023-02-22 18:15:21 +00:00
parent 46982c7d64
commit 6c12ce0e04
10 changed files with 13 additions and 13 deletions

View File

@ -3,7 +3,7 @@ import { PluginMessage } from './services/plugins/PluginRunner';
import shim from '@joplin/lib/shim';
import { isCallbackUrl } from '@joplin/lib/callbackUrlUtils';
const { BrowserWindow, Tray, screen } = require('electron');
import { BrowserWindow, Tray, screen } from 'electron';
const url = require('url');
const path = require('path');
const { dirname } = require('@joplin/lib/path-utils');
@ -25,7 +25,7 @@ export default class ElectronAppWrapper {
private env_: string;
private isDebugMode_: boolean;
private profilePath_: string;
private win_: any = null;
private win_: BrowserWindow = null;
private willQuitApp_: boolean = false;
private tray_: any = null;
private buildDir_: string = null;
@ -117,7 +117,7 @@ export default class ElectronAppWrapper {
this.win_.setPosition(primaryDisplayWidth / 2 - windowWidth, primaryDisplayHeight / 2 - windowHeight);
}
this.win_.loadURL(url.format({
void this.win_.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true,

View File

@ -225,7 +225,7 @@ export default function(props: Props) {
];
const menu = bridge().Menu.buildFromTemplate(template);
menu.popup(bridge().window());
menu.popup({ window: bridge().window() });
}, [onInstall, onBrowsePlugins]);
const onSearchQueryChange = useCallback((event: OnChangeEvent) => {

View File

@ -20,7 +20,7 @@ export const runtime = (): CommandRuntime => {
const menuItems = SpellCheckerService.instance().spellCheckerConfigMenuItems(selectedLanguages, useSpellChecker);
const menu = Menu.buildFromTemplate(menuItems as any);
menu.popup(bridge().window());
menu.popup({ window: bridge().window() });
},
mapStateToTitle(state: AppState): string {

View File

@ -42,7 +42,7 @@ export default function MultiNoteActions(props: MultiNoteActionsProps) {
const multiNotesButton_click = (item: any) => {
if (item.submenu) {
item.submenu.popup(bridge().window());
item.submenu.popup({ window: bridge().window() });
} else {
item.click();
}

View File

@ -107,7 +107,7 @@ export default function(editor: any, plugins: PluginStates, dispatch: Function)
template = template.concat(menuUtils.pluginContextMenuItems(plugins, MenuItemLocation.EditorContextMenu));
const menu = bridge().Menu.buildFromTemplate(template);
menu.popup(bridge().window());
menu.popup({ window: bridge().window() });
}
bridge().window().webContents.on('context-menu', onContextMenu);

View File

@ -45,7 +45,7 @@ export default function useMessageHandler(scrollWhenReady: any, setScrollWhenRea
fireEditorEvent: () => { console.warn('fireEditorEvent() not implemented'); },
}, dispatch);
menu.popup(bridge().window());
menu.popup({ window: bridge().window() });
} else if (msg.indexOf('#') === 0) {
// This is an internal anchor, which is handled by the WebView so skip this case
} else if (msg === 'contentScriptExecuteCommand') {

View File

@ -123,7 +123,7 @@ const NoteListComponent = (props: Props) => {
customCss: props.customCss,
});
menu.popup(bridge().window());
menu.popup({ window: bridge().window() });
}, [props.selectedNoteIds, props.notes, props.dispatch, props.watchedNoteFiles, props.plugins, props.selectedFolderId, props.customCss]);
const onGlobalDrop_ = () => {

View File

@ -62,7 +62,7 @@ export default function PdfViewer(props: Props) {
fireEditorEvent: () => { console.warn('fireEditorEvent() not implemented'); },
} as ContextMenuOptions, props.dispatch);
menu.popup(bridge().window());
menu.popup({ window: bridge().window() });
}, [props.dispatch]);
const onMessage_ = useCallback(async (event: any) => {

View File

@ -271,7 +271,7 @@ const SidebarComponent = (props: Props) => {
new MenuItem(menuUtils.commandToStatefulMenuItem('newFolder'))
);
menu.popup(bridge().window());
menu.popup({ window: bridge().window() });
}, []);
const itemContextMenu = useCallback(async (event: any) => {
@ -423,7 +423,7 @@ const SidebarComponent = (props: Props) => {
}
}
menu.popup(bridge().window());
menu.popup({ window: bridge().window() });
}, [props.folders, props.dispatch, pluginsRef]);
const folderItem_click = useCallback((folderId: string) => {

View File

@ -233,7 +233,7 @@ const create = (win, options) => {
// When this is being called from a web view, we can't use `win` as this
// would refer to the web view which is not allowed to render a popup menu.
//
menu.popup(electronRemote ? electronRemote.getCurrentWindow() : win);
menu.popup({ window: electronRemote ? electronRemote.getCurrentWindow() : win });
}
});
};