Skip to content

Commit

Permalink
fix(App): Improve layout rendering of services
Browse files Browse the repository at this point in the history
  • Loading branch information
adlk committed Apr 5, 2022
1 parent fb3988a commit ad3bb11
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 35 deletions.
37 changes: 21 additions & 16 deletions src/components/layout/AppLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Todos from '../../features/todos/containers/TodosScreen';
import TrialStatusBar from '../../features/trialStatusBar/containers/TrialStatusBarScreen';
import WebControlsScreen from '../../features/webControls/containers/WebControlsScreen';
import Service from '../../models/Service';
import { workspaceStore } from '../../features/workspaces';

function createMarkup(HTMLString) {
return { __html: HTMLString };
Expand Down Expand Up @@ -109,7 +110,6 @@ class AppLayout extends Component {
{workspacesDrawer}
{sidebar}
<div className="app__service">
<WorkspaceSwitchingIndicator />
{news.length > 0 && news.map(item => (
<InfoBar
key={item.id}
Expand All @@ -133,16 +133,16 @@ class AppLayout extends Component {
<TrialActivationInfoBar />
)}
{!areRequiredRequestsSuccessful && showRequiredRequestsError && (
<InfoBar
type="danger"
ctaLabel="Try again"
ctaLoading={areRequiredRequestsLoading}
sticky
onClick={retryRequiredRequests}
>
<span className="mdi mdi-flash" />
{intl.formatMessage(messages.requiredRequestsFailed)}
</InfoBar>
<InfoBar
type="danger"
ctaLabel="Try again"
ctaLoading={areRequiredRequestsLoading}
sticky
onClick={retryRequiredRequests}
>
<span className="mdi mdi-flash" />
{intl.formatMessage(messages.requiredRequestsFailed)}
</InfoBar>
)}
{showServicesUpdatedInfoBar && (
<InfoBar
Expand All @@ -165,11 +165,16 @@ class AppLayout extends Component {
/>
)}
{isDelayAppScreenVisible ? <DelayApp /> : (
<div className="app__service-size-container">
{services}
{children}
<Todos />
</div>
<>
<WorkspaceSwitchingIndicator />
{!workspaceStore.isSwitchingWorkspace && (
<div className="app__service-size-container">
{services}
{children}
<Todos />
</div>
)}
</>
)}
<TrialStatusBar />
</div>
Expand Down
43 changes: 24 additions & 19 deletions src/components/services/content/Services.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { Component, useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { observer } from 'mobx-react';
import { Link } from 'react-router';
Expand All @@ -25,6 +25,7 @@ const messages = defineMessages({
const styles = {
container: {
display: 'flex',
flex: 1,

'&>span': {
display: 'block',
Expand All @@ -51,23 +52,6 @@ export default @injectSheet(styles) @observer class Services extends Component {
intl: intlShape,
};

serviceContainerRef = React.createRef()

resizeObserver = new window.ResizeObserver(([element]) => {
const bounds = element.target.getBoundingClientRect();

ipcRenderer.send(RESIZE_SERVICE_VIEWS, {
width: bounds.width,
height: bounds.height,
x: bounds.x,
y: element.target.offsetTop,
});
});

componentDidMount() {
this.resizeObserver.observe(this.serviceContainerRef.current);
}

componentWillUnmount() {
if (this._confettiTimeout) {
clearTimeout(this._confettiTimeout);
Expand Down Expand Up @@ -127,10 +111,31 @@ export default @injectSheet(styles) @observer class Services extends Component {
upgrade={() => openSettings({ path: 'user' })}
/>
)}
<ResizeBWServiceComponent />
</>
)}
<div className="services" ref={this.serviceContainerRef} />
</>
);
}
}

const resizeObserver = new window.ResizeObserver(([element]) => {
const bounds = element.target.getBoundingClientRect();

ipcRenderer.send(RESIZE_SERVICE_VIEWS, {
width: bounds.width,
height: bounds.height,
x: bounds.x,
y: element.target.offsetTop,
});
});

const ResizeBWServiceComponent = () => {
const serviceContainerRef = useRef();

useEffect(() => {
resizeObserver.observe(serviceContainerRef.current);
}, [serviceContainerRef]);

return <div className="services" ref={serviceContainerRef} />;
};

0 comments on commit ad3bb11

Please sign in to comment.