@@ -155,27 +155,28 @@ function addCompanyProblems(sortMethod: string) {
155
155
async function addCompaniesToSelect ( ) {
156
156
const companySearch = document . getElementById ( 'companySearch' ) as HTMLInputElement ;
157
157
const companyList = document . getElementById ( 'companyList' ) as HTMLDataListElement ;
158
- let uniqueCompanies = new Set < string > ( ) ;
158
+ let companies = [ ] ;
159
159
160
- const data = await new Promise < { leetcodeProblems : LeetcodeProblems } > ( resolve => {
161
- chrome . storage . local . get ( 'leetcodeProblems ' , function ( items : { [ key : string ] : any ; } ) {
162
- resolve ( items as { leetcodeProblems : LeetcodeProblems } ) ;
160
+ const data = await new Promise < { companyProblems : any } > ( ( resolve ) => {
161
+ chrome . storage . local . get ( 'companyProblems ' , function ( data ) {
162
+ resolve ( data ) ;
163
163
} ) ;
164
164
} ) ;
165
165
166
- data . leetcodeProblems . questions . forEach ( ( question : Question ) => {
167
- if ( question . companies ) {
168
- question . companies . forEach ( ( company : Company ) => {
169
- uniqueCompanies . add ( company . name ) ;
170
- } ) ;
166
+ const companyProblems = data . companyProblems ;
167
+ // add all the keys to the set
168
+ Object . keys ( companyProblems ) . forEach ( ( company ) => {
169
+ if ( company ) {
170
+ console . log ( company ) ;
171
+ companies . push ( company ) ;
171
172
}
172
173
} ) ;
173
174
174
175
// Event when the "Enter" key is pressed or an option is selected from the dropdown
175
176
const handleSelection = ( ) => {
176
177
const inputValue = companySearch . value ;
177
178
// Find the selected company in a case-insensitive manner
178
- const selectedCompany = Array . from ( uniqueCompanies ) . find (
179
+ const selectedCompany = Array . from ( companies ) . find (
179
180
( company ) => company . toLowerCase ( ) === inputValue . toLowerCase ( )
180
181
) ;
181
182
if ( selectedCompany ) {
@@ -193,8 +194,7 @@ async function addCompaniesToSelect() {
193
194
194
195
companySearch . addEventListener ( 'change' , handleSelection ) ;
195
196
196
- // Convert the Set to an Array and sort it alphabetically
197
- const sortedCompanies = Array . from ( uniqueCompanies ) . sort ( ) ;
197
+ const sortedCompanies = companies . sort ( ) ;
198
198
199
199
sortedCompanies . forEach ( ( company ) => {
200
200
const option = document . createElement ( 'option' ) ;
0 commit comments