Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: zoom level on servers #2770

Merged
merged 4 commits into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 18 additions & 33 deletions src/ui/main/menuBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ const selectViewDeps = createStructuredSelector<
rootWindowState: ({ rootWindowState }) => rootWindowState,
});

const getCurrentViewWebcontents = async () => {
const browserWindow = await getRootWindow();

if (!browserWindow.isVisible()) {
browserWindow.showInactive();
}
browserWindow.focus();
const currentView = select(({ currentView }) => currentView);
const url = typeof currentView === 'object' ? currentView.url : null;
if (!url) {
return null;
}
return getWebContentsByServerUrl(url);
};

const createViewMenu = createSelector(
selectViewDeps,
({
Expand Down Expand Up @@ -376,17 +391,7 @@ const createViewMenu = createSelector(
label: t('menus.resetZoom'),
accelerator: 'CommandOrControl+0',
click: async () => {
const browserWindow = await getRootWindow();

if (!browserWindow.isVisible()) {
browserWindow.showInactive();
}
browserWindow.focus();
const url = typeof currentView === 'object' ? currentView.url : null;
if (!url) {
return;
}
const guestWebContents = getWebContentsByServerUrl(url);
const guestWebContents = await getCurrentViewWebcontents();
guestWebContents?.setZoomLevel(0);
},
},
Expand All @@ -395,16 +400,7 @@ const createViewMenu = createSelector(
label: t('menus.zoomIn'),
accelerator: 'CommandOrControl+Plus',
click: async () => {
const browserWindow = await getRootWindow();
if (!browserWindow.isVisible()) {
browserWindow.showInactive();
}
browserWindow.focus();
const url = typeof currentView === 'object' ? currentView.url : null;
if (!url) {
return;
}
const guestWebContents = getWebContentsByServerUrl(url);
const guestWebContents = await getCurrentViewWebcontents();
if (!guestWebContents) {
return;
}
Expand All @@ -421,21 +417,10 @@ const createViewMenu = createSelector(
label: t('menus.zoomOut'),
accelerator: 'CommandOrControl+-',
click: async () => {
const browserWindow = await getRootWindow();
if (!browserWindow.isVisible()) {
browserWindow.showInactive();
}
browserWindow.focus();
const url = typeof currentView === 'object' ? currentView.url : null;
if (!url) {
return;
}

const guestWebContents = getWebContentsByServerUrl(url);
const guestWebContents = await getCurrentViewWebcontents();
if (!guestWebContents) {
return;
}

const zoomLevel = guestWebContents.getZoomLevel();
if (zoomLevel <= -9) {
return;
Expand Down
Loading