Skip to content

Commit

Permalink
Merge pull request #31 from Milkshiift/main
Browse files Browse the repository at this point in the history
[shelteRPC] Proper app lookup
  • Loading branch information
SpikeHD committed Jun 28, 2024
2 parents eafbf68 + 394670e commit 9a5d2e1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions plugins/shelteRPC/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ interface AssetCache {

const {
flux: {
dispatcher: FluxDispatcher,
stores: { GameStore },
dispatcher: FluxDispatcher
},
settings: { registerSection },
ui: { showToast },
Expand All @@ -29,8 +28,8 @@ const apps: Record<string, { name: string } | string> = {}
// when we load, set current game as nothing
store.currentlyPlaying = ''

async function lookupApp(name: string): Promise<string> {
return GameStore.getGameByName(name)?.name || 'Unknown'
async function lookupApp(appId: string): Promise<string> {
return (await http.get(`/oauth2/applications/${appId}/rpc`))?.body || 'Unknown'
}

export const generateAssetId = async (appId: string, asset: string) => {
Expand Down Expand Up @@ -67,7 +66,7 @@ async function handleMessage(e: MessageEvent<string>) {

if (data.activity) {
const appId = data.activity.application_id
apps[appId] ||= await lookupApp(data.activity.name)
apps[appId] ||= await lookupApp(appId)

const app = apps[appId]
if (typeof app !== 'string') {
Expand Down

0 comments on commit 9a5d2e1

Please sign in to comment.