Skip to content

Commit 56ad62a

Browse files
authored
extract global state keys (#699)
Signed-off-by: Yan Zhang <[email protected]>
1 parent 699517f commit 56ad62a

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

src/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { initialize as initCommands } from "./commands";
88
import { initialize as initRecommendations } from "./recommendation";
99
import { showReleaseNotesOnStart, HelpViewType } from "./misc";
1010
import { initialize as initExp } from "./exp";
11-
import { KEY_SHOW_WHEN_USING_JAVA, OverviewViewSerializer } from "./overview";
11+
import { OverviewViewSerializer } from "./overview";
1212
import { JavaRuntimeViewSerializer, validateJavaRuntime } from "./java-runtime";
1313
import { scheduleAction } from "./utils/scheduler";
1414
import { showWelcomeWebview, WelcomeViewSerializer } from "./welcome";
@@ -18,6 +18,7 @@ import { ClassPathConfigurationViewSerializer } from "./classpath/classpathConfi
1818
import { initFormatterSettingsEditorProvider } from "./formatter-settings";
1919
import { initRemoteProfileProvider } from "./formatter-settings/RemoteProfileProvider";
2020
import { CodeActionProvider } from "./providers/CodeActionProvider";
21+
import { KEY_SHOW_WHEN_USING_JAVA } from "./utils/globalState";
2122

2223
export async function activate(context: vscode.ExtensionContext) {
2324
syncState(context);

src/misc/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
import { RELEASE_NOTE_PRESENTATION_HISTORY } from "../utils/globalState";
45
import * as vscode from "vscode";
56
import { getReleaseNotesEntries, findLatestReleaseNotes, timeToString, getExtensionVersion } from "../utils";
67

@@ -12,7 +13,6 @@ export enum HelpViewType {
1213
}
1314

1415
type ReleaseNotesPresentationHistoryEntry = { version: string, timeStamp: string };
15-
const RELEASE_NOTE_PRESENTATION_HISTORY = "releaseNotesPresentationHistory";
1616

1717
export async function showReleaseNotesOnStart(context: vscode.ExtensionContext) {
1818
const entries = await getReleaseNotesEntries(context);

src/overview/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
// Licensed under the MIT license.
33

44
import * as vscode from "vscode";
5-
65
import * as path from "path";
7-
86
import { instrumentOperation, sendInfo } from "vscode-extension-telemetry-wrapper";
9-
import { getExtensionContext } from "../utils";
10-
import { loadTextFromFile } from "../utils";
7+
import { getExtensionContext, loadTextFromFile } from "../utils";
8+
import { KEY_OVERVIEW_LAST_SHOW_TIME, KEY_SHOW_WHEN_USING_JAVA } from "../utils/globalState";
119

1210
let overviewView: vscode.WebviewPanel | undefined;
13-
export const KEY_SHOW_WHEN_USING_JAVA = "showWhenUsingJava";
14-
const KEY_OVERVIEW_LAST_SHOW_TIME = "overviewLastShowTime";
1511

1612
const toggleOverviewVisibilityOperation = instrumentOperation("toggleOverviewVisibility", (operationId: string, context: vscode.ExtensionContext, visibility: boolean) => {
1713
sendInfo(operationId, {

src/recommendation/handler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
// Licensed under the MIT license.
33

44
import * as vscode from "vscode";
5-
65
import { sendInfo } from "vscode-extension-telemetry-wrapper";
76
import { instrumentCommand } from "../utils";
87
import { isExtensionInstalled, recommendExtension } from "../utils";
8+
import { KEY_RECOMMENDATION_TIMESTAMP_MAP } from "../utils/globalState";
99

10-
const KEY_RECOMMENDATION_TIMESTAMP_MAP = "recommendationTimeStampMap";
1110

1211
let handler: (...args: any[]) => any;
1312

src/utils/globalState.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
export const KEY_RECOMMENDATION_TIMESTAMP_MAP = "recommendationTimeStampMap";
5+
6+
// first view (shared)
7+
export const KEY_SHOW_WHEN_USING_JAVA = "showWhenUsingJava";
8+
// overview
9+
export const KEY_OVERVIEW_LAST_SHOW_TIME = "overviewLastShowTime";
10+
// welcome
11+
export const KEY_IS_WELCOME_PAGE_VIEWED = "isWelcomePageViewed";
12+
13+
// release note (inactive)
14+
export const RELEASE_NOTE_PRESENTATION_HISTORY = "releaseNotesPresentationHistory";

src/welcome/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import * as vscode from "vscode";
55
import * as path from "path";
66
import { getExtensionContext, loadTextFromFile } from "../utils";
77
import { instrumentSimpleOperation, sendInfo } from "vscode-extension-telemetry-wrapper";
8+
import { KEY_SHOW_WHEN_USING_JAVA, KEY_IS_WELCOME_PAGE_VIEWED } from "../utils/globalState";
89

9-
const KEY_SHOW_WHEN_USING_JAVA = "showWhenUsingJava";
10-
const KEY_IS_WELCOME_PAGE_VIEWED = "isWelcomePageViewed";
1110
let welcomeView: vscode.WebviewPanel | undefined;
1211

1312
export async function showWelcomeWebview(context: vscode.ExtensionContext, _operationId?: string, options?: any) {

0 commit comments

Comments
 (0)