[MM-36347] Force max window width of 700px (#1720)
This commit is contained in:
@@ -52,6 +52,6 @@ window.addEventListener('message', async (event) => {
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.on(UPDATE_TEAMS_DROPDOWN, (event, teams, activeTeam, darkMode, enableServerManagement, hasGPOTeams, expired, mentions, unreads) => {
|
||||
window.postMessage({type: UPDATE_TEAMS_DROPDOWN, data: {teams, activeTeam, darkMode, enableServerManagement, hasGPOTeams, expired, mentions, unreads}}, window.location.href);
|
||||
ipcRenderer.on(UPDATE_TEAMS_DROPDOWN, (event, teams, activeTeam, darkMode, enableServerManagement, hasGPOTeams, expired, mentions, unreads, windowBounds) => {
|
||||
window.postMessage({type: UPDATE_TEAMS_DROPDOWN, data: {teams, activeTeam, darkMode, enableServerManagement, hasGPOTeams, expired, mentions, unreads, windowBounds}}, window.location.href);
|
||||
});
|
||||
|
@@ -31,6 +31,7 @@ export default class TeamDropdownView {
|
||||
mentions?: Map<string, number>;
|
||||
expired?: Map<string, boolean>;
|
||||
window: BrowserWindow;
|
||||
windowBounds: Electron.Rectangle;
|
||||
|
||||
constructor(window: BrowserWindow, teams: TeamWithTabs[], darkMode: boolean, enableServerManagement: boolean) {
|
||||
this.teams = teams;
|
||||
@@ -38,6 +39,8 @@ export default class TeamDropdownView {
|
||||
this.darkMode = darkMode;
|
||||
this.enableServerManagement = enableServerManagement;
|
||||
|
||||
this.windowBounds = this.window.getContentBounds();
|
||||
|
||||
const preload = getLocalPreload('dropdown.js');
|
||||
this.view = new BrowserView({webPreferences: {
|
||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
||||
@@ -77,6 +80,11 @@ export default class TeamDropdownView {
|
||||
this.updateDropdown();
|
||||
}
|
||||
|
||||
updateWindowBounds = () => {
|
||||
this.windowBounds = this.window.getContentBounds();
|
||||
this.updateDropdown();
|
||||
}
|
||||
|
||||
updateDropdown = () => {
|
||||
this.view.webContents.send(
|
||||
UPDATE_TEAMS_DROPDOWN,
|
||||
@@ -88,6 +96,7 @@ export default class TeamDropdownView {
|
||||
this.expired,
|
||||
this.mentions,
|
||||
this.unreads,
|
||||
this.windowBounds,
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,7 @@ import {CombinedConfig} from 'types/config';
|
||||
import {SavedWindowState} from 'types/mainWindow';
|
||||
|
||||
import {SELECT_NEXT_TAB, SELECT_PREVIOUS_TAB, GET_FULL_SCREEN_STATUS} from 'common/communication';
|
||||
import {DEFAULT_WINDOW_HEIGHT, DEFAULT_WINDOW_WIDTH, MINIMUM_WINDOW_HEIGHT, MINIMUM_WINDOW_WIDTH} from 'common/utils/constants';
|
||||
|
||||
import * as Validator from '../Validator';
|
||||
import ContextMenu from '../contextMenu';
|
||||
@@ -37,11 +38,6 @@ function isFramelessWindow() {
|
||||
}
|
||||
|
||||
function createMainWindow(config: CombinedConfig, options: {linuxAppIcon: string}) {
|
||||
const defaultWindowWidth = 1000;
|
||||
const defaultWindowHeight = 700;
|
||||
const minimumWindowWidth = 400;
|
||||
const minimumWindowHeight = 240;
|
||||
|
||||
// Create the browser window.
|
||||
const preload = getLocalPreload('mainWindow.js');
|
||||
const boundsInfoPath = path.join(app.getPath('userData'), 'bounds-info.json');
|
||||
@@ -54,7 +50,7 @@ function createMainWindow(config: CombinedConfig, options: {linuxAppIcon: string
|
||||
}
|
||||
} catch (e) {
|
||||
// Follow Electron's defaults, except for window dimensions which targets 1024x768 screen resolution.
|
||||
savedWindowState = {width: defaultWindowWidth, height: defaultWindowHeight};
|
||||
savedWindowState = {width: DEFAULT_WINDOW_WIDTH, height: DEFAULT_WINDOW_HEIGHT};
|
||||
}
|
||||
|
||||
const {maximized: windowIsMaximized} = savedWindowState;
|
||||
@@ -66,8 +62,8 @@ function createMainWindow(config: CombinedConfig, options: {linuxAppIcon: string
|
||||
fullscreenable: true,
|
||||
show: false, // don't start the window until it is ready and only if it isn't hidden
|
||||
paintWhenInitiallyHidden: true, // we want it to start painting to get info from the webapp
|
||||
minWidth: minimumWindowWidth,
|
||||
minHeight: minimumWindowHeight,
|
||||
minWidth: MINIMUM_WINDOW_WIDTH,
|
||||
minHeight: MINIMUM_WINDOW_HEIGHT,
|
||||
frame: !isFramelessWindow(),
|
||||
fullscreen: savedWindowState.fullscreen,
|
||||
titleBarStyle: 'hidden' as const,
|
||||
|
@@ -184,6 +184,7 @@ function handleResizeMainWindow() {
|
||||
setBoundsFunction();
|
||||
}
|
||||
status.viewManager.setLoadingScreenBounds();
|
||||
status.teamDropdown?.updateWindowBounds();
|
||||
}
|
||||
|
||||
export function sendToRenderer(channel: string, ...args: any[]) {
|
||||
|
Reference in New Issue
Block a user