@@ -293,6 +293,8 @@ function runApp() {
293293 } )
294294 }
295295
296+ let proxyUrl
297+
296298 app . on ( 'ready' , async ( _ , __ ) => {
297299 if ( process . env . NODE_ENV === 'production' ) {
298300 protocol . handle ( 'app' , async ( request ) => {
@@ -412,8 +414,10 @@ function runApp() {
412414 }
413415
414416 if ( useProxy ) {
417+ proxyUrl = `${ proxyProtocol } ://${ proxyHostname } :${ proxyPort } `
418+
415419 session . defaultSession . setProxy ( {
416- proxyRules : ` ${ proxyProtocol } :// ${ proxyHostname } : ${ proxyPort } `
420+ proxyRules : proxyUrl
417421 } )
418422 }
419423
@@ -960,18 +964,20 @@ function runApp() {
960964 } )
961965
962966 ipcMain . handle ( IpcChannels . GENERATE_PO_TOKEN , ( _ , visitorData ) => {
963- return generatePoToken ( visitorData )
967+ return generatePoToken ( visitorData , proxyUrl )
964968 } )
965969
966970 ipcMain . on ( IpcChannels . ENABLE_PROXY , ( _ , url ) => {
967971 session . defaultSession . setProxy ( {
968972 proxyRules : url
969973 } )
974+ proxyUrl = url
970975 session . defaultSession . closeAllConnections ( )
971976 } )
972977
973978 ipcMain . on ( IpcChannels . DISABLE_PROXY , ( ) => {
974979 session . defaultSession . setProxy ( { } )
980+ proxyUrl = undefined
975981 session . defaultSession . closeAllConnections ( )
976982 } )
977983
@@ -1048,10 +1054,6 @@ function runApp() {
10481054 return app . getSystemLocale ( )
10491055 } )
10501056
1051- ipcMain . handle ( IpcChannels . GET_PICTURES_PATH , ( ) => {
1052- return app . getPath ( 'pictures' )
1053- } )
1054-
10551057 // Allows programmatic toggling of fullscreen without accompanying user interaction.
10561058 // See: https://developer.mozilla.org/en-US/docs/Web/Security/User_activation#transient_activation
10571059 ipcMain . on ( IpcChannels . REQUEST_FULLSCREEN , ( { sender } ) => {
@@ -1078,6 +1080,14 @@ function runApp() {
10781080 } )
10791081 }
10801082
1083+ ipcMain . handle ( IpcChannels . GET_SCREENSHOT_FALLBACK_FOLDER , ( event ) => {
1084+ if ( ! isFreeTubeUrl ( event . senderFrame . url ) ) {
1085+ return
1086+ }
1087+
1088+ return path . join ( app . getPath ( 'pictures' ) , 'Freetube' )
1089+ } )
1090+
10811091 ipcMain . on ( IpcChannels . CHOOSE_DEFAULT_FOLDER , async ( event , kind ) => {
10821092 if ( ! isFreeTubeUrl ( event . senderFrame . url ) || ( kind !== DefaultFolderKind . DOWNLOADS && kind !== DefaultFolderKind . SCREENSHOTS ) ) {
10831093 return
0 commit comments