Skip to content

Commit 71cdce2

Browse files
FerotiqMiodec
andauthored
TypeScript FrontEnd: Add Account Files (#2494)
* add account files, config, and db, fix other files, and make lint script work on cmd * fuck operating systems * remove project from eslint * Merging and fixing some bugs * fixed result ordering * fixed quote filter stopping all results * fixed words filter not working * corrected type * Update commandline-lists.ts * Update types.d.ts * removing explicit tag types * mfing prettier * small changes * stuff * fixes * fix cannot read properties of undefined * another check just to be safe * okay that works Co-authored-by: Miodec <[email protected]>
1 parent c3825ab commit 71cdce2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1348
-926
lines changed

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,66 @@ name: Bug report
22
description: Create a report to help us improve
33
labels: [bug]
44
body:
5-
65
- type: markdown
76
attributes:
87
value: |
98
# Welcome
109
```
1110
Thanks for taking the time to fill out this bug! If you need real-time help, join us on Discord: discord.gg/monkeytype
1211
```
13-
14-
12+
1513
- type: checkboxes
1614
attributes:
1715
label: Did you clear cache before opening an issue?
1816
description: Sometimes your browser has old files cached and the bug you are experiencing might be already fixed, or is just a side effect of a new update. If you don't know how to do that, this website should help https://www.pcmag.com/how-to/how-to-clear-your-cache-on-any-browser.
1917
options:
2018
- label: I have cleared my cache
2119
required: true
22-
20+
2321
- type: checkboxes
2422
attributes:
2523
label: Is there an existing issue for this?
2624
description: Please search to see if an issue already exists for the bug you encountered.
2725
options:
2826
- label: I have searched the existing issues
2927
required: true
30-
28+
3129
- type: markdown
3230
attributes:
3331
value: |
3432
# Basic debugging
3533
```
3634
Below fields are very important to quickly track down the issue, so please take the time to carefully check when the issue happens and when it does not.
3735
```
38-
36+
3937
- type: dropdown
4038
attributes:
4139
label: Does the issue happen when logged in?
4240
options: ["Yes", "No", "N/A"]
4341
validations:
4442
required: true
45-
43+
4644
- type: dropdown
4745
attributes:
4846
label: Does the issue happen when logged out?
4947
options: ["Yes", "No"]
5048
validations:
5149
required: true
52-
50+
5351
- type: dropdown
5452
attributes:
5553
label: Does the issue happen in incognito mode when logged in?
5654
options: ["Yes", "No", "N/A"]
5755
validations:
5856
required: true
59-
57+
6058
- type: dropdown
6159
attributes:
6260
label: Does the issue happen in incognito mode when logged out?
6361
options: ["Yes", "No"]
6462
validations:
6563
required: true
66-
64+
6765
- type: textarea
6866
attributes:
6967
label: Account information
@@ -128,4 +126,3 @@ body:
128126
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
129127
validations:
130128
required: false
131-

.prettierrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
22
"tabWidth": 2,
33
"useTabs": false,
4-
"htmlWhitespaceSensitivity": "ignore"
4+
"htmlWhitespaceSensitivity": "ignore",
5+
"endOfLine": "lf",
6+
"overrides": [
7+
{
8+
"files": ["*.ts"],
9+
"options": {
10+
"parser": "typescript"
11+
}
12+
}
13+
]
514
}
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
import * as DB from "../db";
22
import * as Misc from "../misc";
33

4-
export function clear() {
4+
export function clear(): void {
55
$(".pageAccount .globalTimeTyping .val").text(`-`);
66
$(".pageAccount .globalTestsStarted .val").text(`-`);
77
$(".pageAccount .globalTestsCompleted .val").text(`-`);
88
}
99

10-
export function update() {
11-
if (DB.getSnapshot().globalStats.time != undefined) {
10+
export function update(): void {
11+
const snapshot = DB.getSnapshot();
12+
13+
if (snapshot.globalStats !== undefined) {
1214
// let th = Math.floor(DB.getSnapshot().globalStats.time / 3600);
1315
// let tm = Math.floor((DB.getSnapshot().globalStats.time % 3600) / 60);
1416
// let ts = Math.floor((DB.getSnapshot().globalStats.time % 3600) % 60);
1517
$(".pageAccount .globalTimeTyping .val").text(
1618
Misc.secondsToString(
17-
Math.round(DB.getSnapshot().globalStats.time),
19+
Math.round(snapshot.globalStats.time as number),
1820
true,
1921
true
2022
)
2123
);
2224
}
23-
if (DB.getSnapshot().globalStats.started != undefined) {
25+
26+
if (snapshot.globalStats !== undefined) {
2427
$(".pageAccount .globalTestsStarted .val").text(
25-
DB.getSnapshot().globalStats.started
28+
snapshot.globalStats.started as number
2629
);
2730
}
28-
if (DB.getSnapshot().globalStats.completed != undefined) {
31+
32+
if (snapshot.globalStats !== undefined) {
2933
$(".pageAccount .globalTestsCompleted .val").text(
30-
DB.getSnapshot().globalStats.completed
34+
snapshot.globalStats.completed as number
3135
);
3236
}
3337
}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import * as ChartController from "../controllers/chart-controller";
22
import Config from "../config";
33

4-
export function updatePosition(x, y) {
4+
export function updatePosition(x: number, y: number): void {
55
$(".pageAccount .miniResultChartWrapper").css({ top: y, left: x });
66
}
77

8-
export function show() {
8+
export function show(): void {
99
$(".pageAccount .miniResultChartWrapper").stop(true, true).fadeIn(125);
1010
$(".pageAccount .miniResultChartBg").stop(true, true).fadeIn(125);
1111
}
1212

13-
function hide() {
13+
function hide(): void {
1414
$(".pageAccount .miniResultChartWrapper").stop(true, true).fadeOut(125);
1515
$(".pageAccount .miniResultChartBg").stop(true, true).fadeOut(125);
1616
}
1717

18-
export function updateData(data) {
18+
export function updateData(data: MonkeyTypes.ChartData): void {
1919
// let data = filteredResults[filteredId].chartData;
20-
let labels = [];
20+
const labels = [];
2121
for (let i = 1; i <= data.wpm.length; i++) {
2222
labels.push(i.toString());
2323
}
@@ -28,22 +28,22 @@ export function updateData(data) {
2828

2929
ChartController.miniResult.updateColors();
3030

31-
let maxChartVal = Math.max(...[Math.max(...data.wpm), Math.max(...data.raw)]);
32-
let minChartVal = Math.min(...[Math.min(...data.wpm), Math.min(...data.raw)]);
33-
ChartController.miniResult.options.scales.yAxes[0].ticks.max = Math.round(
34-
maxChartVal
31+
const maxChartVal = Math.max(
32+
...[Math.max(...data.wpm), Math.max(...data.raw)]
3533
);
36-
ChartController.miniResult.options.scales.yAxes[1].ticks.max = Math.round(
37-
maxChartVal
34+
const minChartVal = Math.min(
35+
...[Math.min(...data.wpm), Math.min(...data.raw)]
3836
);
37+
ChartController.miniResult.options.scales.yAxes[0].ticks.max =
38+
Math.round(maxChartVal);
39+
ChartController.miniResult.options.scales.yAxes[1].ticks.max =
40+
Math.round(maxChartVal);
3941

4042
if (!Config.startGraphsAtZero) {
41-
ChartController.miniResult.options.scales.yAxes[0].ticks.min = Math.round(
42-
minChartVal
43-
);
44-
ChartController.miniResult.options.scales.yAxes[1].ticks.min = Math.round(
45-
minChartVal
46-
);
43+
ChartController.miniResult.options.scales.yAxes[0].ticks.min =
44+
Math.round(minChartVal);
45+
ChartController.miniResult.options.scales.yAxes[1].ticks.min =
46+
Math.round(minChartVal);
4747
} else {
4848
ChartController.miniResult.options.scales.yAxes[0].ticks.min = 0;
4949
ChartController.miniResult.options.scales.yAxes[1].ticks.min = 0;
@@ -52,6 +52,6 @@ export function updateData(data) {
5252
ChartController.miniResult.update({ duration: 0 });
5353
}
5454

55-
$(document).on("click", ".pageAccount .miniResultChartBg", (event) => {
55+
$(document).on("click", ".pageAccount .miniResultChartBg", () => {
5656
hide();
5757
});

frontend/src/scripts/account/pb-tables.js renamed to frontend/src/scripts/account/pb-tables.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as DB from "../db";
22
import Config from "../config";
33
import * as Misc from "../misc";
44

5-
export function update() {
5+
export function update(): void {
66
$(".pageAccount .timePbTable tbody").html(`
77
<tr>
88
<td>15</td>
@@ -75,10 +75,11 @@ export function update() {
7575
}
7676

7777
const pb = DB.getSnapshot().personalBests;
78+
if (pb === undefined) return;
7879
let pbData;
7980
let text;
8081
let dateText = `-<br><span class="sub">-</span>`;
81-
let multiplier = Config.alwaysShowCPM ? 5 : 1;
82+
const multiplier = Config.alwaysShowCPM ? 5 : 1;
8283

8384
text = "";
8485
try {

0 commit comments

Comments
 (0)