Skip to content

Commit 808ea42

Browse files
authored
Merge pull request #161 from ccagml/main
hideScore 配置变化时刷新题目列表
2 parents 495bd3a + 0991267 commit 808ea42

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

CHANGELOG.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
## version 2.12.3
2+
3+
- hideScore 配置变化时刷新题目列表
4+
15
## version 2.12.2
26

37
- 修复 使用${tag}作为文件夹名称不生效
48
- 更新 README.md
59

610
## version 2.12.1
711

8-
- 配置filePath文件名 增加 ${yyyymmdd}格式
9-
- 配置filePath文件名 增加 ${timestamp}格式
12+
- 配置 filePath 文件名 增加 ${yyyymmdd}格式
13+
- 配置 filePath 文件名 增加 ${timestamp}格式
1014

1115
## version 2.11.16
1216

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-leetcode-problem-rating",
33
"displayName": "LeetCode",
44
"description": "LeetCode 官方插件增强, 代码开源, 增加 LeetCode 题目难度分, 给个star吧, 球球了",
5-
"version": "2.12.2",
5+
"version": "2.12.3",
66
"author": "ccagml",
77
"publisher": "ccagml",
88
"license": "MIT",

src/controller/TreeViewController.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as lodash from "lodash";
1111
import * as path from "path";
1212
import * as vscode from "vscode";
1313
import { toNumber } from "lodash";
14-
import { Disposable, Uri, window } from "vscode";
14+
import { Disposable, Uri, window, workspace, ConfigurationChangeEvent } from "vscode";
1515
import {
1616
SearchNode,
1717
userContestRankingObj,
@@ -78,7 +78,16 @@ class TreeViewController implements Disposable {
7878
private searchSet: Map<string, ISearchSet> = new Map<string, ISearchSet>();
7979
private waitTodayQuestion: boolean;
8080
private waitUserContest: boolean;
81+
private configurationChangeListener: Disposable;
8182

83+
constructor() {
84+
this.configurationChangeListener = workspace.onDidChangeConfiguration((event: ConfigurationChangeEvent) => {
85+
if (event.affectsConfiguration("leetcode-problem-rating.hideScore")) {
86+
treeDataService.refresh();
87+
bricksDataService.refresh();
88+
}
89+
}, this);
90+
}
8291
// 获取当前文件的路径
8392
/**
8493
* It returns the path of the currently active file, or undefined if there is no active file
@@ -996,7 +1005,7 @@ class TreeViewController implements Disposable {
9961005
}
9971006

9981007
public async resolveTagForProblem(problem: IProblem): Promise<string | undefined> {
999-
let path_en_tags = treeDataService.getTagsDataEn(problem.id)
1008+
let path_en_tags = treeDataService.getTagsDataEn(problem.id);
10001009
if (path_en_tags.length === 1) {
10011010
return path_en_tags[0];
10021011
}
@@ -1078,7 +1087,7 @@ class TreeViewController implements Disposable {
10781087
const temp_searchSet: Map<string, ISearchSet> = this.searchSet;
10791088
const temp_waitTodayQuestion: boolean = this.waitTodayQuestion;
10801089
const temp_waitUserContest: boolean = this.waitUserContest;
1081-
this.dispose();
1090+
this.clearCache();
10821091
let user_score = statusBarService.getUserContestScore();
10831092
for (const problem of await this.getAllProblems()) {
10841093
this.explorerNodeMap.set(problem.id, new NodeModel(problem, true, user_score));
@@ -1492,14 +1501,19 @@ class TreeViewController implements Disposable {
14921501
return this.applySortingStrategy(res);
14931502
}
14941503

1495-
public dispose(): void {
1504+
public clearCache(): void {
14961505
this.explorerNodeMap.clear();
14971506
this.companySet.clear();
14981507
this.tagSet.clear();
14991508
this.fidToQid.clear();
15001509
this.qidToFid.clear();
15011510
}
15021511

1512+
public dispose(): void {
1513+
this.configurationChangeListener.dispose();
1514+
this.clearCache();
1515+
}
1516+
15031517
private sortSubCategoryNodes(subCategoryNodes: NodeModel[], category: Category): void {
15041518
switch (category) {
15051519
case Category.Difficulty:

src/service/TreeDataService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class TreeDataService implements vscode.TreeDataProvider<NodeModel> {
122122
return [];
123123
} else {
124124
switch (
125-
element.id // First-level
125+
element.id // First-level
126126
) {
127127
case Category.All:
128128
return treeViewController.getAllNodes();

0 commit comments

Comments
 (0)