Skip to content

A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.

742 B
Raw Blame
import { selectedZoomFileGroups, ZoomFileGroups } from 'common/zoomFiles'

// Files are selected by id in the install modal. Without a selection the
// backend falls back to every game file, which keeps older callers working.
export function resolveZoomInstallSelection(
  files: ZoomFileGroups,
  requestedIds: string[] | undefined,
  missingSelectionError: string
): { selection: ZoomFileGroups; ids: string[] } | { error: string } {
  const ids = requestedIds ?? files.game.map((file) => file.id)
  const selection = selectedZoomFileGroups(files, ids)

  if (!selection.game.length) {
    return { error: missingSelectionError }
  }

  return {
    selection,
    ids: [...selection.game, ...selection.extras].map((file) => file.id)
  }
}