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 13, 2024
1 parent 701b5a3 commit 34fecdc
Show file tree
Hide file tree
Showing 3 changed files with 17 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const WithGameTemplates = () => (
onClose={action('onClose')}
onAssetPackOpen={action('onAssetPackOpen')}
onGameTemplateOpen={action('onGameTemplateOpen')}
onExampleOpen={action('onExampleOpen')}
/>
);

Expand All @@ -25,6 +26,7 @@ export const WithAssetPacks = () => (
onClose={action('onClose')}
onAssetPackOpen={action('onAssetPackOpen')}
onGameTemplateOpen={action('onGameTemplateOpen')}
onExampleOpen={action('onExampleOpen')}
/>
);

Expand All @@ -34,5 +36,6 @@ export const WithGames = () => (
onClose={action('onClose')}
onAssetPackOpen={action('onAssetPackOpen')}
onGameTemplateOpen={action('onGameTemplateOpen')}
onExampleOpen={action('onExampleOpen')}
/>
);

0 comments on commit 34fecdc

Please sign in to comment.