From fdc30d003a424f6df5cbae1c8e1f2f66951c1414 Mon Sep 17 00:00:00 2001 From: Chen-I Lim Date: Thu, 15 Oct 2020 11:59:56 -0700 Subject: [PATCH] minor cleanup --- src/client/components/boardComponent.tsx | 2 +- src/client/components/cardDialog.tsx | 4 ++-- src/client/filterClause.ts | 6 ++++-- src/client/mutator.ts | 27 +++++++++++------------- src/client/undomanager.ts | 13 +++++++----- tslint.json | 2 +- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/client/components/boardComponent.tsx b/src/client/components/boardComponent.tsx index ffdcfd5a5..03f0ec5e3 100644 --- a/src/client/components/boardComponent.tsx +++ b/src/client/components/boardComponent.tsx @@ -246,7 +246,7 @@ class BoardComponent extends React.Component { if (boardTree.groupByProperty) { card.properties[boardTree.groupByProperty.id] = groupByValue } - await mutator.insertBlock(card, "add card", async () => { await this.setState({shownCard: card}) }, async () => { await this.setState({shownCard: undefined}) }) + await mutator.insertBlock(card, "add card", async () => { this.setState({shownCard: card}) }, async () => { this.setState({shownCard: undefined}) }) } async propertyNameChanged(option: IPropertyOption, text: string) { diff --git a/src/client/components/cardDialog.tsx b/src/client/components/cardDialog.tsx index 5c46916a4..1a7a3c092 100644 --- a/src/client/components/cardDialog.tsx +++ b/src/client/components/cardDialog.tsx @@ -48,12 +48,12 @@ class CardDialog extends React.Component { this.cardListener = new OctoListener() this.cardListener.open(this.props.card.id, async () => { await cardTree.sync() - this.setState({cardTree: cardTree}) + this.setState({ cardTree }) }) const cardTree = new CardTree(this.props.card.id) cardTree.sync().then(() => { this.setState({cardTree}) - }); + }) document.addEventListener("keydown", this.keydownHandler) } diff --git a/src/client/filterClause.ts b/src/client/filterClause.ts index a2ab2270e..9f6fe67f9 100644 --- a/src/client/filterClause.ts +++ b/src/client/filterClause.ts @@ -13,9 +13,11 @@ class FilterClause { case "notIncludes": return "doesn't include" case "isEmpty": return "is empty" case "isNotEmpty": return "is not empty" + default: { + Utils.assertFailure() + return "(unknown)" + } } - Utils.assertFailure() - return "(unknown)" } constructor(o: any = {}) { diff --git a/src/client/mutator.ts b/src/client/mutator.ts index a52ce423c..3f61455fd 100644 --- a/src/client/mutator.ts +++ b/src/client/mutator.ts @@ -14,9 +14,6 @@ import { Utils } from "./utils" // It also ensures that the Undo-manager is called for each action // class Mutator { - constructor() { - } - async insertBlock(block: IBlock, description: string = "add", afterRedo?: () => Promise, beforeUndo?: () => Promise) { await undoManager.perform( async () => { @@ -510,21 +507,21 @@ class Mutator { return block } - async undo() { - await undoManager.undo() - } + async undo() { + await undoManager.undo() + } - undoDescription(): string | undefined { - return undoManager.undoDescription - } + undoDescription(): string | undefined { + return undoManager.undoDescription + } - async redo() { - await undoManager.redo() - } + async redo() { + await undoManager.redo() + } - redoDescription(): string | undefined { - return undoManager.redoDescription - } + redoDescription(): string | undefined { + return undoManager.redoDescription + } } const mutator = new Mutator() diff --git a/src/client/undomanager.ts b/src/client/undomanager.ts index 070939022..0389401eb 100644 --- a/src/client/undomanager.ts +++ b/src/client/undomanager.ts @@ -1,7 +1,7 @@ interface UndoCommand { checkpoint: number - undo: () => void - redo: () => void + undo: () => Promise + redo: () => Promise description?: string } @@ -54,8 +54,8 @@ class UndoManager { } async perform( - redo: () => void, - undo: () => void, + redo: () => Promise, + undo: () => Promise, description?: string, isDiscardable = false ): Promise { @@ -64,7 +64,10 @@ class UndoManager { } registerUndo( - command: { undo: () => void; redo: () => void }, + command: { + undo: () => Promise, + redo: () => Promise + }, description?: string, isDiscardable = false ): UndoManager { diff --git a/tslint.json b/tslint.json index 131103bec..1b206b4e6 100644 --- a/tslint.json +++ b/tslint.json @@ -6,7 +6,7 @@ "no-bitwise": true, "no-conditional-assignment": true, "no-consecutive-blank-lines": true, - "indent": [true, "tabs"], + "indent": [false, "tabs"], "member-access": [true, "no-public"], "semicolon": [true, "never"], "variable-name": [