@@ -147,7 +147,7 @@ document.getElementById('open-dev-tools').addEventListener('click', () => {
147147
148148document . addEventListener ( "DOMContentLoaded" , ( ) => {
149149 loadNotes ( ) ;
150- displayReleases ( ) ;
150+ checkForUpdates ( ) ;
151151 loadSettings ( ) ;
152152 applyThemeFlavor ( ) ; // Apply the saved theme flavor on startup
153153 updateThemeDropdown ( ) ;
@@ -187,30 +187,6 @@ function isNewerVersion(currentVersion, latestVersion) {
187187 return false ;
188188}
189189
190- async function displayReleases ( ) {
191- const releases = await fetchReleases ( ) ;
192- const latestRelease = releases [ 0 ] ; // Get the latest release
193-
194- if ( latestRelease && isNewerVersion ( version , latestRelease . tag_name ) ) {
195- // Show notification
196- const notification = document . getElementById ( "notification" ) ;
197- const message = document . getElementById ( "message" ) ;
198- const downloadLink = document . getElementById ( "download-link" ) ;
199- message . innerText = `New version ${ latestRelease . tag_name } is available!` ;
200- window . API . sendNotification ( 'Update Available' , 'A new version of the app is available.' ) ;
201- downloadLink . href = latestRelease . assets [ 0 ] . browser_download_url ; // Assuming the first asset is the setup file
202- downloadLink . innerText = "Download" ;
203- downloadLink . onclick = ( e ) => {
204- e . preventDefault ( ) ;
205- const downloadUrl = latestRelease . assets [ 0 ] . browser_download_url ;
206- const fileName = latestRelease . assets [ 0 ] . name ;
207- notification . classList . add ( "hidden" ) ;
208- downloadFile ( downloadUrl , fileName ) ;
209- } ;
210- notification . classList . remove ( "hidden" ) ;
211- }
212- }
213-
214190window . API . on ( 'check-for-updates' , ( ) => {
215191 console . log ( "Received check-for-updates event" ) ;
216192 checkForUpdates ( ) ;
@@ -225,17 +201,28 @@ async function checkForUpdates() {
225201 const notification = document . getElementById ( "notification" ) ;
226202 const message = document . getElementById ( "message" ) ;
227203 const downloadLink = document . getElementById ( "download-link" ) ;
204+ const fileSelect = document . getElementById ( "file-select" ) ;
205+
228206 message . innerText = `New version ${ latestRelease . tag_name } is available!` ;
229207 window . API . sendNotification ( 'Update Available' , 'A new version of the app is available.' ) ;
230- downloadLink . href = latestRelease . assets [ 0 ] . browser_download_url ; // Assuming the first asset is the setup file
231- downloadLink . innerText = "Download" ;
208+
209+ // Populate the dropdown menu with available assets
210+ fileSelect . innerHTML = '' ;
211+ latestRelease . assets . forEach ( asset => {
212+ const option = document . createElement ( 'option' ) ;
213+ option . value = asset . browser_download_url ;
214+ option . textContent = asset . name ;
215+ fileSelect . appendChild ( option ) ;
216+ } ) ;
217+
232218 downloadLink . onclick = ( e ) => {
233219 e . preventDefault ( ) ;
234- const downloadUrl = latestRelease . assets [ 0 ] . browser_download_url ;
235- const fileName = latestRelease . assets [ 0 ] . name ;
220+ const downloadUrl = fileSelect . value ;
221+ const fileName = fileSelect . options [ fileSelect . selectedIndex ] . text ;
236222 notification . classList . add ( "hidden" ) ;
237223 downloadFile ( downloadUrl , fileName ) ;
238224 } ;
225+
239226 notification . classList . remove ( "hidden" ) ;
240227 } else {
241228 // Show popup indicating the app is up-to-date
0 commit comments