diff --git a/package.json b/package.json index d2a5d9c8..21dccaa2 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "demo": "run-os", "demo:win32": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file:///src/demo/index.html", "demo:darwin": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/src/demo/index.html", + "format": "pretty-quick", "lint": "run-s lint:*", "lint:project": "tslint --project tsconfig.json", "lint:spec": "tslint --project tsconfig.spec.json", diff --git a/src/renderer/components/about-app.tsx b/src/renderer/components/about-app.tsx index cb203eca..1e900e0f 100644 --- a/src/renderer/components/about-app.tsx +++ b/src/renderer/components/about-app.tsx @@ -72,7 +72,7 @@ export default class AboutApp extends React.Component<{}, IState> { } /** - * main render function + * Renders the component */ public render(): JSX.Element { const { @@ -144,10 +144,16 @@ export default class AboutApp extends React.Component<{}, IState> { ); } + /** + * Callback to handle event when a component is mounted + */ public componentDidMount(): void { ipcRenderer.on('about-app-data', this.updateState); } + /** + * Callback to handle event when a component is unmounted + */ public componentWillUnmount(): void { ipcRenderer.removeListener('about-app-data', this.updateState); } diff --git a/src/renderer/components/basic-auth.tsx b/src/renderer/components/basic-auth.tsx index 6da7f040..dedadf19 100644 --- a/src/renderer/components/basic-auth.tsx +++ b/src/renderer/components/basic-auth.tsx @@ -32,16 +32,22 @@ export default class BasicAuth extends React.Component<{}, IState> { this.updateState = this.updateState.bind(this); } + /** + * Callback to handle event when a component is mounted + */ public componentDidMount(): void { ipcRenderer.on('basic-auth-data', this.updateState); } + /** + * Callback to handle event when a component is unmounted + */ public componentWillUnmount(): void { ipcRenderer.removeListener('basic-auth-data', this.updateState); } /** - * main render function + * Renders the component */ public render(): JSX.Element { const { hostname, isValidCredentials } = this.state; diff --git a/src/renderer/components/loading-screen.tsx b/src/renderer/components/loading-screen.tsx index 73904744..82fa412f 100644 --- a/src/renderer/components/loading-screen.tsx +++ b/src/renderer/components/loading-screen.tsx @@ -28,16 +28,22 @@ export default class LoadingScreen extends React.Component<{}, IState> { this.updateState = this.updateState.bind(this); } + /** + * Callback to handle event when a component is mounted + */ public componentDidMount(): void { ipcRenderer.on('loading-screen-data', this.updateState); } + /** + * Callback to handle event when a component is unmounted + */ public componentWillUnmount(): void { ipcRenderer.removeListener('loading-screen-data', this.updateState); } /** - * main render function + * Renders the component */ public render(): JSX.Element { const { error } = this.state; diff --git a/src/renderer/components/notification-comp.tsx b/src/renderer/components/notification-comp.tsx index 072504b7..6c172579 100644 --- a/src/renderer/components/notification-comp.tsx +++ b/src/renderer/components/notification-comp.tsx @@ -92,17 +92,23 @@ export default class NotificationComp extends React.Component<{}, IState> { this.input = React.createRef(); } + /** + * Callback to handle event when a component is mounted + */ public componentDidMount(): void { ipcRenderer.on('notification-data', this.updateState); } + /** + * Callback to handle event when a component is unmounted + */ public componentWillUnmount(): void { ipcRenderer.removeListener('notification-data', this.updateState); this.clearFlashInterval(); } /** - * Renders the custom title bar + * Renders the component */ public render(): JSX.Element { const { diff --git a/src/renderer/components/screen-picker.tsx b/src/renderer/components/screen-picker.tsx index 1ff5fabe..51928361 100644 --- a/src/renderer/components/screen-picker.tsx +++ b/src/renderer/components/screen-picker.tsx @@ -63,6 +63,9 @@ export default class ScreenPicker extends React.Component<{}, IState> { this.renderTabTitles = this.renderTabTitles.bind(this); } + /** + * Callback to handle event when a component is mounted + */ public componentDidMount(): void { ipcRenderer.on('screen-picker-data', this.updateState); document.addEventListener('keyup', this.handleKeyUpPress, true); @@ -71,13 +74,16 @@ export default class ScreenPicker extends React.Component<{}, IState> { } } + /** + * Callback to handle event when a component is unmounted + */ public componentWillUnmount(): void { ipcRenderer.removeListener('screen-picker-data', this.updateState); document.removeEventListener('keyup', this.handleKeyUpPress, true); } /** - * main render function + * Renders the component */ public render(): JSX.Element { const { sources, selectedSource } = this.state; diff --git a/src/renderer/components/screen-sharing-indicator.tsx b/src/renderer/components/screen-sharing-indicator.tsx index 859bb48e..dacfe461 100644 --- a/src/renderer/components/screen-sharing-indicator.tsx +++ b/src/renderer/components/screen-sharing-indicator.tsx @@ -35,7 +35,7 @@ export default class ScreenSharingIndicator extends React.Component< } /** - * main render function + * Renders the component */ public render(): JSX.Element { const { id } = this.state; @@ -64,10 +64,16 @@ export default class ScreenSharingIndicator extends React.Component< ); } + /** + * Callback to handle event when a component is mounted + */ public componentDidMount(): void { ipcRenderer.on('screen-sharing-indicator-data', this.updateState); } + /** + * Callback to handle event when a component is unmounted + */ public componentWillUnmount(): void { ipcRenderer.removeListener( 'screen-sharing-indicator-data', diff --git a/src/renderer/components/windows-title-bar.tsx b/src/renderer/components/windows-title-bar.tsx index 1c824434..a42c1f9c 100644 --- a/src/renderer/components/windows-title-bar.tsx +++ b/src/renderer/components/windows-title-bar.tsx @@ -50,6 +50,9 @@ export default class WindowsTitleBar extends React.Component<{}, IState> { ); } + /** + * Callback to handle event when a component is mounted + */ public componentDidMount(): void { const target = document.querySelector('title'); this.observer = new MutationObserver((mutations) => { @@ -72,6 +75,9 @@ export default class WindowsTitleBar extends React.Component<{}, IState> { }, 10000); } + /** + * Callback to handle event when a component is unmounted + */ public componentWillUnmount(): void { if (this.observer) { this.observer.disconnect(); @@ -79,7 +85,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> { } /** - * Renders the custom title bar + * Renders the component */ public render(): JSX.Element | null { const { title, isFullScreen } = this.state; diff --git a/tslint.json b/tslint.json index bc2a5117..91c55867 100644 --- a/tslint.json +++ b/tslint.json @@ -23,7 +23,6 @@ ], "no-empty": true, "no-unused-expression": true, - "no-use-before-declare": true, "no-implicit-dependencies": [true, "dev", "optional"], "no-object-literal-type-assertion": false, "no-var-requires": true,