22 app , BrowserWindow , dialog , Menu , ipcMain ,
33 powerSaveBlocker , screen , session , shell ,
44 nativeTheme , net , protocol , clipboard ,
5- Tray
5+ Tray , nativeImage
66} from 'electron'
77import path from 'path'
88import cp from 'child_process'
@@ -17,21 +17,16 @@ import {
1717} from '../constants'
1818import * as baseHandlers from '../datastores/handlers/base'
1919import { extractExpiryTimestamp , ImageCache } from './ImageCache'
20- import { existsSync , writeFileSync , mkdirSync } from 'fs'
20+ import { existsSync , readFileSync } from 'fs'
2121import asyncFs from 'fs/promises'
2222import { promisify } from 'util'
23- import { brotliDecompress , brotliDecompressSync } from 'zlib'
23+ import { brotliDecompress } from 'zlib'
2424
2525import contextMenu from 'electron-context-menu'
2626
2727import packageDetails from '../../package.json'
2828import { generatePoToken } from './poTokenGenerator'
2929
30- import os from 'os'
31- import asar from '@electron/asar'
32-
33- import i18next from 'i18next'
34- import Backend from 'i18next-fs-backend'
3530
3631const brotliDecompressAsync = promisify ( brotliDecompress )
3732
@@ -610,10 +605,11 @@ function runApp() {
610605 } )
611606
612607 function createTray ( ) {
613- const iconPath = process . env . NODE_ENV === 'development'
614- ? path . join ( __dirname , '..' , '..' , '_icons' , 'iconColor.png' )
615- : asarToTmp ( path . join ( '_icons' , 'iconColor.png' ) )
616- tray = new Tray ( iconPath )
608+ const icon = process . env . NODE_ENV === 'development'
609+ ? readFileSync ( path . join ( __dirname , '..' , '..' , '_icons' , 'iconColor.png' ) )
610+ : readFileSync ( path . join ( path . dirname ( __dirname ) , '_icons' , 'iconColor.png' ) )
611+
612+ tray = new Tray ( nativeImage . createFromBuffer ( icon ) )
617613 tray . setIgnoreDoubleClickEvents ( true )
618614
619615 function click ( ) {
@@ -623,11 +619,11 @@ function runApp() {
623619
624620 const menu = Menu . buildFromTemplate ( [
625621 {
626- label : i18next . t ( 'Tray. Show') ,
622+ label : ' Show',
627623 click : ( ) => click ( )
628624 } ,
629625 {
630- label : i18next . t ( 'Tray. Quit') ,
626+ label : ' Quit',
631627 click : handleQuit
632628 }
633629 ] )
@@ -640,22 +636,6 @@ function runApp() {
640636 } )
641637 }
642638
643- function asarToTmp ( relativePath , brotli = false ) {
644- const tmpFile = path . join ( os . tmpdir ( ) , 'freetube' , relativePath )
645-
646- if ( existsSync ( tmpFile ) ) {
647- return tmpFile
648- } else if ( ! existsSync ( path . dirname ( tmpFile ) ) ) {
649- mkdirSync ( path . dirname ( tmpFile ) , { recursive : true } )
650- }
651-
652- const asarFile = asar . extractFile ( path . dirname ( __dirname ) , relativePath )
653-
654- writeFileSync ( tmpFile , ! brotli ? asarFile : brotliDecompressSync ( asarFile ) )
655-
656- return tmpFile
657- }
658-
659639 /**
660640 * @param {string } extension
661641 */
@@ -935,21 +915,6 @@ function runApp() {
935915 startupUrl = null
936916 } )
937917
938- ipcMain . on ( IpcChannels . GET_CURRENT_LOCALE , ( _ , { targetLocale, fallbackLocale } ) => {
939- i18next . use ( Backend ) . init ( {
940- lng : targetLocale ,
941- fallbackLng : fallbackLocale ,
942- backend : {
943- loadPath : process . env . NODE_ENV === 'development'
944- ? path . join ( __dirname , '..' , '..' , 'static' , 'locales' , '{{lng}}.yaml' )
945- : asarToTmp ( path . join ( 'dist' , 'static' , 'locales' , targetLocale + '.json.br' ) , true )
946- } ,
947- interpolation : {
948- escapeValue : false
949- }
950- } )
951- } )
952-
953918 function relaunch ( ) {
954919 if ( process . env . NODE_ENV === 'development' ) {
955920 app . exit ( parseInt ( process . env . FREETUBE_RELAUNCH_EXIT_CODE ) )
0 commit comments