Skip to content

Commit 6cdab3b

Browse files
committed
tech: frontend implementation
1 parent 6cbcb8d commit 6cdab3b

File tree

5 files changed

+60
-3
lines changed

5 files changed

+60
-3
lines changed

src/frontend/helpers/electronStores.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ const wineDownloaderInfoStore = new TypeCheckedStoreFrontend(
129129
)
130130

131131
const gogLibraryStore = new CacheStore<GameInfo[], 'games'>('gog_library', null)
132+
const steamLibraryStore = new CacheStore<GameInfo[], 'games'>(
133+
'steam_library',
134+
null
135+
)
132136
const gogInstalledGamesStore = new TypeCheckedStoreFrontend(
133137
'gogInstalledGamesStore',
134138
{
@@ -188,5 +192,6 @@ export {
188192
metricsStore,
189193
onboardingStore,
190194
newsLetterStore,
191-
hyperPlayLibraryStore
195+
hyperPlayLibraryStore,
196+
steamLibraryStore
192197
}

src/frontend/helpers/library.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ async function install({
5757
return
5858
}
5959

60+
if (gameInfo.runner === 'steam') {
61+
window.api.openExternalUrl(`steam://install/${gameInfo.app_name}`)
62+
return
63+
}
64+
6065
const { folder_name, is_installed, app_name: appName, runner } = gameInfo
6166

6267
if (isInstalling) {
@@ -148,6 +153,13 @@ const launch = async ({
148153
showDialogModal,
149154
isNotNative
150155
}: LaunchOptions): Promise<{ status: 'done' | 'error' | 'abort' }> => {
156+
if (runner === 'steam') {
157+
return new Promise((resolve) => {
158+
window.api.openExternalUrl(`steam://run/${appName}`)
159+
resolve({ status: 'done' })
160+
})
161+
}
162+
151163
const showCompatibilityWarningDialog: boolean =
152164
isNotNative &&
153165
JSON.parse(
@@ -284,5 +296,6 @@ export const epicCategories = ['all', 'legendary', 'epic']
284296
export const gogCategories = ['all', 'gog']
285297
export const sideloadedCategories = ['all', 'sideload']
286298
export const hyperPlayCategories = ['all', 'hyperplay']
299+
export const steamCategories = ['all', 'steam']
287300

288301
export { install, launch, repair, updateGame }

src/frontend/state/libraryState.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
libraryStore,
1919
sideloadLibrary,
2020
hyperPlayLibraryStore,
21+
steamLibraryStore,
2122
configStore
2223
} from 'frontend/helpers/electronStores'
2324
import {
@@ -54,6 +55,7 @@ class LibraryState {
5455
gogLibrary: GameInfo[] = []
5556
sideloadedLibrary: GameInfo[] = []
5657
hyperPlayLibrary: GameInfo[] = []
58+
steamLibrary: GameInfo[] = []
5759
nonAvailableGames: GameInfo[] = []
5860
// array of appName's for games that need updating
5961
gameUpdates: string[] = []
@@ -108,6 +110,8 @@ class LibraryState {
108110
this.sideloadedLibrary = newLibrary
109111
} else if (runner === 'hyperplay') {
110112
this.hyperPlayLibrary = newLibrary
113+
} else if (runner === 'steam') {
114+
this.steamLibrary = newLibrary
111115
}
112116
})
113117
}
@@ -153,6 +157,13 @@ class LibraryState {
153157
this.refreshGogLibrary()
154158
}
155159

160+
this.refreshSteamLibrary()
161+
if (!this.steamLibrary.length || !this.steamLibrary.length) {
162+
window.api.logInfo('No cache found, getting data from steam...')
163+
await window.api.refreshLibrary('steam')
164+
this.refreshSteamLibrary()
165+
}
166+
156167
this.refreshSideloadedLibrary()
157168

158169
this.hiddenGames.list = configStore.get('games.hidden', [])
@@ -197,6 +208,7 @@ class LibraryState {
197208
this.refreshGogLibrary()
198209
this.refreshSideloadedLibrary()
199210
this.refreshHyperplayLibrary()
211+
this.refreshSteamLibrary()
200212
}
201213

202214
refreshEpicLibrary() {
@@ -219,6 +231,10 @@ class LibraryState {
219231
this.gogLibrary = games
220232
}
221233

234+
refreshSteamLibrary() {
235+
this.steamLibrary = steamLibraryStore.get('games', [])
236+
}
237+
222238
refreshHyperplayLibrary() {
223239
this.hyperPlayLibrary = hyperPlayLibraryStore.get('games', [])
224240
}
@@ -314,6 +330,9 @@ class LibraryState {
314330
this.hyperPlayLibrary.forEach((game) => {
315331
if (favouriteAppNames.includes(game.app_name)) tempArray.push(game)
316332
})
333+
this.steamLibrary.forEach((game) => {
334+
if (favouriteAppNames.includes(game.app_name)) tempArray.push(game)
335+
})
317336
}
318337
return tempArray
319338
}
@@ -330,14 +349,22 @@ class LibraryState {
330349
const isGog = gogCategories.includes(this.category)
331350
const epicLibrary = isEpic ? this.epicLibrary : []
332351
const gogLibrary = isGog ? this.gogLibrary : []
352+
const steamLibrary =
353+
this.category === 'steam' ? steamLibraryStore.get('games', []) : []
333354
const sideloadedApps = sideloadedCategories.includes(this.category)
334355
? this.sideloadedLibrary
335356
: []
336357
const HPLibrary = hyperPlayCategories.includes(this.category)
337358
? this.hyperPlayLibrary
338359
: []
339360

340-
library = [...HPLibrary, ...sideloadedApps, ...epicLibrary, ...gogLibrary]
361+
library = [
362+
...HPLibrary,
363+
...sideloadedApps,
364+
...epicLibrary,
365+
...gogLibrary,
366+
...steamLibrary
367+
]
341368

342369
if (!this.showNonAvailable) {
343370
const nonAvailableAppNames = Object.fromEntries(

src/frontend/state/storeAuthState.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { SteamLoginUser } from 'common/types/steam'
12
import { configStore, gogConfigStore } from 'frontend/helpers/electronStores'
23
import { makeAutoObservable } from 'mobx'
34

@@ -8,6 +9,9 @@ class StoreAuthState {
89
gog = {
910
username: ''
1011
}
12+
steam = {
13+
enabledUsers: [] as SteamLoginUser[]
14+
}
1115

1216
constructor() {
1317
makeAutoObservable(this)
@@ -16,6 +20,8 @@ class StoreAuthState {
1620
init() {
1721
this.epic.username = configStore.get_nodefault('userInfo.displayName') ?? ''
1822
this.gog.username = gogConfigStore.get_nodefault('userData.username') ?? ''
23+
this.steam.enabledUsers =
24+
configStore.get_nodefault('steamEnabledUsers') ?? []
1925
}
2026
}
2127

src/frontend/types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ import {
1111
DownloadManagerState
1212
} from 'common/types'
1313

14-
export type Category = 'all' | 'legendary' | 'gog' | 'sideload' | 'hyperplay'
14+
export type Category =
15+
| 'all'
16+
| 'legendary'
17+
| 'gog'
18+
| 'sideload'
19+
| 'hyperplay'
20+
| 'steam'
1521

1622
export type Platform = 'win' | 'mac' | 'linux' | 'browser'
1723

0 commit comments

Comments
 (0)