mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
3 Commits
experiment
...
fix/thumbn
Author | SHA1 | Date | |
---|---|---|---|
![]() |
32ab441386 | ||
![]() |
08f839c430 | ||
![]() |
44158d936a |
@@ -39,12 +39,15 @@ import {
|
|||||||
getGameUrl,
|
getGameUrl,
|
||||||
updateGame,
|
updateGame,
|
||||||
type Game,
|
type Game,
|
||||||
|
setGameUserAcls,
|
||||||
|
getAclsFromUserIds,
|
||||||
} from '../../../Utils/GDevelopServices/Game';
|
} from '../../../Utils/GDevelopServices/Game';
|
||||||
import AuthenticatedUserContext from '../../../Profile/AuthenticatedUserContext';
|
import AuthenticatedUserContext from '../../../Profile/AuthenticatedUserContext';
|
||||||
import AlertMessage from '../../../UI/AlertMessage';
|
import AlertMessage from '../../../UI/AlertMessage';
|
||||||
import OnlineGamePropertiesDialog from './OnlineGamePropertiesDialog';
|
import OnlineGamePropertiesDialog from './OnlineGamePropertiesDialog';
|
||||||
import { showErrorBox } from '../../../UI/Messages/MessageBox';
|
import { showErrorBox } from '../../../UI/Messages/MessageBox';
|
||||||
import { type PartialGameChange } from '../../../GameDashboard/PublicGamePropertiesDialog';
|
import { type PartialGameChange } from '../../../GameDashboard/PublicGamePropertiesDialog';
|
||||||
|
import { type Profile } from '../../../Utils/GDevelopServices/Authentication';
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
icon: {
|
icon: {
|
||||||
@@ -52,6 +55,26 @@ const styles = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const tryUpdateAuthors = async (
|
||||||
|
getAuthorizationHeader: () => Promise<string>,
|
||||||
|
project: gdProject,
|
||||||
|
profile: Profile
|
||||||
|
) => {
|
||||||
|
const authorAcls = getAclsFromUserIds(project.getAuthorIds().toJSArray());
|
||||||
|
|
||||||
|
try {
|
||||||
|
await setGameUserAcls(
|
||||||
|
getAuthorizationHeader,
|
||||||
|
profile.id,
|
||||||
|
project.getProjectUuid(),
|
||||||
|
{ author: authorAcls }
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
// Best effort call, do not prevent exporting the game.
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
type OnlineGameLinkProps = {|
|
type OnlineGameLinkProps = {|
|
||||||
build: ?Build,
|
build: ?Build,
|
||||||
project: gdProject,
|
project: gdProject,
|
||||||
@@ -103,14 +126,42 @@ const OnlineGameLink = ({
|
|||||||
try {
|
try {
|
||||||
setIsGameLoading(true);
|
setIsGameLoading(true);
|
||||||
const game = await getGame(getAuthorizationHeader, id, gameId);
|
const game = await getGame(getAuthorizationHeader, id, gameId);
|
||||||
setGame(game);
|
|
||||||
|
let updatedGame = null;
|
||||||
|
try {
|
||||||
|
const isPublishedForTheFirstTime =
|
||||||
|
build && game.publicWebBuildId === build.id;
|
||||||
|
if (isPublishedForTheFirstTime) {
|
||||||
|
updatedGame = await updateGame(getAuthorizationHeader, id, gameId, {
|
||||||
|
authorName: project.getAuthor() || 'Unspecified publisher',
|
||||||
|
gameName: project.getName() || 'Untitled game',
|
||||||
|
description: project.getDescription(),
|
||||||
|
playWithGamepad: project.isPlayableWithGamepad(),
|
||||||
|
playWithKeyboard: project.isPlayableWithKeyboard(),
|
||||||
|
playWithMobile: project.isPlayableWithMobile(),
|
||||||
|
orientation: project.getOrientation(),
|
||||||
|
categories: project.getCategories().toJSArray(),
|
||||||
|
thumbnailUrl: build
|
||||||
|
? getWebBuildThumbnailUrl(project, build.id)
|
||||||
|
: undefined,
|
||||||
|
discoverable: false,
|
||||||
|
});
|
||||||
|
// We don't await for the authors update, as it is not required for publishing.
|
||||||
|
if (profile) {
|
||||||
|
tryUpdateAuthors(getAuthorizationHeader, project, profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Unable to update the game', err);
|
||||||
|
}
|
||||||
|
setGame(updatedGame || game);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Unable to load the game', err);
|
console.error('Unable to load the game', err);
|
||||||
} finally {
|
} finally {
|
||||||
setIsGameLoading(false);
|
setIsGameLoading(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[build, getAuthorizationHeader, profile]
|
[build, getAuthorizationHeader, profile, project]
|
||||||
);
|
);
|
||||||
|
|
||||||
React.useEffect(
|
React.useEffect(
|
||||||
|
Reference in New Issue
Block a user