Skip to content

Commit

Permalink
Make the editor opening on startup configurable - fixes #112
Browse files Browse the repository at this point in the history
  • Loading branch information
mykter committed Dec 17, 2017
1 parent 44de979 commit fce9a52
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
11 changes: 10 additions & 1 deletion src/main-process/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export enum ConfigName {
pingFileStart = "pingFileStart",
period = "period",
seed = "seed",
cancelTags = "cancelTags"
cancelTags = "cancelTags",
editorOnStartup = "editorOnStartup"
}
export interface ConfigDict {
[index: string]: any;
Expand All @@ -25,6 +26,7 @@ export interface ConfigDict {
period: number;
seed: number;
cancelTags: Set<string>;
editorOnStartup: boolean;
}

export interface ConfigPref {
Expand Down Expand Up @@ -189,6 +191,13 @@ export class Config {
label: "The tags to use when not supplied by the user for any reason",
configurable: true,
default: ["afk", "RETRO"]
},
{
name: ConfigName.editorOnStartup,
type: "checkbox",
label: "Open the tag editor on startup if pings have been missed since last run",
configurable: true,
default: false
}
];
}
3 changes: 2 additions & 1 deletion src/main-process/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import windowStateKeeper = require("electron-window-state");
import * as helper from "./helper";
import * as edit from "./edit";
import { Ping } from "../ping";
import { ConfigName } from "./config";

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

Expand Down
25 changes: 17 additions & 8 deletions src/preferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,24 @@ export const PrefGroup = (props: PrefGroupProps) => {
if (isFormControl) {
inProps["className"] = "form-control";
}
let type = props.pref.type;
if (props.pref.type === "file") {
type = "input";
inProps["className"] =
("className" in inProps ? inProps["className"] + " " : "") + "file-input";
}
if (props.pref.type === "tags") {
type = "input";

let type;
switch (props.pref.type) {
case "file": {
type = "input";
inProps["className"] =
("className" in inProps ? inProps["className"] + " " : "") + "file-input";
break;
}
case "tags": {
type = "input";
break;
}
default: {
type = props.pref.type;
}
}

return (
<input
readOnly={readOnly}
Expand Down

0 comments on commit fce9a52

Please sign in to comment.