Add version to WebAPI initialize call in sticker creator preload

This commit is contained in:
Ken Powers 2020-01-21 16:48:05 -05:00 committed by Scott Nonnenberg
parent 6cc0f2abce
commit 95d393ee89
3 changed files with 14 additions and 7 deletions

17
main.js
View File

@ -189,9 +189,12 @@ async function handleUrl(event, target) {
}
}
function captureClicks(window) {
function handleCommonWindowEvents(window) {
window.webContents.on('will-navigate', handleUrl);
window.webContents.on('new-window', handleUrl);
window.webContents.on('preload-error', (event, preloadPath, error) => {
console.error(`Preload error in ${preloadPath}: `, error.message);
});
}
const DEFAULT_WIDTH = 800;
@ -340,7 +343,7 @@ function createWindow() {
mainWindow.webContents.openDevTools();
}
captureClicks(mainWindow);
handleCommonWindowEvents(mainWindow);
// Emitted when the window is about to be closed.
// Note: We do most of our shutdown logic here because all windows are closed by
@ -504,7 +507,7 @@ function showAbout() {
aboutWindow = new BrowserWindow(options);
captureClicks(aboutWindow);
handleCommonWindowEvents(aboutWindow);
aboutWindow.loadURL(prepareURL([__dirname, 'about.html']));
@ -553,7 +556,7 @@ async function showSettingsWindow() {
settingsWindow = new BrowserWindow(options);
captureClicks(settingsWindow);
handleCommonWindowEvents(settingsWindow);
settingsWindow.loadURL(prepareURL([__dirname, 'settings.html']));
@ -620,7 +623,7 @@ async function showStickerCreator() {
stickerCreatorWindow = new BrowserWindow(options);
captureClicks(stickerCreatorWindow);
handleCommonWindowEvents(stickerCreatorWindow);
const appUrl = config.enableHttp
? prepareURL(['http://localhost:6380/sticker-creator/dist/index.html'])
@ -673,7 +676,7 @@ async function showDebugLogWindow() {
debugLogWindow = new BrowserWindow(options);
captureClicks(debugLogWindow);
handleCommonWindowEvents(debugLogWindow);
debugLogWindow.loadURL(prepareURL([__dirname, 'debug_log.html'], { theme }));
@ -722,7 +725,7 @@ async function showPermissionsPopupWindow() {
permissionsPopupWindow = new BrowserWindow(options);
captureClicks(permissionsPopupWindow);
handleCommonWindowEvents(permissionsPopupWindow);
permissionsPopupWindow.loadURL(
prepareURL([__dirname, 'permissions_popup.html'], { theme })

View File

@ -50,11 +50,14 @@ const InnerGrid = SortableContainer(
async paths => {
actions.initializeStickers(paths);
paths.forEach(path => {
// tslint:disable-next-line no-floating-promises
queue.add(async () => {
try {
const webp = await convertToWebp(path);
actions.addWebp(webp);
} catch (e) {
// @ts-ignore
window.log.error('Error processing image:', e);
actions.removeSticker(path);
actions.addToast('StickerCreator--Toasts--errorProcessing');
}

View File

@ -37,6 +37,7 @@ const WebAPI = initializeWebAPI({
certificateAuthority: config.certificateAuthority,
contentProxyUrl: config.contentProxyUrl,
proxyUrl: config.proxyUrl,
version: config.version,
});
window.convertToWebp = async (path, width = 512, height = 512) => {