Skip to content

Commit 3fcfcf7

Browse files
committed
[chore] lint
1 parent c29b62a commit 3fcfcf7

File tree

3 files changed

+99
-86
lines changed

3 files changed

+99
-86
lines changed

src/main/index.ts

+43-41
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ function createMainWindow() {
7878
if (overlayWindow != null) {
7979
try {
8080
overlayWindow.close();
81-
} catch (_) {}
81+
} catch (_) {
82+
console.error(_);
83+
}
8284
overlayWindow = null;
8385
}
8486
});
@@ -93,6 +95,46 @@ function createMainWindow() {
9395
return window;
9496
}
9597

98+
function createOverlay() {
99+
const window = new BrowserWindow({
100+
width: 400,
101+
height: 300,
102+
webPreferences: {
103+
nodeIntegration: true,
104+
webSecurity: false,
105+
},
106+
...electronOverlayWindow.WINDOW_OPTS,
107+
});
108+
109+
if (isDevelopment) {
110+
window.loadURL(
111+
`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}?version=${autoUpdater.currentVersion.version}&view=overlay`
112+
);
113+
} else {
114+
window.loadURL(
115+
formatUrl({
116+
pathname: joinPath(__dirname, 'index.html'),
117+
protocol: 'file',
118+
query: {
119+
version: autoUpdater.currentVersion.version,
120+
view: 'overlay',
121+
},
122+
slashes: true,
123+
})
124+
);
125+
}
126+
window.setIgnoreMouseEvents(true);
127+
electronOverlayWindow.attachTo(window, 'Among Us');
128+
129+
if (isDevelopment) {
130+
// Force devtools into detached mode otherwise they are unusable
131+
window.webContents.openDevTools({
132+
mode: 'detach',
133+
});
134+
}
135+
return window;
136+
}
137+
96138
const gotTheLock = app.requestSingleInstanceLock();
97139
if (!gotTheLock) {
98140
app.quit();
@@ -159,46 +201,6 @@ if (!gotTheLock) {
159201
}
160202
});
161203

162-
function createOverlay() {
163-
const window = new BrowserWindow({
164-
width: 400,
165-
height: 300,
166-
webPreferences: {
167-
nodeIntegration: true,
168-
webSecurity: false,
169-
},
170-
...electronOverlayWindow.WINDOW_OPTS,
171-
});
172-
173-
if (isDevelopment) {
174-
window.loadURL(
175-
`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}?version=${autoUpdater.currentVersion.version}&view=overlay`
176-
);
177-
} else {
178-
window.loadURL(
179-
formatUrl({
180-
pathname: joinPath(__dirname, 'index.html'),
181-
protocol: 'file',
182-
query: {
183-
version: autoUpdater.currentVersion.version,
184-
view: 'overlay',
185-
},
186-
slashes: true,
187-
})
188-
);
189-
}
190-
window.setIgnoreMouseEvents(true);
191-
electronOverlayWindow.attachTo(window, 'Among Us');
192-
193-
if (isDevelopment) {
194-
// Force devtools into detached mode otherwise they are unusable
195-
window.webContents.openDevTools({
196-
mode: 'detach',
197-
});
198-
}
199-
return window;
200-
}
201-
202204
// quit application when all windows are closed
203205
app.on('window-all-closed', () => {
204206
// on macOS it is common for applications to stay open until the user explicitly quits

src/renderer/App.tsx

+51-42
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {
22
Dispatch,
33
ErrorInfo,
4+
ReactChild,
45
SetStateAction,
56
useEffect,
67
useReducer,
@@ -116,12 +117,18 @@ enum AppState {
116117
VOICE,
117118
}
118119

120+
interface ErrorBoundaryProps {
121+
children: ReactChild;
122+
}
119123
interface ErrorBoundaryState {
120124
error?: Error;
121125
}
122126

123-
class ErrorBoundary extends React.Component<{}, ErrorBoundaryState> {
124-
constructor(props: {}) {
127+
class ErrorBoundary extends React.Component<
128+
ErrorBoundaryProps,
129+
ErrorBoundaryState
130+
> {
131+
constructor(props: ErrorBoundaryProps) {
125132
super(props);
126133
this.state = {};
127134
}
@@ -135,7 +142,7 @@ class ErrorBoundary extends React.Component<{}, ErrorBoundaryState> {
135142
console.error('React Error: ', error, errorInfo);
136143
}
137144

138-
render() {
145+
render(): ReactChild {
139146
if (this.state.error) {
140147
return (
141148
<div style={{ paddingTop: 16 }}>
@@ -170,7 +177,7 @@ class ErrorBoundary extends React.Component<{}, ErrorBoundaryState> {
170177
}
171178
}
172179

173-
export default function App() {
180+
const App: React.FC = function () {
174181
const [state, setState] = useState<AppState>(AppState.MENU);
175182
const [gameState, setGameState] = useState<AmongUsState>({} as AmongUsState);
176183
const [settingsOpen, setSettingsOpen] = useState(false);
@@ -289,52 +296,54 @@ export default function App() {
289296
setSettingsOpen={setSettingsOpen}
290297
/>
291298
<ErrorBoundary>
292-
<Settings
293-
open={settingsOpen}
294-
onClose={() => setSettingsOpen(false)}
295-
/>
296-
<Dialog fullWidth open={updaterState.state !== 'unavailable'}>
297-
<DialogTitle>Updating...</DialogTitle>
298-
<DialogContent>
299-
{(updaterState.state === 'downloading' ||
300-
updaterState.state === 'downloaded') &&
301-
updaterState.progress && (
302-
<>
303-
<LinearProgress
304-
variant={
305-
updaterState.state === 'downloaded'
306-
? 'indeterminate'
307-
: 'determinate'
308-
}
309-
value={updaterState.progress.percent}
310-
/>
311-
<DialogContentText>
312-
{prettyBytes(updaterState.progress.transferred)} /{' '}
313-
{prettyBytes(updaterState.progress.total)}
314-
</DialogContentText>
315-
</>
299+
<>
300+
<Settings
301+
open={settingsOpen}
302+
onClose={() => setSettingsOpen(false)}
303+
/>
304+
<Dialog fullWidth open={updaterState.state !== 'unavailable'}>
305+
<DialogTitle>Updating...</DialogTitle>
306+
<DialogContent>
307+
{(updaterState.state === 'downloading' ||
308+
updaterState.state === 'downloaded') &&
309+
updaterState.progress && (
310+
<>
311+
<LinearProgress
312+
variant={
313+
updaterState.state === 'downloaded'
314+
? 'indeterminate'
315+
: 'determinate'
316+
}
317+
value={updaterState.progress.percent}
318+
/>
319+
<DialogContentText>
320+
{prettyBytes(updaterState.progress.transferred)} /{' '}
321+
{prettyBytes(updaterState.progress.total)}
322+
</DialogContentText>
323+
</>
324+
)}
325+
{updaterState.state === 'error' && (
326+
<DialogContentText color="error">
327+
{updaterState.error}
328+
</DialogContentText>
316329
)}
330+
</DialogContent>
317331
{updaterState.state === 'error' && (
318-
<DialogContentText color="error">
319-
{updaterState.error}
320-
</DialogContentText>
332+
<DialogActions>
333+
<Button href="https://github.com/ottomated/CrewLink/releases/latest">
334+
Download Manually
335+
</Button>
336+
</DialogActions>
321337
)}
322-
</DialogContent>
323-
{updaterState.state === 'error' && (
324-
<DialogActions>
325-
<Button href="https://github.com/ottomated/CrewLink/releases/latest">
326-
Download Manually
327-
</Button>
328-
</DialogActions>
329-
)}
330-
</Dialog>
331-
{page}
338+
</Dialog>
339+
{page}
340+
</>
332341
</ErrorBoundary>
333342
</ThemeProvider>
334343
</SettingsContext.Provider>
335344
</LobbySettingsContext.Provider>
336345
</GameStateContext.Provider>
337346
);
338-
}
347+
};
339348

340349
ReactDOM.render(<App />, document.getElementById('app'));

src/renderer/Overlay.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface UseStylesProps {
1717
hudHeight: number;
1818
}
1919

20-
const useStyles = makeStyles((theme) => ({
20+
const useStyles = makeStyles(() => ({
2121
meetingHud: {
2222
position: 'absolute',
2323
top: '50%',
@@ -81,7 +81,7 @@ const playerColors = [
8181

8282
const iPadRatio = 854 / 579;
8383

84-
export default function Overlay() {
84+
const Overlay: React.FC = function () {
8585
const [gameState, setGameState] = useState<AmongUsState>(
8686
(undefined as unknown) as AmongUsState
8787
);
@@ -135,7 +135,7 @@ export default function Overlay() {
135135
)}
136136
</>
137137
);
138-
}
138+
};
139139

140140
interface AvatarOverlayProps {
141141
voiceState: VoiceState;
@@ -278,3 +278,5 @@ const MeetingHud: React.FC<MeetingHudProps> = ({
278278
};
279279

280280
ReactDOM.render(<Overlay />, document.getElementById('app'));
281+
282+
export default Overlay;

0 commit comments

Comments
 (0)