Skip to content

Commit e072c77

Browse files
committed
store widget not loading on first visit
1 parent 603b8ec commit e072c77

5 files changed

Lines changed: 49 additions & 45 deletions

File tree

.millennium/Dist/webkit.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Millennium, IconsModule, definePlugin, callable } from '@steambrew/client';
2+
import type { MilleniumWindowContext } from './types/millennium';
23

34
const fetchPrices = callable<[{ steam_app_id: string }], string>('fetch_prices');
45
const getApiKey = callable<[], string>('get_api_key');
@@ -75,7 +76,7 @@ interface Response { success: boolean; data: Record<string, Game|null>; error?:
7576

7677
function detectAppId(): number | null {
7778
try {
78-
const p = (window as any).MainWindowBrowserManager?.m_lastLocation?.pathname;
79+
const p = window.MainWindowBrowserManager?.m_lastLocation?.pathname;
7980
if (p) { const m = p.match(/\/app\/(\d+)/); if (m) return parseInt(m[1], 10); }
8081
} catch {}
8182
return null;
@@ -253,7 +254,7 @@ function Settings() {
253254
R.createElement('div', { style: { marginBottom: 16 } },
254255
R.createElement('label', { style: { fontSize: 12, fontWeight: 600, display: 'block', marginBottom: 6 } }, 'GG.deals API Key'),
255256
R.createElement('input', {
256-
type: 'password', value: key, onChange: (e: any) => setKey(e.target.value),
257+
type: 'password', value: key, onChange: (e:{ target: { value: string } }) => setKey(e.target.value),
257258
placeholder: 'Paste your API key here...',
258259
style: { width: '100%', padding: '8px 12px', fontSize: 13, background: 'rgba(0,0,0,0.3)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: 4, color: '#fff', outline: 'none', boxSizing: 'border-box' as const },
259260
}),
@@ -278,7 +279,7 @@ function Settings() {
278279

279280
export default definePlugin(() => {
280281
checkKey();
281-
Millennium.AddWindowCreateHook?.((ctx: any) => {
282+
Millennium.AddWindowCreateHook?.((ctx: MilleniumWindowContext) => {
282283
if (!ctx?.m_strName?.startsWith('SP ')) return;
283284
const doc = ctx.m_popup?.document;
284285
if (!doc?.body) return;
@@ -289,6 +290,4 @@ export default definePlugin(() => {
289290
icon: window.SP_REACT.createElement(IconsModule.Settings, null),
290291
content: window.SP_REACT.createElement(Settings, null),
291292
};
292-
});
293-
294-
declare global { interface Window { SP_REACT: any; MainWindowBrowserManager: any; } }
293+
});

frontend/types/millennium.d.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
interface SteamLocation {
2+
pathname: string;
3+
}
4+
5+
interface MainWindowBrowserManager {
6+
m_lastLocation?: SteamLocation
7+
}
8+
9+
interface MilleniumPopup {
10+
document: Document;
11+
}
12+
13+
interface MilleniumWindowContext {
14+
m_strName?: string;
15+
m_popup?: MilleniumPopup;
16+
}
17+
18+
declare global {
19+
interface Window {
20+
SP_REACT: typeof import('react');
21+
MainWindowBrowserManager?: MainWindowBrowserManager;
22+
}
23+
}
24+
25+
export type { MilleniumWindowContext };

0 commit comments

Comments
 (0)