@@ -34,16 +34,20 @@ let timeout
3434 */
3535async function initPopup ( ) {
3636 console . log ( 'initPopup' )
37+
38+ // Get options
3739 const { options } = await chrome . storage . sync . get ( [ 'options' ] )
3840 console . log ( 'options:' , options )
3941
40- // Set Options (since this is the only one)
42+ // Set Options (this is currently the only one in the popup )
4143 document . getElementById ( 'popupPreview' ) . checked = options . popupPreview
4244
45+ // Ensure authError is set to false
4346 authError = false
47+
4448 // Check auth if checkAuth is enabled in options
4549 if ( options . checkAuth ) {
46- alwaysAuth . classList . remove ( 'd-none' )
50+ await checkSiteAuth ( )
4751 }
4852
4953 // If missing auth data or options.checkAuth check current site for auth
@@ -103,14 +107,7 @@ async function initPopup() {
103107 return displayAlert ( { message : 'No Files Returned.' } )
104108 }
105109
106- // Check auth if checkAuth is enabled in options
107- if ( options . checkAuth ) {
108- alwaysAuth . classList . remove ( 'd-none' )
109- await checkSiteAuth ( )
110- }
111-
112- // Hide loading display table, update table
113- // loadingTable.classList.add('d-none')
110+ // Update table should only be called here, changes should use initPopup()
114111 updateTable ( data )
115112
116113 // Re-init clipboardJS and popupLinks after updateTable
@@ -168,8 +165,7 @@ async function onMessage(message) {
168165 await chrome . storage . local . set ( { auth } )
169166 console . log ( 'New Authentication Found.' )
170167 if ( options . checkAuth ) {
171- alwaysAuth . classList . remove ( 'disabled' , 'btn-outline-secondary' )
172- alwaysAuth . classList . add ( 'btn-warning' )
168+ alwaysAuth . classList . remove ( 'd-none' )
173169 }
174170 if ( authError ) {
175171 authButton . classList . remove ( 'd-none' )
@@ -222,7 +218,7 @@ async function authCredentials(event) {
222218 console . log ( 'Auth Credentials Updated...' )
223219 authButton . classList . add ( 'd-none' )
224220 errorAlert . classList . add ( 'd-none' )
225- alwaysAuth . classList . add ( 'disabled' , 'btn-outline-secondary ')
221+ alwaysAuth . classList . add ( 'd-none ' )
226222 await initPopup ( )
227223 } else {
228224 displayAlert ( { message : 'Error Getting or Setting Credentials.' } )
0 commit comments