Repository: 4ian/GDevelop
File: newIDE/app/src/GameDashboard/GamesList.js (JavaScript)

Code before:
          otherProjectFile.fileMetadata.fileIdentifier
      );
    });
  }
  return false;
};

const getDashboardItemsToDisplay = ({
  project,
  currentFileMetadata,
  allDashboardItems,
  searchText,
  searchClient,
  currentPage,
  orderBy,
}: {|
  project: ?gdProject,
  currentFileMetadata: ?FileMetadata,
  allDashboardItems: ?Array<DashboardItem>,
  searchText: string,
  searchClient: Fuse,
  currentPage: number,
  orderBy: GamesDashboardOrderBy,
|}): ?Array<DashboardItem> => {
  if (!allDashboardItems) return null;
  let itemsToDisplay: DashboardItem[] = allDashboardItems;

  if (searchText) {
    // If there is a search, just return those items, ordered by the search relevance.
    const searchResults = searchClient.search(
      getFuseSearchQueryForMultipleKeys(searchText, [
        'game.gameName',
        'projectFiles.fileMetadata.name',
      ])
    );
    itemsToDisplay = searchResults.map(result => result.item);
  } else {
    // If there is no search, sort the items by the selected order.
    itemsToDisplay =
      orderBy === 'totalSessions'
        ? itemsToDisplay.sort(totalSessionsSort)
        : orderBy === 'weeklySessions'
        ? itemsToDisplay.sort(lastWeekSessionsSort)
        : orderBy === 'lastModifiedAt'
        ? itemsToDisplay.sort(lastModifiedAtSort)
        : itemsToDisplay;

    // If a project is opened, no search is done, and sorted by last modified date,
    // then the opened project should be displayed first.
    if (project && orderBy === 'lastModifiedAt') {
      const currentProjectId = project.getProjectUuid();

Review comment (suggestion):
I don't know if this array should be copied with a destructuring operation because it can be sorted below, affecting both `itemsToDisplay` and `allDashboardItems` I think

Code after:
          otherProjectFile.fileMetadata.fileIdentifier
      );
    });
  }
  return false;
};

const getDashboardItemsToDisplay = ({
  project,
  currentFileMetadata,
  allDashboardItems,
  searchText,
  searchClient,
  currentPage,
  orderBy,
}: {|
  project: ?gdProject,
  currentFileMetadata: ?FileMetadata,
  allDashboardItems: ?Array<DashboardItem>,
  searchText: string,
  searchClient: Fuse,
  currentPage: number,
  orderBy: GamesDashboardOrderBy,
|}): ?Array<DashboardItem> => {
  if (!allDashboardItems) return null;
  let itemsToDisplay: DashboardItem[] = [...allDashboardItems];

  if (searchText) {
    // If there is a search, just return those items, ordered by the search relevance.
    const searchResults = searchClient.search(
      getFuseSearchQueryForMultipleKeys(searchText, [
        'game.gameName',
        'projectFiles.fileMetadata.name',
      ])
    );
    itemsToDisplay = searchResults.map(result => result.item);
  } else {
    // If there is no search, sort the items by the selected order.
    if (orderBy) {
      itemsToDisplay.sort(
        orderBy === 'totalSessions'
          ? totalSessionsSort
          : orderBy === 'weeklySessions'
          ? lastWeekSessionsSort
          : lastModifiedAtSort
      );
    }

    // If a project is opened, no search is done, and sorted by last modified date,
    // then the opened project should be displayed first.
    if (project && orderBy === 'lastModifiedAt') {