Skip to content

Commit 6cab6b8

Browse files
authored
Revert "[Tech/UX] Allow for separate library refreshes (Heroic-Games-Launcher#1356)"
This reverts commit 37cdf7e.
1 parent 2930644 commit 6cab6b8

File tree

6 files changed

+23
-52
lines changed

6 files changed

+23
-52
lines changed

electron/main.ts

+9-27
Original file line numberDiff line numberDiff line change
@@ -590,18 +590,10 @@ ipcMain.handle(
590590

591591
/// IPC handlers begin here.
592592

593-
ipcMain.handle('checkGameUpdates', async (event, library?: Runner) => {
594-
switch (library) {
595-
case 'legendary':
596-
return LegendaryLibrary.get().listUpdateableGames()
597-
case 'gog':
598-
return GOGLibrary.get().listUpdateableGames()
599-
default:
600-
return [
601-
...(await LegendaryLibrary.get().listUpdateableGames()),
602-
...(await GOGLibrary.get().listUpdateableGames())
603-
]
604-
}
593+
ipcMain.handle('checkGameUpdates', async () => {
594+
const legendaryUpdates = await LegendaryLibrary.get().listUpdateableGames()
595+
const gogUpdates = await GOGLibrary.get().listUpdateableGames()
596+
return [...legendaryUpdates, ...gogUpdates]
605597
})
606598

607599
ipcMain.handle('getEpicGamesStatus', async () => isEpicServiceOffline())
@@ -755,21 +747,11 @@ if (existsSync(installed)) {
755747
})
756748
}
757749

758-
ipcMain.handle('refreshLibrary', async (e, fullRefresh, library?: Runner) => {
759-
switch (library) {
760-
case 'legendary':
761-
await LegendaryLibrary.get().getGames('info', fullRefresh)
762-
break
763-
case 'gog':
764-
await GOGLibrary.get().sync()
765-
break
766-
default:
767-
await Promise.allSettled([
768-
LegendaryLibrary.get().getGames('info', fullRefresh),
769-
GOGLibrary.get().sync()
770-
])
771-
break
772-
}
750+
ipcMain.handle('refreshLibrary', async (e, fullRefresh) => {
751+
await Promise.allSettled([
752+
GOGLibrary.get().sync(),
753+
LegendaryLibrary.get().getGames('info', fullRefresh)
754+
])
773755
})
774756

775757
ipcMain.on('logError', (e, err) => logError(`${err}`, LogPrefix.Frontend))

src/components/UI/ActionIcons/index.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,15 @@ import { useTranslation } from 'react-i18next'
1515
import ContextProvider from 'src/state/ContextProvider'
1616
import FormControl from '../FormControl'
1717
import './index.css'
18-
import { Runner } from 'src/types'
1918

2019
interface Props {
2120
sortDescending: boolean
2221
sortInstalled: boolean
2322
toggleSortDescending: () => void
2423
toggleSortinstalled: () => void
25-
library: Runner
2624
}
2725

2826
export default function ActionIcons({
29-
library,
3027
sortDescending,
3128
toggleSortDescending,
3229
sortInstalled,
@@ -88,8 +85,7 @@ export default function ActionIcons({
8885
refreshLibrary({
8986
checkForUpdates: true,
9087
fullRefresh: true,
91-
runInBackground: false,
92-
library
88+
runInBackground: false
9389
})
9490
}
9591
>

src/screens/Game/GameSubMenu/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default function GamesSubmenu({
7979
})
8080
if (path) {
8181
await renderer.invoke('changeInstallPath', [appName, path, runner])
82-
await refresh(runner)
82+
await refresh()
8383
}
8484
return
8585
}

src/screens/Library/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export default function Library(): JSX.Element {
105105
sortDescending={sortDescending}
106106
toggleSortDescending={() => handleSortDescending()}
107107
sortInstalled={sortInstalled}
108-
library={category === 'epic' ? 'legendary' : 'gog'}
109108
toggleSortinstalled={() => handleSortInstalled()}
110109
/>
111110
</div>

src/state/GlobalState.tsx

+11-16
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
InstalledInfo,
99
LibraryTopSectionOptions,
1010
RefreshOptions,
11-
Runner,
1211
WineVersionInfo
1312
} from 'src/types'
1413
import { TFunction, withTranslation } from 'react-i18next'
@@ -233,13 +232,12 @@ export class GlobalState extends PureComponent<Props> {
233232
this.setState({ libraryTopSection: value })
234233
}
235234

236-
handleSuccessfulLogin = (runner: Runner) => {
235+
handleSuccessfulLogin = (runner: 'epic' | 'gog') => {
237236
this.handleFilter('all')
238237
this.handleCategory(runner)
239238
this.refreshLibrary({
240239
fullRefresh: true,
241-
runInBackground: false,
242-
library: runner
240+
runInBackground: false
243241
})
244242
}
245243

@@ -255,7 +253,7 @@ export class GlobalState extends PureComponent<Props> {
255253
}
256254
})
257255

258-
this.handleSuccessfulLogin('legendery' as Runner)
256+
this.handleSuccessfulLogin('epic')
259257
}
260258

261259
return response.status
@@ -291,7 +289,7 @@ export class GlobalState extends PureComponent<Props> {
291289
window.location.reload()
292290
}
293291

294-
refresh = async (library?: Runner, checkUpdates?: boolean): Promise<void> => {
292+
refresh = async (checkUpdates?: boolean): Promise<void> => {
295293
console.log('refreshing')
296294

297295
let updates = this.state.gameUpdates
@@ -311,7 +309,7 @@ export class GlobalState extends PureComponent<Props> {
311309

312310
try {
313311
updates = checkUpdates
314-
? await ipcRenderer.invoke('checkGameUpdates', library)
312+
? await ipcRenderer.invoke('checkGameUpdates')
315313
: this.state.gameUpdates
316314
} catch (error) {
317315
ipcRenderer.send('logError', error)
@@ -340,8 +338,7 @@ export class GlobalState extends PureComponent<Props> {
340338
refreshLibrary = async ({
341339
checkForUpdates,
342340
fullRefresh,
343-
runInBackground = true,
344-
library = undefined
341+
runInBackground = true
345342
}: RefreshOptions): Promise<void> => {
346343
if (this.state.refreshing) return
347344

@@ -351,11 +348,11 @@ export class GlobalState extends PureComponent<Props> {
351348
})
352349
ipcRenderer.send('logInfo', 'Refreshing Library')
353350
try {
354-
await ipcRenderer.invoke('refreshLibrary', fullRefresh, library)
351+
await ipcRenderer.invoke('refreshLibrary', fullRefresh)
355352
} catch (error) {
356353
ipcRenderer.send('logError', error)
357354
}
358-
this.refresh(library, checkForUpdates)
355+
this.refresh(checkForUpdates)
359356
}
360357

361358
refreshWineVersionInfo = async (fetch: boolean): Promise<void> => {
@@ -410,8 +407,7 @@ export class GlobalState extends PureComponent<Props> {
410407
appName,
411408
status,
412409
folder,
413-
progress,
414-
runner
410+
progress
415411
}: GameStatus) => {
416412
const { libraryStatus, gameUpdates } = this.state
417413
const currentApp = libraryStatus.filter(
@@ -444,8 +440,7 @@ export class GlobalState extends PureComponent<Props> {
444440
// This avoids calling legendary again before the previous process is killed when canceling
445441
this.refreshLibrary({
446442
checkForUpdates: true,
447-
runInBackground: true,
448-
library: runner
443+
runInBackground: true
449444
})
450445

451446
storage.setItem(
@@ -459,7 +454,7 @@ export class GlobalState extends PureComponent<Props> {
459454
})
460455
}
461456

462-
this.refreshLibrary({ runInBackground: true, library: runner })
457+
this.refreshLibrary({ runInBackground: true })
463458
this.setState({ libraryStatus: newLibraryStatus })
464459
}
465460
}

src/types.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export interface ContextType {
7070
libraryTopSection: string
7171
handleLibraryTopSection: (value: LibraryTopSectionOptions) => void
7272
platform: NodeJS.Platform | string
73-
refresh: (library: Runner, checkUpdates?: boolean) => Promise<void>
73+
refresh: (checkUpdates?: boolean) => Promise<void>
7474
refreshLibrary: (options: RefreshOptions) => Promise<void>
7575
refreshWineVersionInfo: (fetch: boolean) => void
7676
refreshing: boolean
@@ -267,7 +267,6 @@ export interface Path {
267267
export type RefreshOptions = {
268268
checkForUpdates?: boolean
269269
fullRefresh?: boolean
270-
library?: Runner
271270
runInBackground?: boolean
272271
}
273272

0 commit comments

Comments
 (0)