Skip to content

Commit

Permalink
Add example for using custom_id and referrer_id (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker authored Dec 17, 2024
1 parent f5012e0 commit 5accb83
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
18 changes: 16 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk-playground/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"tsc": "tsc"
},
"dependencies": {
"@discord/embedded-app-sdk": "^1.7.0",
"@discord/embedded-app-sdk": "^1.8.1",
"@radix-ui/colors": "^3.0.0",
"@radix-ui/react-scroll-area": "^1.0.1",
"@stitches/react": "^1.2.1",
Expand Down
14 changes: 13 additions & 1 deletion sdk-playground/packages/client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import {BrowserRouter as Router, Routes, Route, Link, useLocation} from 'react-router-dom';
import {BrowserRouter as Router, Routes, Route, Link, useLocation, useNavigate} from 'react-router-dom';

import * as Scrollable from './components/Scrollable';
import {AuthProvider} from './components/AuthProvider';
Expand Down Expand Up @@ -43,6 +43,8 @@ import {useState} from 'react';
import GetActivityInstance from "./pages/GetActivityInstance";
import CloseActivity from "./pages/CloseActivity";

import discordSdk from './discordSdk';

// Add contexts here
export default function App(): React.ReactElement {
return (
Expand Down Expand Up @@ -230,9 +232,19 @@ const routes: Record<string, AppRoute> = {
},
};

let navigateOnInit = true;

function RootedApp(): React.ReactElement {
const location = useLocation();
const [query, setQuery] = useState('');
const navigate = useNavigate();

React.useEffect(() => {
if (navigateOnInit && discordSdk.customId === 'PAGE_GET_SKUS') {
navigate('/get-skus');
navigateOnInit = false;
}
}, [navigate]);

return (
<S.SiteWrapper>
Expand Down
2 changes: 2 additions & 0 deletions sdk-playground/packages/client/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export default function Home() {
</p>
<br></br>
<h3> Basic Activity Info</h3>
<p> Custom ID: {discordSdk.customId} </p>
<p> Instance ID: {instanceId} </p>
<p> Referrer ID: {discordSdk.referrerId} </p>
<p> Client ID: {clientId} </p>
<p> Channel ID: {channelId} </p>
{ guildId != null ? (<p> Guild ID: {guildId} </p>) : null }
Expand Down

0 comments on commit 5accb83

Please sign in to comment.