diff --git a/src/main/events/index.ts b/src/main/events/index.ts index 932b80e4..eff62531 100644 --- a/src/main/events/index.ts +++ b/src/main/events/index.ts @@ -1,4 +1,4 @@ -import { appVersion, defaultDownloadsPath } from "@main/constants"; +import { appVersion, defaultDownloadsPath, isStaging } from "@main/constants"; import { ipcMain } from "electron"; import "./catalogue/get-catalogue"; @@ -72,5 +72,6 @@ import "./misc/show-item-in-folder"; ipcMain.handle("ping", () => "pong"); ipcMain.handle("getVersion", () => appVersion); +ipcMain.handle("isStaging", () => isStaging); ipcMain.handle("isPortableVersion", () => isPortableVersion()); ipcMain.handle("getDefaultDownloadsPath", () => defaultDownloadsPath); diff --git a/src/preload/index.ts b/src/preload/index.ts index d8d142ca..0166ba2a 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -198,6 +198,7 @@ contextBridge.exposeInMainWorld("electron", { ping: () => ipcRenderer.invoke("ping"), getVersion: () => ipcRenderer.invoke("getVersion"), getDefaultDownloadsPath: () => ipcRenderer.invoke("getDefaultDownloadsPath"), + isStaging: () => ipcRenderer.invoke("isStaging"), isPortableVersion: () => ipcRenderer.invoke("isPortableVersion"), openExternal: (src: string) => ipcRenderer.invoke("openExternal", src), openCheckout: () => ipcRenderer.invoke("openCheckout"), diff --git a/src/renderer/src/components/sidebar/sidebar.tsx b/src/renderer/src/components/sidebar/sidebar.tsx index 75bd1b78..787cf66a 100644 --- a/src/renderer/src/components/sidebar/sidebar.tsx +++ b/src/renderer/src/components/sidebar/sidebar.tsx @@ -54,13 +54,16 @@ export function Sidebar() { useEffect(() => { if (userDetails) { - update({ - name: userDetails.displayName, - Username: userDetails.username, - email: userDetails.email ?? undefined, - Email: userDetails.email, - "Subscription expiration date": userDetails?.subscription?.expiresAt, - "Payment status": userDetails?.subscription?.status, + window.electron.isStaging().then((isStaging) => { + update({ + user_id: userDetails.id + (isStaging ? "-staging" : ""), + name: userDetails.displayName, + Username: userDetails.username, + email: userDetails.email ?? undefined, + Email: userDetails.email, + "Subscription expiration date": userDetails?.subscription?.expiresAt, + "Payment status": userDetails?.subscription?.status, + }); }); } }, [userDetails, hasActiveSubscription]); diff --git a/src/renderer/src/declaration.d.ts b/src/renderer/src/declaration.d.ts index 4065b64c..a1965b6a 100644 --- a/src/renderer/src/declaration.d.ts +++ b/src/renderer/src/declaration.d.ts @@ -162,6 +162,7 @@ declare global { openExternal: (src: string) => Promise; openCheckout: () => Promise; getVersion: () => Promise; + isStaging: () => Promise; ping: () => string; getDefaultDownloadsPath: () => Promise; isPortableVersion: () => Promise; diff --git a/src/shared/index.ts b/src/shared/index.ts index 173867df..699cc4d8 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -46,7 +46,7 @@ export const removeSymbolsFromName = (name: string) => export const removeSpecialEditionFromName = (name: string) => name.replace( - /(The |Digital )?(GOTY|Deluxe|Standard|Ultimate|Definitive|Enhanced|Collector's|Premium|Digital|Limited|Game of the Year|Reloaded|[0-9]{4}) Edition/g, + /(The |Digital )?(GOTY|Deluxe|Standard|Ultimate|Definitive|Enhanced|Collector's|Premium|Digital|Limited|Game of the Year|Reloaded|[0-9]{4}) Edition/gi, "" ); @@ -73,7 +73,8 @@ export const formatName = pipe( replaceUnderscoreWithSpace, replaceDotsWithSpace, replaceNbspWithSpace, - (str) => str.replace(/DIRECTOR'S CUT/g, ""), + (str) => str.replace(/DIRECTOR'S CUT/gi, ""), + (str) => str.replace(/Friend's Pass/gi, ""), removeSymbolsFromName, removeDuplicateSpaces, (str) => str.trim()