Skip to content

Commit 32db551

Browse files
committed
Merge branch 'hotfix/1.4.1'
2 parents 5f3681d + 00e7bd7 commit 32db551

4 files changed

Lines changed: 26 additions & 35 deletions

File tree

src/data/Storage.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
import { DefaultQuickActions, DefaultSettings, IsDebug, Permission, QuickAction, Settings } from '@/data/Constants';
22
import { PlainPage } from '@/model/Page';
33
import PreferencesService from '@/service/PreferencesService';
4-
import { app, safeStorage, session } from 'electron';
4+
import { app, Rectangle, safeStorage, session } from 'electron';
55
import Store from 'electron-store';
66

7-
/**
8-
* Bounds interface for window dimensions
9-
*/
10-
interface Bounds {
11-
width: number;
12-
height: number;
13-
x?: number;
14-
y?: number;
15-
}
16-
177
type AllPermissions = Record<string, SessionPermissions>;
188
type SessionPermissions = Record<string, UrlPermissions>;
199
type UrlPermissions = Record<string, PermissionStatus>;
@@ -97,30 +87,34 @@ class Vault {
9787
* Storage class - manages application data persistence
9888
*/
9989
class Storage {
100-
static getSharedBounds(): Bounds {
90+
static getSharedBounds(): Rectangle {
10191
return Vault.get('SharedBounds', {
10292
width: Storage.getSettings(Settings.DEFAULT_WIDTH),
10393
height: Storage.getSettings(Settings.DEFAULT_HEIGHT),
104-
} as Bounds)!;
94+
x: 0,
95+
y: 0,
96+
})!;
10597
}
10698

10799
static getSharedSize(): { width: number; height: number } {
108100
const bounds = Storage.getSharedBounds();
109101
return { width: bounds.width, height: bounds.height };
110102
}
111103

112-
static setSharedBounds(value: Bounds): void {
104+
static setSharedBounds(value: Rectangle): void {
113105
Vault.set('SharedBounds', value);
114106
}
115107

116-
static getWindowBounds(id: string | number): Bounds {
108+
static getWindowBounds(id: string | number): Rectangle {
117109
return Vault.get(`WindowBounds.${id}`, {
118110
width: Storage.getSettings(Settings.DEFAULT_WIDTH),
119111
height: Storage.getSettings(Settings.DEFAULT_HEIGHT),
120-
} as Bounds)!;
112+
x: 0,
113+
y: 0,
114+
})!;
121115
}
122116

123-
static setWindowBounds(id: string | number, value: Bounds): void {
117+
static setWindowBounds(id: string | number, value: Rectangle): void {
124118
Vault.set(`WindowBounds.${id}`, value);
125119
}
126120

@@ -150,11 +144,13 @@ class Storage {
150144
Storage.setPages(pages);
151145
}
152146

153-
static getDefaultSize(): Bounds {
147+
static getDefaultSize(): Rectangle {
154148
return {
155149
width: Storage.getSettings(Settings.DEFAULT_WIDTH),
156150
height: Storage.getSettings(Settings.DEFAULT_HEIGHT),
157-
} as Bounds;
151+
x: 0,
152+
y: 0,
153+
};
158154
}
159155

160156
static getPermissions(

src/service/FrameService.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,15 @@ class FrameService {
8181
this.getFrame()!.emit('blur');
8282
}
8383

84-
private getOrCreateFrame(): BaseWindow {
85-
if (!this.getFrame()) { this.createFrame(); }
86-
return this.getFrame()!;
87-
}
88-
89-
private createFrame() {
84+
private createFrame(): BaseWindow {
9085
const frame = new BaseWindow(this.getFrameOptions());
9186
frame.setContentProtection(AppState.contentProtection);
9287
frame.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
9388
WindowUtil.setDefaultAlwaysOnTopSettings(frame);
9489
const fps = Storage.getSettings(Settings.DRAG_REFRESH_RATE) as number || null;
9590
Draggable.from(frame, { maximize: true, fps });
96-
if (Storage.getSettings<boolean>(Settings.SHARE_BOUNDS)) {
97-
const sharedBounds = Storage.getSharedBounds();
98-
sharedBounds && frame.setBounds(sharedBounds);
99-
}
10091
AppState.frame = frame;
92+
return frame;
10193
}
10294

10395
private registerStateListeners(): void {
@@ -254,12 +246,16 @@ class FrameService {
254246

255247
if (newView === oldView) { return; }
256248

257-
const frame = this.getOrCreateFrame();
249+
let frame = this.getFrame();
250+
const hasFrame = !!frame;
251+
252+
!frame && (frame = this.createFrame());
253+
258254
oldView && frame.contentView.removeChildView(oldView);
259255
oldView?.emit('detached');
260256
this.setupNavbarForCurrentPage();
261257

262-
if (!Storage.getSettings<boolean>(Settings.SHARE_BOUNDS)) {
258+
if (!hasFrame || !Storage.getSettings<boolean>(Settings.SHARE_BOUNDS)) {
263259
frame.isMaximized() && frame.unmaximize();
264260
const bounds = PageService.getPageBounds(page);
265261
frame.setBounds(bounds);

src/service/NavbarService.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ class NavbarService {
4141
}
4242

4343
private getCurrentUrl(): string {
44-
const currentView = PageService.getCurrentView();
45-
return currentView ? currentView.webContents.getURL() : '';
44+
return PageService.getCurrentView()?.webContents.getURL() || PageService.getCurrentHomeUrl();
4645
}
4746

4847
public sendLabel(label = AppState.currentPage!.label): void {
@@ -78,7 +77,7 @@ class NavbarService {
7877
private sendDidNavigate(): void {
7978
const wc = PageService.getCurrentView()!.webContents;
8079
NavbarPropagator.sendToRender('did-navigate', {
81-
url: this.getCurrentUrl() || PageService.getCurrentHomeUrl(),
80+
url: this.getCurrentUrl(),
8281
canGoBack: wc.navigationHistory.canGoBack(),
8382
canGoForward: wc.navigationHistory.canGoForward(),
8483
});

src/service/PageService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class PageService {
290290
* @returns Window bounds.
291291
*/
292292
private getBoundsForDefaultPosition(windowSize: Size): Rectangle {
293-
const bounds = { width: windowSize.width, height: windowSize.height } as Rectangle;
293+
const bounds = { width: windowSize.width, height: windowSize.height, x: 0, y: 0 };
294294

295295
// Get user position preference
296296
const position = Storage.getSettings(Settings.DEFAULT_POSITION);

0 commit comments

Comments
 (0)