Skip to content

Commit 402fec0

Browse files
authored
fix: Bugs related to focused webContents (#1525)
* Handle webcontents focus/blur * Use focused webcontents on menu bar * Add editFlags reducer * Add WebViewComponent * Use Loading component from Fuselage * Add ReparentingContainer * Add FailureImage * Add better webContents handling on WebViewComponent * Fix ids in FailureImage * Update navigation events for webviews * Add wrapper on ServerPane * Add Shell * Fix reloading state
1 parent 23acf42 commit 402fec0

30 files changed

Lines changed: 4831 additions & 308 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"@babel/preset-react": "^7.8.3",
6666
"@fiahfy/icns-convert": "^0.0.8",
6767
"@rocket.chat/eslint-config": "^0.4.0",
68-
"@rocket.chat/fuselage": "^0.2.0-dev.106",
68+
"@rocket.chat/fuselage": "^0.2.0-dev.111",
6969
"@rocket.chat/fuselage-hooks": "^0.2.0-dev.94",
7070
"babel-eslint": "^10.0.3",
7171
"builtin-modules": "^3.0.0",

src/actions.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ export const DEEP_LINK_TRIGGERED = 'deep-link/triggered';
1111
export const DEEP_LINKS_SERVER_ADDED = 'deep-links/server-added';
1212
export const DEEP_LINKS_SERVER_FOCUSED = 'deep-links/server-focused';
1313
export const LOADING_ERROR_VIEW_RELOAD_SERVER_CLICKED = 'loading-error-view/reload-server-clicked';
14+
export const MAIN_WINDOW_EDIT_FLAGS_CHANGED = 'main-window/edit-flags-changed';
1415
export const MAIN_WINDOW_INSTALL_UPDATE_CLICKED = 'main-window/install-update-clicked';
1516
export const MAIN_WINDOW_STATE_CHANGED = 'main-window/state-changed';
17+
export const MAIN_WINDOW_WEBCONTENTS_FOCUSED = 'main-window/webcontents-focused';
1618
export const MENU_BAR_ABOUT_CLICKED = 'menu-bar/about-clicked';
1719
export const MENU_BAR_ADD_NEW_SERVER_CLICKED = 'menu-bar/add-new-server-clicked';
1820
export const MENU_BAR_CLEAR_TRUSTED_CERTIFICATES_CLICKED = 'menu-bar/clear-trusted-certificates-clicked';
@@ -65,6 +67,7 @@ export const UPDATES_UPDATE_DOWNLOADED = 'updates/update-downloaded';
6567
export const WEBVIEW_CERTIFICATE_DENIED = 'webview/certificate-denied';
6668
export const WEBVIEW_CERTIFICATE_TRUSTED = 'webview/certificate-trusted';
6769
export const WEBVIEW_DID_NAVIGATE = 'webview/did-navigate';
70+
export const WEBVIEW_EDIT_FLAGS_CHANGED = 'webview/edit-flags-changed';
6871
export const WEBVIEW_FAVICON_CHANGED = 'webview/favicon-changed';
6972
export const WEBVIEW_FOCUS_REQUESTED = 'webview/focus-requested';
7073
export const WEBVIEW_FOCUSED = 'webview/focused';

src/components/AboutDialog/index.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Button, Field, Flex, Margins, ToggleSwitch } from '@rocket.chat/fuselage';
1+
import { Box, Button, Field, Flex, Loading, Margins, ToggleSwitch } from '@rocket.chat/fuselage';
22
import { useUniqueId } from '@rocket.chat/fuselage-hooks';
33
import { remote } from 'electron';
44
import React, { useState, useRef, useEffect, useMemo } from 'react';
@@ -18,10 +18,6 @@ import {
1818
} from '../../actions';
1919
import { RocketChatLogo } from '../RocketChatLogo.js';
2020
import { useSaga } from '../SagaMiddlewareProvider';
21-
import {
22-
LoadingIndicator,
23-
LoadingIndicatorDot,
24-
} from './styles.js';
2521
import { Dialog } from '../Dialog/index.js';
2622

2723
export function AboutDialog() {
@@ -130,15 +126,11 @@ export function AboutDialog() {
130126

131127
<Margins inline='auto' block='x8'>
132128
{checkingForUpdates && <Box>
133-
{checkingForUpdatesMessage
134-
? <Margins block='x12'>
135-
<Box textStyle='c1' textColor='info'>{checkingForUpdatesMessage}</Box>
136-
</Margins>
137-
: <LoadingIndicator>
138-
<LoadingIndicatorDot />
139-
<LoadingIndicatorDot />
140-
<LoadingIndicatorDot />
141-
</LoadingIndicator>}
129+
<Margins block='x12'>
130+
{checkingForUpdatesMessage
131+
? <Box textStyle='c1' textColor='info'>{checkingForUpdatesMessage}</Box>
132+
: <Loading size='x16' />}
133+
</Margins>
142134
</Box>}
143135

144136
<Field.Row>

src/components/AboutDialog/styles.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/components/AddServerView/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const defaultServerUrl = 'https://open.rocket.chat';
2727

2828
export function AddServerView() {
2929
const isVisible = useSelector(({ currentServerUrl }) => currentServerUrl === null);
30-
const isFull = useSelector(({ servers, isSideBarEnabled }) => !(servers.length > 0 && isSideBarEnabled));
3130
const dispatch = useDispatch();
3231
const { t } = useTranslation();
3332
const [input, setInput] = useState('');
@@ -129,7 +128,7 @@ export function AddServerView() {
129128
inputRef.current.focus();
130129
}, [isVisible]);
131130

132-
return <Wrapper isVisible={isVisible} isFull={isFull}>
131+
return <Wrapper isVisible={isVisible}>
133132
<Content>
134133
<Margins block='x16'>
135134
<Box>

src/components/AddServerView/styles.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ import { css } from '@emotion/core';
22
import styled from '@emotion/styled';
33

44
export const Wrapper = styled.section`
5-
position: fixed;
5+
position: absolute;
6+
left: 0;
67
top: 0;
78
right: 0;
89
bottom: 0;
9-
overflow-y: auto;
1010
background-color: #2f343d;
11+
12+
overflow-y: auto;
1113
align-items: center;
1214
-webkit-app-region: drag;
1315
justify-content: center;
1416
1517
${ ({ isVisible }) => css`display: ${ isVisible ? 'flex' : 'none' };` };
16-
${ ({ isFull }) => css`left: ${ isFull ? '0' : '68px' };` }
1718
`;
1819

1920
export const Content = styled.div`

src/components/App.js

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { remote } from 'electron';
22
import i18n from 'i18next';
3-
import React, { useEffect, useState, Component } from 'react';
3+
import React, { useEffect, useState } from 'react';
44
import { I18nextProvider, useTranslation } from 'react-i18next';
55
import { Provider, useDispatch } from 'react-redux';
66
import { call, put, select, takeEvery } from 'redux-saga/effects';
@@ -17,20 +17,15 @@ import {
1717
WEBVIEW_CERTIFICATE_TRUSTED,
1818
} from '../actions';
1919
import { MainWindow } from './MainWindow';
20-
import { AboutDialog } from './AboutDialog';
21-
import { ScreenSharingDialog } from './ScreenSharingDialog';
22-
import { UpdateDialog } from './UpdateDialog';
23-
import { SideBar } from './SideBar';
24-
import { ServersView } from './ServersView';
25-
import { AddServerView } from './AddServerView';
2620
import { TrayIcon } from './TrayIcon';
2721
import { MenuBar } from './MenuBar';
2822
import { Dock } from './Dock';
2923
import { TouchBar } from './TouchBar';
3024
import { createReduxStoreAndSagaMiddleware } from '../storeAndEffects';
3125
import { SagaMiddlewareProvider, useSaga } from './SagaMiddlewareProvider';
3226
import { validateServerUrl } from '../sagas/servers';
33-
import { SelectClientCertificateDialog } from './SelectClientCertificateDialog';
27+
import { Shell } from './Shell';
28+
import { ErrorCatcher } from './utils/ErrorCatcher';
3429

3530
function AppContent() {
3631
const { t } = useTranslation();
@@ -148,34 +143,13 @@ function AppContent() {
148143

149144
return <MainWindow>
150145
<MenuBar />
151-
<SideBar />
152-
<ServersView />
153-
<AddServerView />
154-
<AboutDialog />
155-
<ScreenSharingDialog />
156-
<SelectClientCertificateDialog />
157-
<UpdateDialog />
146+
<Shell />
158147
<Dock />
159148
<TrayIcon />
160149
<TouchBar />
161150
</MainWindow>;
162151
}
163152

164-
class ErrorCatcher extends Component {
165-
componentDidCatch(error, errorInfo) {
166-
console.error(error);
167-
console.error(errorInfo.componentStack);
168-
remote.dialog.showErrorBox(error.message, error.stack);
169-
process.exit(1);
170-
}
171-
172-
render() {
173-
return <>
174-
{this.props.children}
175-
</>;
176-
}
177-
}
178-
179153
export function App() {
180154
const [[store, sagaMiddleware]] = useState(() => createReduxStoreAndSagaMiddleware());
181155

0 commit comments

Comments
 (0)