Skip to content

hideScore 配置变化时刷新题目列表 #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
## version 2.12.3

- hideScore 配置变化时刷新题目列表

## version 2.12.2

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

## version 2.12.1

- 配置filePath文件名 增加 ${yyyymmdd}格式
- 配置filePath文件名 增加 ${timestamp}格式
- 配置 filePath 文件名 增加 ${yyyymmdd}格式
- 配置 filePath 文件名 增加 ${timestamp}格式

## version 2.11.16

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-leetcode-problem-rating",
"displayName": "LeetCode",
"description": "LeetCode 官方插件增强, 代码开源, 增加 LeetCode 题目难度分, 给个star吧, 球球了",
"version": "2.12.2",
"version": "2.12.3",
"author": "ccagml",
"publisher": "ccagml",
"license": "MIT",
Expand Down
22 changes: 18 additions & 4 deletions src/controller/TreeViewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as lodash from "lodash";
import * as path from "path";
import * as vscode from "vscode";
import { toNumber } from "lodash";
import { Disposable, Uri, window } from "vscode";
import { Disposable, Uri, window, workspace, ConfigurationChangeEvent } from "vscode";
import {
SearchNode,
userContestRankingObj,
Expand Down Expand Up @@ -78,7 +78,16 @@ class TreeViewController implements Disposable {
private searchSet: Map<string, ISearchSet> = new Map<string, ISearchSet>();
private waitTodayQuestion: boolean;
private waitUserContest: boolean;
private configurationChangeListener: Disposable;

constructor() {
this.configurationChangeListener = workspace.onDidChangeConfiguration((event: ConfigurationChangeEvent) => {
if (event.affectsConfiguration("leetcode-problem-rating.hideScore")) {
treeDataService.refresh();
bricksDataService.refresh();
}
}, this);
}
// 获取当前文件的路径
/**
* It returns the path of the currently active file, or undefined if there is no active file
Expand Down Expand Up @@ -996,7 +1005,7 @@ class TreeViewController implements Disposable {
}

public async resolveTagForProblem(problem: IProblem): Promise<string | undefined> {
let path_en_tags = treeDataService.getTagsDataEn(problem.id)
let path_en_tags = treeDataService.getTagsDataEn(problem.id);
if (path_en_tags.length === 1) {
return path_en_tags[0];
}
Expand Down Expand Up @@ -1078,7 +1087,7 @@ class TreeViewController implements Disposable {
const temp_searchSet: Map<string, ISearchSet> = this.searchSet;
const temp_waitTodayQuestion: boolean = this.waitTodayQuestion;
const temp_waitUserContest: boolean = this.waitUserContest;
this.dispose();
this.clearCache();
let user_score = statusBarService.getUserContestScore();
for (const problem of await this.getAllProblems()) {
this.explorerNodeMap.set(problem.id, new NodeModel(problem, true, user_score));
Expand Down Expand Up @@ -1492,14 +1501,19 @@ class TreeViewController implements Disposable {
return this.applySortingStrategy(res);
}

public dispose(): void {
public clearCache(): void {
this.explorerNodeMap.clear();
this.companySet.clear();
this.tagSet.clear();
this.fidToQid.clear();
this.qidToFid.clear();
}

public dispose(): void {
this.configurationChangeListener.dispose();
this.clearCache();
}

private sortSubCategoryNodes(subCategoryNodes: NodeModel[], category: Category): void {
switch (category) {
case Category.Difficulty:
Expand Down
2 changes: 1 addition & 1 deletion src/service/TreeDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class TreeDataService implements vscode.TreeDataProvider<NodeModel> {
return [];
} else {
switch (
element.id // First-level
element.id // First-level
) {
case Category.All:
return treeViewController.getAllNodes();
Expand Down