Repository: 4ian/GDevelop
File: newIDE/app/src/AssetStore/ExtensionStore/InstallExtension.js (JavaScript)

Code before:
    const serializedExtension = await eventsFunctionsExtensionOpener.readEventsFunctionExtensionFile(
      pathOrUrl
    );

    if (project.hasEventsFunctionsExtensionNamed(serializedExtension.name)) {
      const answer = await showConfirmation({
        title: t`Replace existing extension`,
        message: t`An extension with this name already exists in the project. Importing this extension will replace it.`,
        confirmButtonLabel: `Replace`,
      });
      if (!answer) return null;
    }
    else {
      let hasConflictWithBuiltInExtension = false;
      const allExtensions = gd
        .asPlatform(gd.JsPlatform.get())
        .getAllPlatformExtensions();
      mapVector(allExtensions, extension => {
        if (extension.getName() === serializedExtension.name) {
          hasConflictWithBuiltInExtension = true;
        }
      });
      if (hasConflictWithBuiltInExtension) {
        await showAlert({
          title: t`Invalid name`,
          message: t`The imported extension has the same name as a built-in extension. It can't be imported.`,
        });
        return null;
      }
    }

    onWillInstallExtension(serializedExtension.name);

    await addSerializedExtensionsToProject(
      eventsFunctionsExtensionsState,
      project,
      [serializedExtension],
      false
    );
    return serializedExtension.name;
  } catch (rawError) {
    showErrorBox({
      message: i18n._(
        t`An error happened while loading this extension. Please check that it is a proper extension file and compatible with this version of GDevelop`
      ),
      rawError,
      errorId: 'extension-loading-error',
    });
    return null;
  }
};

Review comment (suggestion):
```suggestion
          message: t`The extension can't be imported because it has the same name as a built-in extension.`,
```

Code after:
  try {
    const pathOrUrl = await eventsFunctionsExtensionOpener.chooseEventsFunctionExtensionFile();
    if (!pathOrUrl) return null;

    const serializedExtension = await eventsFunctionsExtensionOpener.readEventsFunctionExtensionFile(
      pathOrUrl
    );

    if (project.hasEventsFunctionsExtensionNamed(serializedExtension.name)) {
      const answer = await showConfirmation({
        title: t`Replace existing extension`,
        message: t`An extension with this name already exists in the project. Importing this extension will replace it.`,
        confirmButtonLabel: `Replace`,
      });
      if (!answer) return null;
    } else {
      let hasConflictWithBuiltInExtension = false;
      const allExtensions = gd
        .asPlatform(gd.JsPlatform.get())
        .getAllPlatformExtensions();
      mapVector(allExtensions, extension => {
        if (extension.getName() === serializedExtension.name) {
          hasConflictWithBuiltInExtension = true;
        }
      });
      if (hasConflictWithBuiltInExtension) {
        await showAlert({
          title: t`Invalid name`,
          message: t`The extension can't be imported because it has the same name as a built-in extension.`,
        });
        return null;
      }
    }

    onWillInstallExtension(serializedExtension.name);

    await addSerializedExtensionsToProject(
      eventsFunctionsExtensionsState,
      project,
      [serializedExtension],
      false
    );
    return serializedExtension.name;
  } catch (rawError) {
    showErrorBox({
      message: i18n._(
        t`An error happened while loading this extension. Please check that it is a proper extension file and compatible with this version of GDevelop`
      ),
      rawError,
      errorId: 'extension-loading-error',
    });