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

Code before:
      preferences.getIsMenuBarHiddenInPreview,
      preferences.getIsAlwaysOnTopInPreview,
      preferences.values.openDiagnosticReportAutomatically,
      currentlyRunningInAppTutorial,
      getAuthenticatedPlayerForPreview,
      quickCustomizationDialogOpenedFromGameId,
      onCaptureFinished,
      createCaptureOptionsForPreview,
    ]
  );

  const launchPreview = addCreateBadgePreHookIfNotClaimed(
    authenticatedUser,
    TRIVIAL_FIRST_PREVIEW,
    _launchPreview
  );

  const launchNewPreview = React.useCallback(
    async options => {
      const numberOfWindows = options ? options.numberOfWindows : 1;
      await launchPreview({ networkPreview: false, numberOfWindows });
    },
    [launchPreview]
  );

  const launchPreviewWithScreenshot = React.useCallback(
    () =>
      launchPreview({
        networkPreview: false,
        hotReload: false,
        launchCaptureOptions: {
          screenshots: [
            { delayTimeInSeconds: 3000 }, // Take only 1 screenshot per preview.
          ],
        },
      }),
    [launchPreview]
  );

  const launchHotReloadPreview = React.useCallback(
    () =>
      launchPreview({
        networkPreview: false,
        hotReload: true,
      }),
    [launchPreview]
  );

  const launchNetworkPreview = React.useCallback(
    () => launchPreview({ networkPreview: true, hotReload: false }),
    [launchPreview]

Review comment (suggestion):
Consider not adding yet-another-way-to-launch-preview and instead:
- Make the logic related to the timing inside the existing function.
- delayTimeInSeconds can also be in the function
- forcing a screenshot, bypassing the check for timing, is "just" a "forceScreenshot: true". But this is only used for quick customization. For normal previews, the buttons are unchanged.

Code after:
      preferences.getIsMenuBarHiddenInPreview,
      preferences.getIsAlwaysOnTopInPreview,
      preferences.values.openDiagnosticReportAutomatically,
      currentlyRunningInAppTutorial,
      getAuthenticatedPlayerForPreview,
      quickCustomizationDialogOpenedFromGameId,
      onCaptureFinished,
      createCaptureOptionsForPreview,
    ]
  );

  const launchPreview = addCreateBadgePreHookIfNotClaimed(
    authenticatedUser,
    TRIVIAL_FIRST_PREVIEW,
    _launchPreview
  );

  const launchNewPreview = React.useCallback(
    async options => {
      const numberOfWindows = options ? options.numberOfWindows : 1;
      await launchPreview({ networkPreview: false, numberOfWindows });
    },
    [launchPreview]
  );

  const launchHotReloadPreview = React.useCallback(
    async () => {
      const launchCaptureOptions = currentProject
        ? getHotReloadPreviewLaunchCaptureOptions(
            currentProject.getProjectUuid()
          )
        : undefined;
      await launchPreview({
        networkPreview: false,
        hotReload: true,
        launchCaptureOptions,
      });
    },
    [currentProject, launchPreview, getHotReloadPreviewLaunchCaptureOptions]
  );

  const launchNetworkPreview = React.useCallback(
    () => launchPreview({ networkPreview: true, hotReload: false }),
    [launchPreview]
  );

  const launchPreviewWithDiagnosticReport = React.useCallback(
    () => launchPreview({ forceDiagnosticReport: true }),
    [launchPreview]
  );