Skip to content

Commit 53d9c84

Browse files
committed
enable new "left-thin" account handle buttons layout mode, #175
1 parent 13eb4a2 commit 53d9c84

21 files changed

+183
-157
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The way of verifying that the installation packages attached to the [releases](h
4040
- :bell: **System tray icon** with a total number of unread messages shown on top of it. Enabling [local messages store](https://github.com/vladimiry/ElectronMail/issues/32) improves this feature ([how to enable](https://github.com/vladimiry/ElectronMail/releases/tag/v2.0.0-beta.1)), see respective [issue](https://github.com/vladimiry/ElectronMail/issues/30).
4141
- :gear: **Starting minimized to tray**.
4242
- :gear: **Closing to tray**.
43-
- :gear: **Switchable accounts handle buttons positioning** (vertical, horizontal and horizontal-dropdown). See details [here](https://github.com/vladimiry/ElectronMail/issues/36) and screenshots in the [images](images) folder.
43+
- :gear: **Switchable accounts handle buttons positioning** (`top` , `left`, `left-thin`). See details in [#36](https://github.com/vladimiry/ElectronMail/issues/36) and [#175](https://github.com/vladimiry/ElectronMail/issues/175). Demo screenshots placed in the [images](images) folder (specifically [this](images/controls-view-modes-(top-left-left_thing).gif) image).
4444
- :package: **Batch emails export** to EML files. Feature released with [v2.0.0-beta.4](https://github.com/vladimiry/ElectronMail/releases/tag/v2.0.0-beta.4) version, requires `local messages store` feature to be enabled ([how to enable](https://github.com/vladimiry/ElectronMail/releases/tag/v2.0.0-beta.1)).
4545
- :closed_lock_with_key: **Built-in/prepackaged web clients**. The built-in web clients are built from source code, see respective official [Protonmail](https://github.com/ProtonMail/WebClient) repository. See [79](https://github.com/vladimiry/ElectronMail/issues/79) and [80](https://github.com/vladimiry/ElectronMail/issues/80) issues for details.
4646
- :gear: **Configuring proxy per account** support. Enabled since [v3.0.0](https://github.com/vladimiry/ElectronMail/releases/tag/v3.0.0) release. See [113](https://github.com/vladimiry/ElectronMail/issues/113) and [120](https://github.com/vladimiry/ElectronMail/issues/120) issues for details.
219 KB
Loading

src/electron-main/__test__/api/index.spec.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -350,15 +350,15 @@ const tests: Record<keyof TestContext["endpoints"], (t: ExecutionContext<TestCon
350350
const patches: Array<Partial<BaseConfig>> = [
351351
{
352352
startHidden: false,
353-
compactLayout: true,
353+
layoutMode: "top",
354354
closeToTray: false,
355355
unreadNotifications: true,
356356
checkUpdateAndNotify: true,
357357
logLevel: "warn",
358358
},
359359
{
360360
startHidden: true,
361-
compactLayout: undefined,
361+
layoutMode: undefined,
362362
closeToTray: true,
363363
unreadNotifications: false,
364364
checkUpdateAndNotify: false,
@@ -446,21 +446,6 @@ const tests: Record<keyof TestContext["endpoints"], (t: ExecutionContext<TestCon
446446
await readConfigAndSettings(t.context.endpoints, {password: OPTIONS.masterPassword});
447447
t.true(await t.context.ctx.settingsStore.readable(), "store: settings file exists");
448448
},
449-
450-
toggleCompactLayout: async (t) => {
451-
const endpoints = t.context.endpoints;
452-
const action = endpoints.toggleCompactLayout;
453-
454-
const config1 = await readConfig(endpoints);
455-
t.true(config1.compactLayout);
456-
457-
const config2 = await action();
458-
t.is(config2.compactLayout, !config1.compactLayout);
459-
460-
await action();
461-
const config3 = await t.context.ctx.configStore.readExisting();
462-
t.is(config3.compactLayout, !config2.compactLayout);
463-
},
464449
};
465450

466451
Object.entries(tests).forEach(([apiMethodName, method]) => {

src/electron-main/api/index.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,6 @@ export const initApi = async (ctx: Context): Promise<IpcMainApiEndpoints> => {
321321
return ctx.settingsStore.readable();
322322
},
323323

324-
async toggleCompactLayout() {
325-
const config = await ctx.configStore.readExisting();
326-
327-
return ctx.configStore.write({
328-
...config,
329-
compactLayout: !config.compactLayout,
330-
});
331-
},
332-
333324
async generateTOTPToken({secret}) {
334325
return {
335326
token: authenticator.generate(secret),

src/electron-main/storage-upgrade.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {INITIAL_STORES, PLATFORM} from "./constants";
1414
import {IPC_MAIN_API_NOTIFICATION$} from "src/electron-main/api/constants";
1515
import {IPC_MAIN_API_NOTIFICATION_ACTIONS} from "src/shared/api/main";
1616
import {
17+
LAYOUT_MODES,
1718
ONE_SECOND_MS,
1819
PACKAGE_VERSION,
1920
PROTON_API_ENTRY_PRIMARY_VALUE,
@@ -288,6 +289,24 @@ const CONFIG_UPGRADES: Record<string, (config: Config) => void> = {
288289
});
289290
});
290291
})();
292+
293+
(() => {
294+
const key: keyof Pick<Config, "layoutMode"> = "layoutMode";
295+
296+
if (LAYOUT_MODES.some(({value}) => value === config[key])) {
297+
return;
298+
}
299+
300+
type PrevConfig = Config & { compactLayout?: boolean };
301+
const compactLayout = (config as PrevConfig).compactLayout;
302+
delete (config as PrevConfig).compactLayout;
303+
304+
config[key] = typeof compactLayout === "boolean"
305+
? compactLayout
306+
? "top"
307+
: "left"
308+
: INITIAL_STORES.config()[key];
309+
})();
291310
},
292311
// WARN needs to be the last updater
293312
"100.0.0": (config) => {

src/shared/api/main.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ export const ENDPOINTS_DEFINITION = {
111111

112112
toggleBrowserWindow: ActionType.Promise<{ forcedState: boolean } | void>(),
113113

114-
toggleCompactLayout: ActionType.Promise<void, Config>(),
115-
116114
updateOverlayIcon: ActionType.Promise<{
117115
hasLoggedOut: boolean;
118116
unread: number;

src/shared/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ export const ZOOM_FACTORS: ReadonlyArray<number> = [
188188
2,
189189
];
190190

191+
export const LAYOUT_MODES = [
192+
{value: "top", title: "top"},
193+
{value: "left", title: "left"},
194+
{value: "left-thin", title: "left (thin)"},
195+
] as const;
191196

192197
export const WEB_VIEW_SESSION_STORAGE_KEY_SKIP_LOGIN_DELAYS = "ELECTRON_MAIL_SKIP_LOGIN_DELAYS";
193198

src/shared/model/options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface Config extends BaseConfig, Partial<StoreModel.StoreEntity> {
4141
// base
4242
checkUpdateAndNotify: boolean;
4343
closeToTray: boolean;
44-
compactLayout: boolean;
44+
layoutMode: (typeof import("src/shared/constants").LAYOUT_MODES)[number]["value"];
4545
customTrayIconColor: string;
4646
customUnreadBgColor: string;
4747
customUnreadTextColor: string;
@@ -60,7 +60,7 @@ export interface Config extends BaseConfig, Partial<StoreModel.StoreEntity> {
6060
export type BaseConfig = Pick<Config,
6161
| "checkUpdateAndNotify"
6262
| "closeToTray"
63-
| "compactLayout"
63+
| "layoutMode"
6464
| "customTrayIconColor"
6565
| "customUnreadBgColor"
6666
| "customUnreadTextColor"

src/shared/util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function initialConfig(): Config {
6363
// base
6464
checkUpdateAndNotify: false,
6565
closeToTray: true,
66-
compactLayout: true,
66+
layoutMode: "top",
6767
customTrayIconColor: "",
6868
customUnreadBgColor: "",
6969
customUnreadTextColor: "",
@@ -85,7 +85,7 @@ export function pickBaseConfigProperties(
8585
{
8686
checkUpdateAndNotify,
8787
closeToTray,
88-
compactLayout,
88+
layoutMode,
8989
customTrayIconColor,
9090
customUnreadBgColor,
9191
customUnreadTextColor,
@@ -104,7 +104,7 @@ export function pickBaseConfigProperties(
104104
return {
105105
checkUpdateAndNotify,
106106
closeToTray,
107-
compactLayout,
107+
layoutMode,
108108
customTrayIconColor,
109109
customUnreadBgColor,
110110
customUnreadTextColor,

src/web/browser-window/app/_accounts/account-title.component.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[ngClass]="{'selected': state.selected, 'stored': state.stored, 'login-filled-once': state.account.loginFilledOnce}"
44
class="btn-group"
55
>
6-
<a class="btn btn-sm btn-secondary b-handle" href="mailto:{{ state.account.accountConfig.login }}">
6+
<a class="btn btn-sm btn-secondary" href="mailto:{{ state.account.accountConfig.login }}">
77
<electron-mail-unread-badge
88
*ngIf="state.account.notifications.unread"
99
[value]="state.account.notifications.unread"
@@ -14,16 +14,14 @@
1414
</div>
1515
<div *ngIf="state.loginDelayed" class="d-flex mr-2 login-delay">
1616
<i *ngIf="state.account.loginDelayedUntilSelected" class="fa fa-hand-pointer-o mr-1"></i>
17-
<span *ngIf="state.account.loginDelayedSeconds; let remainingSeconds">{{ remainingSeconds }}</span>
18-
</div>
19-
<div class="d-flex flex-grow-1">
20-
{{ state.account.accountConfig.title || state.account.accountConfig.login }}
17+
<span class="letters" *ngIf="state.account.loginDelayedSeconds; let remainingSeconds">{{ remainingSeconds }}</span>
2118
</div>
19+
<div class="d-flex flex-grow-1 letters login">{{ state.account.accountConfig.title || state.account.accountConfig.login }}</div>
2220
</a>
2321
<button
2422
(click)="toggleViewMode($event)"
2523
*ngIf="state.stored"
26-
class="btn btn-sm btn-secondary b-toggle-view"
24+
class="btn btn-sm btn-secondary"
2725
title="Toggle online/database view mode"
2826
>
2927
<i

0 commit comments

Comments
 (0)