diff options
| author | Christoph Schlosser <christoph@linux.com> | 2018-03-02 21:34:02 +0100 |
|---|---|---|
| committer | Christoph Schlosser <christophschlosser@users.noreply.github.com> | 2018-03-02 21:42:35 +0100 |
| commit | b837545df65a31ba5dac154644c359c2a55d1531 (patch) | |
| tree | 4160556a5d8fa2a1ee8d08419e939c6596b1c514 | |
| parent | 67d19d44cee92facc0f0dfd1514706f5b7f3a2fa (diff) | |
| download | doxdocgen-b837545df65a31ba5dac154644c359c2a55d1531.tar.gz | |
Add config changed notification
| -rw-r--r-- | package.json | 3 | ||||
| -rw-r--r-- | src/extension.ts | 25 |
2 files changed, 27 insertions, 1 deletions
diff --git a/package.json b/package.json index cb5db10..0ba91da 100644 --- a/package.json +++ b/package.json @@ -193,7 +193,8 @@ "test": "npm run compile && node ./node_modules/vscode/bin/test" }, "dependencies": { - "moment": "^2.20.1" + "moment": "^2.20.1", + "opn": "^5.2.0" }, "devDependencies": { "@types/mocha": "^2.2.48", diff --git a/src/extension.ts b/src/extension.ts index a5510dc..52ecbf8 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,13 +1,38 @@ "use strict"; // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below +import * as opn from "opn"; import * as vscode from "vscode"; import CodeParserController from "./CodeParserController"; +enum ConfigChangedNotificationOptions { + CHANGED = "What's changed", + HIDE = "Don't show me again", + GLOBAL_STORAGE_KEY = "doxdocgen_hide_config_changed_notification", +} + // this method is called when your extension is activated // your extension is activated the very first time the command is executed export function activate(context: vscode.ExtensionContext) { const parser = new CodeParserController(); context.subscriptions.push(parser); + + let notificationHideThenable: Thenable<string>; + const active = context.globalState.get<string>(ConfigChangedNotificationOptions.GLOBAL_STORAGE_KEY); + if (active === undefined || active !== "false") { + // tslint:disable-next-line:max-line-length + notificationHideThenable = vscode.window.showWarningMessage("DoxDocGen: Config keys have changed. Please check your config!", ConfigChangedNotificationOptions.CHANGED, ConfigChangedNotificationOptions.HIDE); + } + + if (notificationHideThenable !== undefined) { + notificationHideThenable.then((action) => { + if (action === ConfigChangedNotificationOptions.CHANGED) { + // tslint:disable-next-line:max-line-length + opn("https://github.com/christophschlosser/doxdocgen/commit/1c844758719d8dc7d538585bb4393565e5629e84#diff-b9cfc7f2cdf78a7f4b91a753d10865a2"); + } else if (action === ConfigChangedNotificationOptions.HIDE) { + context.globalState.update(ConfigChangedNotificationOptions.GLOBAL_STORAGE_KEY, "false"); + } + }); + } } |