Skip to content

Commit

Permalink
Handle example opening messages from gd.games public profile
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreSi committed May 7, 2024
1 parent 701b5a3 commit 26f6230
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions newIDE/app/src/Profile/PublicProfileDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
type PrivateGameTemplateListingData,
type PrivateAssetPackListingData,
} from '../Utils/GDevelopServices/Shop';
import { type ExampleShortHeader } from '../Utils/GDevelopServices/Example';
import { useStableUpToDateCallback } from '../Utils/UseStableUpToDateCallback';

type Props = {|
Expand All @@ -18,15 +19,17 @@ type Props = {|
privateAssetPackListingData: PrivateAssetPackListingData
) => void,
onGameTemplateOpen?: (
privateAssetPackListingData: PrivateGameTemplateListingData
privateGameTemplateListingData: PrivateGameTemplateListingData
) => void,
onExampleOpen?: (exampleShortHeader: ExampleShortHeader) => void,
|};

const PublicProfileDialog = ({
userId,
onClose,
onAssetPackOpen,
onGameTemplateOpen,
onExampleOpen,
}: Props) => {
const callbacks = React.useMemo(
() => ({
Expand All @@ -44,8 +47,15 @@ const PublicProfileDialog = ({
}
}
: null,
openExample: onExampleOpen
? (data: GdGamesMessageEventData) => {
if (data.exampleShortHeader) {
onExampleOpen(data.exampleShortHeader);
}
}
: null,
}),
[onAssetPackOpen, onGameTemplateOpen]
[onAssetPackOpen, onGameTemplateOpen, onExampleOpen]
);

const onMessageReceived = React.useCallback(
Expand Down
2 changes: 2 additions & 0 deletions newIDE/app/src/UI/GdGamesFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {
type PrivateGameTemplateListingData,
type PrivateAssetPackListingData,
} from '../Utils/GDevelopServices/Shop';
import { type ExampleShortHeader } from '../Utils/GDevelopServices/Example';

export type GdGamesMessageEventData = $ReadOnly<{
id?: string | any,
privateAssetPackListingData?: PrivateAssetPackListingData,
privateGameTemplateListingData?: PrivateGameTemplateListingData,
exampleShortHeader?: ExampleShortHeader,
}>;

type Props = {|
Expand Down

0 comments on commit 26f6230

Please sign in to comment.