@@ -210,6 +210,24 @@ class AppState {
210210 }
211211 }
212212
213+ public clearQueues ( ) : void {
214+ // Clear screenshotQueue
215+ this . screenshotQueue . forEach ( ( screenshotPath ) => {
216+ fs . unlink ( screenshotPath , ( err ) => {
217+ if ( err ) console . error ( `Error deleting screenshot at ${ screenshotPath } :` , err ) ;
218+ } ) ;
219+ } ) ;
220+ this . screenshotQueue = [ ] ;
221+
222+ // Clear extraScreenshotQueue
223+ this . extraScreenshotQueue . forEach ( ( screenshotPath ) => {
224+ fs . unlink ( screenshotPath , ( err ) => {
225+ if ( err ) console . error ( `Error deleting extra screenshot at ${ screenshotPath } :` , err ) ;
226+ } ) ;
227+ } ) ;
228+ this . extraScreenshotQueue = [ ] ;
229+ }
230+
213231 // Screenshot management methods
214232 private async takeScreenshot ( ) : Promise < string > {
215233 if ( ! this . mainWindow ) throw new Error ( "No main window available" )
@@ -510,6 +528,17 @@ class AppState {
510528 ipcMain . handle ( "toggle-window" , async ( ) => {
511529 this . toggleMainWindow ( )
512530 } )
531+
532+ ipcMain . handle ( "reset-queues" , async ( ) => {
533+ try {
534+ AppState . getInstance ( ) . clearQueues ( ) ;
535+ console . log ( "Screenshot queues have been cleared." ) ;
536+ return { success : true } ;
537+ } catch ( error : any ) {
538+ console . error ( "Error resetting queues:" , error ) ;
539+ return { success : false , error : error . message } ;
540+ }
541+ } ) ;
513542 }
514543 // Global shortcuts setup
515544 public setupGlobalShortcuts ( ) : void {
@@ -533,6 +562,23 @@ class AppState {
533562 await this . processScreenshots ( )
534563 } )
535564
565+ globalShortcut . register ( "CommandOrControl+R" , ( ) => {
566+ console . log ( "Resetting screenshot queues and switching view to 'queue'..." ) ;
567+
568+ // Clear both screenshot queues
569+ this . clearQueues ( ) ;
570+
571+ console . log ( "Cleared queues." ) ;
572+
573+ // **Update the view state to 'queue'**
574+ this . view = "queue" ;
575+
576+ // Notify renderer process to switch view to 'queue'
577+ if ( this . mainWindow && ! this . mainWindow . isDestroyed ( ) ) {
578+ this . mainWindow . webContents . send ( "reset-view" ) ;
579+ }
580+ } ) ;
581+
536582 globalShortcut . register ( "CommandOrControl+B" , ( ) => {
537583 this . toggleMainWindow ( )
538584 // If window exists and we're showing it, bring it to front
@@ -549,6 +595,8 @@ class AppState {
549595 }
550596 }
551597 } )
598+
599+
552600 }
553601}
554602
0 commit comments