Skip to content

Commit 6cbcb8d

Browse files
committed
tech: types and edge cases
1 parent 2a0f8c5 commit 6cbcb8d

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

src/backend/cache.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Store from 'electron-store'
33
export default class CacheStore<ValueType, KeyType extends string = string> {
44
private readonly store: Store
55
private in_memory_store: Map<string, ValueType>
6-
private using_in_memory: boolean
6+
private using_in_memory: number
77
private current_store: Store | Map<string, ValueType>
88
private readonly lifespan: number | null
99

@@ -20,7 +20,7 @@ export default class CacheStore<ValueType, KeyType extends string = string> {
2020
clearInvalidConfig: true
2121
})
2222
this.in_memory_store = new Map<string, ValueType>()
23-
this.using_in_memory = false
23+
this.using_in_memory = 0
2424
this.current_store = this.store
2525
this.lifespan = max_value_lifespan
2626
}
@@ -31,7 +31,7 @@ export default class CacheStore<ValueType, KeyType extends string = string> {
3131
*/
3232
public use_in_memory() {
3333
// Mirror store to memory map
34-
this.using_in_memory = true
34+
this.using_in_memory += 1
3535
this.in_memory_store = new Map(this.store) as Map<string, ValueType>
3636
this.current_store = this.in_memory_store
3737
}
@@ -85,8 +85,10 @@ export default class CacheStore<ValueType, KeyType extends string = string> {
8585
public commit() {
8686
if (this.using_in_memory) {
8787
this.store.store = Object.fromEntries(this.in_memory_store)
88-
this.using_in_memory = false
89-
this.current_store = this.store
88+
this.using_in_memory -= 1
89+
if (this.using_in_memory === 0) {
90+
this.current_store = this.store
91+
}
9092
}
9193
}
9294
}

src/backend/logger/logger.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ export enum LogPrefix {
3535
Sideload = 'Sideload',
3636
Achievements = 'Achievements',
3737
Auth = 'Auth',
38-
AutoUpdater = 'AutoUpdater'
38+
AutoUpdater = 'AutoUpdater',
39+
Steam = 'Steam'
3940
}
4041

4142
export const RunnerToLogPrefixMap = {
4243
legendary: LogPrefix.Legendary,
4344
gog: LogPrefix.Gog,
4445
hyperplay: LogPrefix.HyperPlay,
45-
sideload: LogPrefix.Sideload
46+
sideload: LogPrefix.Sideload,
47+
steam: LogPrefix.Steam
4648
}
4749

4850
type LogInputType = unknown[] | unknown

src/backend/save_sync.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ async function getDefaultSavePath(
3737
return getDefaultLegendarySavePath(appName)
3838
case 'gog':
3939
return getDefaultGogSavePaths(appName, alreadyDefinedGogSaves)
40+
case 'steam':
4041
case 'sideload':
4142
return ''
4243
}

src/backend/shortcuts/nonesteamgame/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ const pictureExt = '.jpg'
55
const coverArtSufix = 'p' + pictureExt
66
const backGroundArtSufix = '_hero' + pictureExt
77
const logoArtSufix = '_logo' + pictureExt
8+
const steamDBBaseURL = 'https://cdn.steamstatic.com/steam/apps'
89

910
export {
1011
transparentSteamLogoHex,
1112
coverArtSufix,
1213
backGroundArtSufix,
1314
logoArtSufix,
14-
pictureExt
15+
pictureExt,
16+
steamDBBaseURL
1517
}

src/backend/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ function removeSpecialcharacters(text: string): string {
347347
}
348348

349349
async function openUrlOrFile(url: string): Promise<string | void> {
350-
if (url.startsWith('http')) {
350+
if (url.includes('://')) {
351351
return shell.openExternal(url)
352352
}
353353
return shell.openPath(url)
@@ -1205,14 +1205,15 @@ export const processIsClosed = async (pid: number) => {
12051205
}
12061206

12071207
type RunnerStore = {
1208-
[key in Runner]: 'Epic Games' | 'GOG' | 'HyperPlay' | 'Sideloaded'
1208+
[key in Runner]: 'Epic Games' | 'GOG' | 'HyperPlay' | 'Sideloaded' | 'Steam'
12091209
}
12101210

12111211
const runnerStore: RunnerStore = {
12121212
legendary: 'Epic Games',
12131213
gog: 'GOG',
12141214
hyperplay: 'HyperPlay',
1215-
sideload: 'Sideloaded'
1215+
sideload: 'Sideloaded',
1216+
steam: 'Steam'
12161217
}
12171218

12181219
export const getStoreName = (runner: Runner) => {

0 commit comments

Comments
 (0)