Skip to content

Commit

Permalink
Show maintainer's message.
Browse files Browse the repository at this point in the history
  • Loading branch information
agrawal-d committed Jun 3, 2023
1 parent d0c96e1 commit 9dc2c52
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-3.0-or-later",
"icon": "icon.png",
"publisher": "DivyanshuAgrawal",
"version": "5.10.0",
"version": "5.11.0",
"engines": {
"vscode": "^1.52.0"
},
Expand Down Expand Up @@ -211,6 +211,12 @@
"default": true,
"description": "A welcome message is shown when you run a testcase for the first time. This setting is updated automatically after the first message is shown."
},
"cph.general.onceMaintainerMessage": {
"title": "Show 'looking for a maintainer' message",
"type": "boolean",
"default": true,
"description": "A message from the maintainer is shown when you run a testcase for the first time. This setting is updated automatically after the first message is shown."
},
"cph.general.defaultLanguage": {
"title": "Default language for new problems",
"type": "string",
Expand Down
3 changes: 3 additions & 0 deletions src/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export const getGoArgsPref = (): string[] =>
export const getFirstTimePref = (): boolean =>
getPreference('general.firstTime') || 'true';

export const getLookingForMaintainerPerf = (): boolean =>
getPreference('general.onceMaintainerMessage');

export const getDefaultLangPref = (): string | null => {
const pref = getPreference('general.defaultLanguage');
if (pref === 'none' || pref == ' ' || !pref) {
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export type prefSection =
| 'language.python.Command'
| 'general.retainWebviewContext'
| 'general.autoShowJudge'
| 'general.defaultLanguageTemplateFileLocation';
| 'general.defaultLanguageTemplateFileLocation'
| 'general.onceMaintainerMessage';

export type Language = {
name: LangNames;
Expand Down
21 changes: 21 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
getRustCommand,
getJavaCommand,
getGoCommand,
getLookingForMaintainerPerf,
updatePreference,
} from './preferences';
import { Language, Problem } from './types';

Expand Down Expand Up @@ -166,3 +168,22 @@ export const getProblemForDocument = (
const problem: Problem = JSON.parse(readFileSync(probPath).toString());
return problem;
};

export const showMaintainerMessage = async () => {
/** Temporary maintainer's messaage **/
if (getLookingForMaintainerPerf()) {
console.log("Showing maintainer's message");
updatePreference('general.onceMaintainerMessage', false);
const openIssue = 'Details';
const issueUrl = 'https://rb.gy/ohx17';
const result = await vscode.window.showInformationMessage(
'CPH is looking for a maintainer to continue development of extension!' +
'Help the community by keeping this extension alive.',
openIssue,
);

if (result === openIssue) {
vscode.env.openExternal(vscode.Uri.parse(issueUrl));
}
}
};
3 changes: 2 additions & 1 deletion src/webview/processRunAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Problem } from '../types';
import { runSingleAndSave } from './processRunSingle';
import { compileFile, getBinSaveLocation } from '../compiler';
import { deleteBinary } from '../executions';
import { getLanguage } from '../utils';
import { getLanguage, showMaintainerMessage } from '../utils';
import { getJudgeViewProvider } from '../extension';

/**
Expand All @@ -11,6 +11,7 @@ import { getJudgeViewProvider } from '../extension';
**/
export default async (problem: Problem) => {
console.log('Run all started', problem);
showMaintainerMessage();
const didCompile = await compileFile(problem.srcPath);
if (!didCompile) {
return;
Expand Down

0 comments on commit 9dc2c52

Please sign in to comment.