@@ -155,27 +155,28 @@ function addCompanyProblems(sortMethod: string) {
155155async function addCompaniesToSelect ( ) {
156156 const companySearch = document . getElementById ( 'companySearch' ) as HTMLInputElement ;
157157 const companyList = document . getElementById ( 'companyList' ) as HTMLDataListElement ;
158- let uniqueCompanies = new Set < string > ( ) ;
158+ let companies = [ ] ;
159159
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 ) ;
163163 } ) ;
164164 } ) ;
165165
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 ) ;
171172 }
172173 } ) ;
173174
174175 // Event when the "Enter" key is pressed or an option is selected from the dropdown
175176 const handleSelection = ( ) => {
176177 const inputValue = companySearch . value ;
177178 // Find the selected company in a case-insensitive manner
178- const selectedCompany = Array . from ( uniqueCompanies ) . find (
179+ const selectedCompany = Array . from ( companies ) . find (
179180 ( company ) => company . toLowerCase ( ) === inputValue . toLowerCase ( )
180181 ) ;
181182 if ( selectedCompany ) {
@@ -193,8 +194,7 @@ async function addCompaniesToSelect() {
193194
194195 companySearch . addEventListener ( 'change' , handleSelection ) ;
195196
196- // Convert the Set to an Array and sort it alphabetically
197- const sortedCompanies = Array . from ( uniqueCompanies ) . sort ( ) ;
197+ const sortedCompanies = companies . sort ( ) ;
198198
199199 sortedCompanies . forEach ( ( company ) => {
200200 const option = document . createElement ( 'option' ) ;
0 commit comments