Skip to content

Commit

Permalink
Emergency fix for webview
Browse files Browse the repository at this point in the history
  • Loading branch information
langningchen committed Nov 9, 2024
1 parent 0dcc365 commit eb66435
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 26 deletions.
7 changes: 2 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

All notable changes to the "cyezoi" extension will be documented in this file.

## v0.0.17
## v0.0.18

- **Add keybindings to submit and open problem**
- **Add refresh button to webview**
- Fix the issue of displaying the relative time
- Enhance login experience
- Emergency fix for webview

Want to see the previous log? [Click here](https://github.com/CYEZOI/cyezoi-helper/commits/main/CHANGELOG.md)
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,12 @@
}
},
{
"command": "attendC",
"title": "CYEZOI: Attend Contest"
"command": "cyezoi.attendC",
"title": "CYEZOI: Attend Contest",
"icon": {
"light": "res/icons/plus-light.svg",
"dark": "res/icons/plus-dark.svg"
}
},
{
"command": "cyezoi.refreshRTree",
Expand Down Expand Up @@ -223,6 +227,11 @@
"command": "cyezoi.submitProblem",
"when": "viewItem == problem",
"group": "inline"
},
{
"command": "cyezoi.attendC",
"when": "viewItem == contest",
"group": "inline"
}
],
"view/title": [
Expand Down
3 changes: 3 additions & 0 deletions res/icons/plus-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions res/icons/plus-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 8 additions & 9 deletions src/cTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export default class implements vscode.TreeDataProvider<Contest> {
}

export class Contest extends vscode.TreeItem {
constructor(tdoc: utils.ContestDoc, showProblem: boolean) {
super(tdoc.title, showProblem ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None);
constructor(tdoc: utils.ContestDoc, attended: boolean) {
super(tdoc.title, vscode.TreeItemCollapsibleState.Collapsed);
this.id = tdoc._id;
this.contextValue = 'contest';
this.description = utils.toTime(new Date(tdoc.endAt).getTime() - new Date(tdoc.beginAt).getTime());
Expand All @@ -89,13 +89,12 @@ export class Contest extends vscode.TreeItem {
tooltipDoc.appendMarkdown(`- **Rated**: ${tdoc.rated ? 'Yes' : 'No'}\n`);
tooltipDoc.appendMarkdown(`- **Allow View Code**: ${tdoc.allowViewCode ? 'Yes' : 'No'}\n`);
this.tooltip = tooltipDoc;
if (showProblem) {
this.command = {
command: 'cyezoi.openC',
title: 'Open Contest',
arguments: [tdoc._id],
};
} else {
this.command = {
command: 'cyezoi.openC',
title: 'Open Contest',
arguments: [tdoc._id],
};
if (attended) {
this.command = {
command: 'cyezoi.attendC',
title: 'Attend Contest',
Expand Down
2 changes: 1 addition & 1 deletion src/cWeb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class {
const staticFiles = [
{ 'path': ['res', 'libs', 'vscode-elements', 'bundled.js'], attributes: { 'type': 'module' } },
{ 'path': ['res', 'libs', 'codicon', 'codicon.css'], attributes: { 'id': 'vscode-codicon-stylesheet' } },
{ 'path': ['src', 'utils.js'] },
{ 'path': ['res', 'html', 'static.js'] },
{ 'path': ['res', 'html', 'contest.js'] },
];
let recordHtml = path.join(this._extensionPath, 'res', 'html', 'contest.html');
Expand Down
25 changes: 18 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,30 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.commands.executeCommand('cyezoi.openT', rid);
}
}));
disposables.push(vscode.commands.registerCommand('cyezoi.attendC', async (tid: string | undefined) => {
disposables.push(vscode.commands.registerCommand('cyezoi.attendC', async (tid: vscode.TreeItem | string | undefined) => {
if (tid instanceof vscode.TreeItem) {
const args = tid.command?.arguments;
if (args && args[Symbol.iterator]) {
[tid] = args;
}
}
if (tid === undefined) {
tid = await io.input('Please input the contest ID');
if (tid === undefined) {
return;
}
};
await new fetch({
path: `/d/${settings.domain}/contest/${tid}`, addCookie: true,
body: {
"operation": "attend",
},
}).start();
try {
await new fetch({
path: `/d/${settings.domain}/contest/${tid}`, addCookie: true,
body: {
"operation": "attend",
},
}).start();
} catch (e) {
io.error((e as Error).message);
return;
}
io.info('Contest attended');
vscode.commands.executeCommand('cyezoi.refreshCTree');
}));
Expand Down
2 changes: 1 addition & 1 deletion src/pWeb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class {
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'fold', 'indent-fold.min.js'] },
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'section', 'active-line.min.js'] },
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'display', 'autorefresh.min.js'] },
{ 'path': ['src', 'utils.js'] },
{ 'path': ['res', 'html', 'static.js'] },
{ 'path': ['res', 'html', 'problem.css'] },
{ 'path': ['res', 'html', 'problem.js'] },
];
Expand Down
2 changes: 1 addition & 1 deletion src/rWeb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class {
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'fold', 'indent-fold.min.js'] },
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'section', 'active-line.min.js'] },
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'display', 'autorefresh.min.js'] },
{ 'path': ['src', 'utils.js'] },
{ 'path': ['res', 'html', 'static.js'] },
{ 'path': ['res', 'html', 'record.css'] },
{ 'path': ['res', 'html', 'record.js'] },
];
Expand Down

0 comments on commit eb66435

Please sign in to comment.