Skip to content
This repository was archived by the owner on Apr 9, 2025. It is now read-only.

Commit fce9a52

Browse files
committed
Make the editor opening on startup configurable - fixes #112
1 parent 44de979 commit fce9a52

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

src/main-process/config.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export enum ConfigName {
1313
pingFileStart = "pingFileStart",
1414
period = "period",
1515
seed = "seed",
16-
cancelTags = "cancelTags"
16+
cancelTags = "cancelTags",
17+
editorOnStartup = "editorOnStartup"
1718
}
1819
export interface ConfigDict {
1920
[index: string]: any;
@@ -25,6 +26,7 @@ export interface ConfigDict {
2526
period: number;
2627
seed: number;
2728
cancelTags: Set<string>;
29+
editorOnStartup: boolean;
2830
}
2931

3032
export interface ConfigPref {
@@ -189,6 +191,13 @@ export class Config {
189191
label: "The tags to use when not supplied by the user for any reason",
190192
configurable: true,
191193
default: ["afk", "RETRO"]
194+
},
195+
{
196+
name: ConfigName.editorOnStartup,
197+
type: "checkbox",
198+
label: "Open the tag editor on startup if pings have been missed since last run",
199+
configurable: true,
200+
default: false
192201
}
193202
];
194203
}

src/main-process/prompts.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import windowStateKeeper = require("electron-window-state");
55
import * as helper from "./helper";
66
import * as edit from "./edit";
77
import { Ping } from "../ping";
8+
import { ConfigName } from "./config";
89

910
// Global reference to prevent garbage collection
1011
let promptWindow: Electron.BrowserWindow | null;
@@ -166,7 +167,7 @@ export function catchUp(till: number): boolean {
166167
* Show an editor if the time is after the next ping in the pingfile
167168
*/
168169
export function editorIfMissed() {
169-
if (global.pingFile.pings.length === 0) {
170+
if (!global.config.user.get(ConfigName.editorOnStartup) || global.pingFile.pings.length === 0) {
170171
return;
171172
}
172173

src/preferences.tsx

+17-8
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,24 @@ export const PrefGroup = (props: PrefGroupProps) => {
2222
if (isFormControl) {
2323
inProps["className"] = "form-control";
2424
}
25-
let type = props.pref.type;
26-
if (props.pref.type === "file") {
27-
type = "input";
28-
inProps["className"] =
29-
("className" in inProps ? inProps["className"] + " " : "") + "file-input";
30-
}
31-
if (props.pref.type === "tags") {
32-
type = "input";
25+
26+
let type;
27+
switch (props.pref.type) {
28+
case "file": {
29+
type = "input";
30+
inProps["className"] =
31+
("className" in inProps ? inProps["className"] + " " : "") + "file-input";
32+
break;
33+
}
34+
case "tags": {
35+
type = "input";
36+
break;
37+
}
38+
default: {
39+
type = props.pref.type;
40+
}
3341
}
42+
3443
return (
3544
<input
3645
readOnly={readOnly}

0 commit comments

Comments
 (0)