Skip to content

Commit 59d2c83

Browse files
committed
recalculate the min and max each time the dateselect is updated
1 parent d9eb551 commit 59d2c83

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/problems-by-company/company.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ function addNavbarLinks() {
6262
button.style.minWidth = '130px';
6363
button.style.height = '40px';
6464
button.style.padding = '5px';
65-
button.style.border = '3px solid #373737';
6665
button.style.backgroundColor = '#373737';
6766
button.style.borderRadius = '10px';
6867
button.style.fontSize = '12px';
@@ -80,6 +79,10 @@ async function updateFrequency(selectedFrequency: string) {
8079
table.deleteRow(1);
8180
}
8281

82+
// Reset min and max frequency for the selected range
83+
minFrequency = Number.MAX_SAFE_INTEGER;
84+
maxFrequency = 0;
85+
8386
// Update the frequency values in the solutions array
8487
const data = await new Promise<{ companyProblems: any }>((resolve) => {
8588
chrome.storage.local.get('companyProblems', function (data) {
@@ -91,14 +94,20 @@ async function updateFrequency(selectedFrequency: string) {
9194
if (Array.isArray(companyProblems)) {
9295
solutions.forEach((solution, index) => {
9396
// Update the frequency based on the selected option
94-
solution['frequency'] = companyProblems[index][selectedFrequency];
97+
const freqValue = companyProblems[index][selectedFrequency];
98+
solution['frequency'] = freqValue;
99+
100+
// Update min and max frequency for the selected range
101+
if (freqValue < minFrequency) minFrequency = freqValue;
102+
if (freqValue > maxFrequency) maxFrequency = freqValue;
95103
});
96104
}
97105

98106
// Rebuild the table with updated frequency values
99107
rebuildTable();
100108
}
101109

110+
102111
interface Company {
103112
name: string;
104113
}

0 commit comments

Comments
 (0)