Repository: 4ian/GDevelop
File: newIDE/app/src/ResourcesEditor/index.js (JavaScript)

Code before:
  }

  componentWillUnmount() {
    unregisterOnResourceExternallyChangedCallback(
      this.resourceExternallyChangedCallbackId
    );
  }

  _onKeyDown = (event: KeyboardEvent) => {
    if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
      this._moveSelection(event.key === 'ArrowDown' ? 1 : -1);
      event.preventDefault();
    }
  };

  _moveSelection = (delta: number) => {
    const { project } = this.props;
    const { selectedResource } = this.state;
    const resourcesManager = project.getResourcesManager();
    const allNames = resourcesManager.getAllResourceNames().toJSArray();

    if (allNames.length === 0) return;

    let nextIndex = 0;
    if (selectedResource) {
      const currentIndex = allNames.indexOf(selectedResource.getName());
      nextIndex = Math.max(
        0,
        Math.min(allNames.length - 1, currentIndex + delta)
      );
    }

    const nextResource = resourcesManager.getResource(allNames[nextIndex]);
    if (nextResource !== selectedResource) {
      this._onResourceSelected(nextResource);
    }
  };

  refreshResourcesList() {
    if (this._resourcesList) this._resourcesList.forceUpdateList();
  }

  updateToolbar = () => {
    const openedEditorNames = this.editorMosaic
      ? this.editorMosaic.getOpenedEditorNames()
      : [];

    this.props.setToolbar(
      <Toolbar
        onOpenProjectFolder={this.openProjectFolder}
        canOpenProjectFolder={

Review comment (suggestion):
Same as the other, I think it would be worth exposing Count and using GetResourcePosition rather than everytime getting getAllResourceNames + calling to JSArray which creates useless copies of the list of names in memory.

Code after:
  componentDidMount() {
    this.resourceExternallyChangedCallbackId = registerOnResourceExternallyChangedCallback(
      this.onResourceExternallyChanged.bind(this)
    );
  }

  componentWillUnmount() {
    unregisterOnResourceExternallyChangedCallback(
      this.resourceExternallyChangedCallbackId
    );
  }

  refreshResourcesList() {
    if (this._resourcesList) this._resourcesList.forceUpdateList();
  }

  updateToolbar = () => {
    const openedEditorNames = this.editorMosaic
      ? this.editorMosaic.getOpenedEditorNames()
      : [];

    this.props.setToolbar(
      <Toolbar
        onOpenProjectFolder={this.openProjectFolder}
        canOpenProjectFolder={
          !!remote &&
          !!this.props.fileMetadata &&
          this.props.storageProvider.internalName === 'LocalFile'
        }
        onToggleProperties={this.toggleProperties}
        isPropertiesShown={openedEditorNames.includes('properties')}
        canDelete={!!this.state.selectedResource}
        onDeleteSelection={() =>
          this.deleteResource(this.state.selectedResource)
        }
      />
    );
  };

  deleteResource = (resource: ?gdResource) => {
    const { project, onDeleteResource } = this.props;
    if (!resource) return;

    const answer = Window.showConfirmDialog(
      "Are you sure you want to remove this resource? This can't be undone."
    );
    if (!answer) return;

    const resourcesManager = project.getResourcesManager();
    const currentIndex = resourcesManager.getResourcePosition(
      resource.getName()