Improve a few things Bis repetita

Do not show in changelog
This commit is contained in:
AlexandreS
2022-01-10 18:06:18 +01:00
committed by GitHub
parent 3acd76ff02
commit 34a75a29c7
3 changed files with 72 additions and 60 deletions

View File

@@ -40,7 +40,7 @@ jobs:
This bug is actually known but we currently lack information on how to reproduce it. Could you please tell us more about how it happened in the issue #3453?
token: ${{ secrets.GITHUB_TOKEN }}
- name: Autocomment known 124 crash removing a node (reference issue comment)
if: "${{ contains(github.event.issue.body, 'Error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.') }}"
if: "${{ contains(github.event.issue.body, 'The node to be removed is not a child of this node') }}"
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: 3453

View File

@@ -1,6 +1,7 @@
// @flow
import { Trans } from '@lingui/macro';
import { I18n } from '@lingui/react';
import { type I18n as I18nType } from '@lingui/core';
import * as React from 'react';
import Dialog from '../../UI/Dialog';
import FlatButton from '../../UI/FlatButton';
@@ -48,6 +49,41 @@ export default function ExtensionsSearchDialog({
installExtension
);
const installOrImportExtension = async (
i18n: I18nType,
extensionShortHeader?: ExtensionShortHeader
) => {
setIsInstalling(true);
try {
let wasExtensionInstalledOrImported;
if (!!extensionShortHeader) {
onInstallExtension(extensionShortHeader);
wasExtensionInstalledOrImported = await installDisplayedExtension(
i18n,
project,
eventsFunctionsExtensionsState,
extensionShortHeader
);
} else {
wasExtensionInstalledOrImported = await importExtension(
i18n,
eventsFunctionsExtensionsState,
project
);
}
if (wasExtensionInstalledOrImported) {
setExtensionWasInstalled(true);
if (onExtensionInstalled) onExtensionInstalled();
return true;
}
return false;
} finally {
setIsInstalling(false);
}
};
const eventsFunctionsExtensionOpener = eventsFunctionsExtensionsState.getEventsFunctionsExtensionOpener();
return (
@@ -73,19 +109,7 @@ export default function ExtensionsSearchDialog({
key="import"
label={<Trans>Import extension</Trans>}
onClick={() => {
(async () => {
setIsInstalling(true);
const wasExtensionImported = await importExtension(
i18n,
eventsFunctionsExtensionsState,
project
);
if (wasExtensionImported && onExtensionInstalled)
onExtensionInstalled();
setExtensionWasInstalled(wasExtensionImported);
setIsInstalling(false);
})();
installOrImportExtension(i18n);
}}
disabled={isInstalling}
/>
@@ -99,28 +123,9 @@ export default function ExtensionsSearchDialog({
>
<ExtensionStore
isInstalling={isInstalling}
onInstall={async extensionShortHeader => {
setIsInstalling(true);
try {
onInstallExtension(extensionShortHeader);
const wasExtensionInstalled = await installDisplayedExtension(
i18n,
project,
eventsFunctionsExtensionsState,
extensionShortHeader
);
if (wasExtensionInstalled) {
setExtensionWasInstalled(true);
if (onExtensionInstalled)
onExtensionInstalled(extensionShortHeader);
return true;
}
return false;
} finally {
setIsInstalling(false);
}
}}
onInstall={async extensionShortHeader =>
installOrImportExtension(i18n, extensionShortHeader)
}
project={project}
showOnlyWithBehaviors={false}
/>

View File

@@ -40,6 +40,7 @@ import {
TRIVIAL_FIRST_BEHAVIOR,
TRIVIAL_FIRST_EXTENSION,
} from '../Utils/GDevelopServices/Badge';
import { type ExtensionShortHeader } from '../Utils/GDevelopServices/Extension';
const styles = {
disabledItem: { opacity: 0.6 },
@@ -184,6 +185,33 @@ export default function NewBehaviorDialog({
const hasSearchNoResult =
!!searchText && !behaviors.length && !deprecatedBehaviors.length;
const onInstallExtension = async (
i18n: I18nType,
extensionShortHeader: ExtensionShortHeader
) => {
setIsInstalling(true);
try {
const wasExtensionInstalled = await installDisplayedExtension(
i18n,
project,
eventsFunctionsExtensionsState,
extensionShortHeader
);
if (wasExtensionInstalled) {
// Setting the extension install time will force a reload of
// the behavior metadata, and so the list of behaviors.
setExtensionInstallTime(Date.now());
setCurrentTab('installed');
if (scrollView.current) scrollView.current.scrollToBottom();
return true;
}
return false;
} finally {
setIsInstalling(false);
}
};
return (
<I18n>
{({ i18n }) => (
@@ -311,30 +339,9 @@ export default function NewBehaviorDialog({
<ExtensionStore
project={project}
isInstalling={isInstalling}
onInstall={async extensionShortHeader => {
setIsInstalling(true);
try {
const wasExtensionInstalled = await installDisplayedExtension(
i18n,
project,
eventsFunctionsExtensionsState,
extensionShortHeader
);
if (wasExtensionInstalled) {
// Setting the extension install time will force a reload of
// the behavior metadata, and so the list of behaviors.
setExtensionInstallTime(Date.now());
setCurrentTab('installed');
if (scrollView.current)
scrollView.current.scrollToBottom();
return true;
}
return false;
} finally {
setIsInstalling(false);
}
}}
onInstall={async extensionShortHeader =>
onInstallExtension(i18n, extensionShortHeader)
}
showOnlyWithBehaviors
/>
)}