File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,22 +56,18 @@ export class AccountAction {
5656
5757 switchWebview = accountIndex => {
5858 return async ( dispatch , getState ) => {
59- try {
60- const account = AccountSelector . getAccounts ( getState ( ) ) [ Math . max ( accountIndex , 0 ) ] ;
61- dispatch ( switchAccount ( account . id ) ) ;
59+ const account = AccountSelector . getAccounts ( getState ( ) ) [ Math . max ( accountIndex , 0 ) ] ;
60+ dispatch ( switchAccount ( account . id ) ) ;
6261
63- // Note: We need to focus window first to properly set focus
64- // on the webview with shortcuts like Cmd+1/2/3
65- window . blur ( ) ;
66- window . focus ( ) ;
62+ // Note: We need to focus window first to properly set focus
63+ // on the webview with shortcuts like Cmd+1/2/3
64+ window . blur ( ) ;
65+ window . focus ( ) ;
6766
68- const webview = document . querySelector ( `.Webview[data-accountid="${ account . id } "]` ) ;
69- if ( webview ) {
70- webview . blur ( ) ;
71- webview . focus ( ) ;
72- }
73- } catch ( error ) {
74- throw error ;
67+ const webview = document . querySelector ( `.Webview[data-accountid="${ account . id } "]` ) ;
68+ if ( webview ) {
69+ webview . blur ( ) ;
70+ webview . focus ( ) ;
7571 }
7672 } ;
7773 } ;
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ const Sidebar = ({
7070 < div
7171 style = { { color : colorFromId ( currentAccentID ) } }
7272 className = { getClassName ( account ) }
73- onClick = { preventFocus ( event =>
73+ onClick = { preventFocus ( ( ) =>
7474 window . dispatchEvent (
7575 new CustomEvent ( EVENT_TYPE . ACTION . SWITCH_ACCOUNT , { detail : { accountIndex : accounts . indexOf ( account ) } } ) ,
7676 ) ,
Original file line number Diff line number Diff line change @@ -83,16 +83,22 @@ const Webview = ({
8383 // https://github.com/electron/electron/issues/14474#issuecomment-425794480
8484 useEffect ( ( ) => {
8585 const webview = webviewRef . current ;
86- const listener = ( ) => {
87- webview . blur ( ) ;
88- webview . focus ( ) ;
86+ const currentLocation = new URL ( window . location . href ) ;
87+ const focusParam = currentLocation . searchParams . get ( 'focus' ) ;
88+
89+ const focusWebView = ( ) => {
90+ if ( focusParam && focusParam === 'true' ) {
91+ webview . blur ( ) ;
92+ webview . focus ( ) ;
93+ }
8994 } ;
95+
9096 if ( account . visible && webview ) {
91- webview . addEventListener ( 'dom-ready' , listener ) ;
97+ webview . addEventListener ( 'dom-ready' , focusWebView ) ;
9298 }
9399 return ( ) => {
94100 if ( webview ) {
95- webview . removeEventListener ( 'dom-ready' , listener ) ;
101+ webview . removeEventListener ( 'dom-ready' , focusWebView ) ;
96102 }
97103 } ;
98104 } , [ account , webviewRef ] ) ;
Original file line number Diff line number Diff line change @@ -63,7 +63,6 @@ export const EVENT_TYPE = {
6363 UNREAD_COUNT : 'EVENT_TYPE.LIFECYCLE.UNREAD_COUNT' ,
6464 } ,
6565 PREFERENCES : {
66- SET_HIDDEN : 'EVENT_TYPE.PREFERENCES.SET_HIDDEN' ,
6766 SHOW : 'EVENT_TYPE.PREFERENCES.SHOW' ,
6867 } ,
6968 PROXY_PROMPT : {
Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ const BASE_URL = EnvironmentUtil.web.getWebappUrl(argv[config.ARGUMENT.ENV]);
9393
9494const logger = getLogger ( path . basename ( __filename ) ) ;
9595const currentLocale = locale . getCurrent ( ) ;
96+ const startHidden = Boolean ( argv [ config . ARGUMENT . STARTUP ] || argv [ config . ARGUMENT . HIDDEN ] ) ;
9697
9798if ( argv [ config . ARGUMENT . VERSION ] ) {
9899 console . info ( config . version ) ;
@@ -244,7 +245,7 @@ const showMainWindow = async (mainWindowState: WindowStateKeeper.State) => {
244245 main . webContents . openDevTools ( { mode : 'detach' } ) ;
245246 }
246247
247- if ( ! argv [ config . ARGUMENT . STARTUP ] && ! argv [ config . ARGUMENT . HIDDEN ] ) {
248+ if ( ! startHidden ) {
248249 if ( ! WindowUtil . isInView ( main ) ) {
249250 main . center ( ) ;
250251 }
@@ -320,14 +321,11 @@ const showMainWindow = async (mainWindowState: WindowStateKeeper.State) => {
320321
321322 const mainURL = new URL ( fileUrl ( INDEX_HTML ) ) ;
322323 mainURL . searchParams . set ( 'env' , encodeURIComponent ( webappURL . href ) ) ;
324+ mainURL . searchParams . set ( 'focus' , String ( ! startHidden ) ) ;
323325
324326 await main . loadURL ( mainURL . href ) ;
325327 const wrapperCSSContent = await fs . readFile ( WRAPPER_CSS , 'utf8' ) ;
326328 await main . webContents . insertCSS ( wrapperCSSContent ) ;
327-
328- if ( argv [ config . ARGUMENT . STARTUP ] || argv [ config . ARGUMENT . HIDDEN ] ) {
329- WindowManager . sendActionToPrimaryWindow ( EVENT_TYPE . PREFERENCES . SET_HIDDEN ) ;
330- }
331329} ;
332330
333331// App Events
Original file line number Diff line number Diff line change @@ -79,10 +79,6 @@ const subscribeToMainProcessEvents = () => {
7979 ipcRenderer . on ( EVENT_TYPE . ACTION . SWITCH_ACCOUNT , ( event , accountIndex : number ) => {
8080 window . dispatchEvent ( new CustomEvent ( EVENT_TYPE . ACTION . SWITCH_ACCOUNT , { detail : { accountIndex} } ) ) ;
8181 } ) ;
82-
83- ipcRenderer . on ( EVENT_TYPE . PREFERENCES . SET_HIDDEN , ( ) => {
84- window . dispatchEvent ( new CustomEvent ( EVENT_TYPE . PREFERENCES . SET_HIDDEN ) ) ;
85- } ) ;
8682} ;
8783
8884const setupIpcInterface = ( ) : void => {
You can’t perform that action at this time.
0 commit comments