Skip to content

Commit f656f85

Browse files
authored
fix: leetcode.hideSolved not working (#319)
1 parent 7c3e8cb commit f656f85

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

src/explorer/explorerNodeManager.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import * as _ from "lodash";
55
import { Disposable } from "vscode";
66
import * as list from "../commands/list";
7-
import { Category, defaultProblem } from "../shared";
7+
import { Category, defaultProblem, ProblemState } from "../shared";
8+
import { shouldHideSolvedProblem } from "../utils/settingUtils";
89
import { LeetCodeNode } from "./LeetCodeNode";
910

1011
class ExplorerNodeManager implements Disposable {
@@ -14,7 +15,11 @@ class ExplorerNodeManager implements Disposable {
1415

1516
public async refreshCache(): Promise<void> {
1617
this.dispose();
18+
const shouldHideSolved: boolean = shouldHideSolvedProblem();
1719
for (const problem of await list.listProblems()) {
20+
if (shouldHideSolved && problem.state === ProblemState.AC) {
21+
continue;
22+
}
1823
this.explorerNodeMap.set(problem.id, new LeetCodeNode(problem));
1924
for (const company of problem.companies) {
2025
this.companySet.add(company);

src/utils/settingUtils.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) jdneo. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
import { workspace, WorkspaceConfiguration } from "vscode";
5+
6+
export function getWorkspaceConfiguration(): WorkspaceConfiguration {
7+
return workspace.getConfiguration("leetcode");
8+
}
9+
10+
export function shouldHideSolvedProblem(): boolean {
11+
return getWorkspaceConfiguration().get<boolean>("hideSolved", false);
12+
}

src/utils/uiUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as vscode from "vscode";
55
import { getLeetCodeEndpoint } from "../commands/plugin";
66
import { leetCodeChannel } from "../leetCodeChannel";
7-
import { getWorkspaceConfiguration } from "./workspaceUtils";
7+
import { getWorkspaceConfiguration } from "./settingUtils";
88

99
export namespace DialogOptions {
1010
export const open: vscode.MessageItem = { title: "Open" };

src/utils/workspaceUtils.ts

-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,3 @@ export async function getActiveFilePath(uri?: vscode.Uri): Promise<string | unde
4040
}
4141
return wsl.useWsl() ? wsl.toWslPath(textEditor.document.uri.fsPath) : textEditor.document.uri.fsPath;
4242
}
43-
44-
export function getWorkspaceConfiguration(): vscode.WorkspaceConfiguration {
45-
return vscode.workspace.getConfiguration("leetcode");
46-
}

0 commit comments

Comments
 (0)