Skip to content

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

1.6 KB
Raw Blame
import { useTranslation } from 'react-i18next'
import {
  Cloud,
  CloudAlert,
  CloudCheck,
  CloudOff,
  RefreshCw
} from 'lucide-react'
import type { LucideIcon } from 'lucide-react'

import type { SteamCloudSyncState } from 'common/types/steam'

/** Icon shown for each sync outcome, in the library and in the modal. */
export const CLOUD_SYNC_ICONS: Record<SteamCloudSyncState, LucideIcon> = {
  unknown: Cloud,
  ok: CloudCheck,
  // A plain circling arrow — a spinning cloud reads as odd. Arrows point
  // clockwise to match the spin direction.
  syncing: RefreshCw,
  conflicts: CloudAlert,
  incomplete: CloudAlert,
  failed: CloudOff
}

/** States that warrant the attention dot. */
export function issueLevel(
  state: SteamCloudSyncState
): 'none' | 'warning' | 'error' {
  if (state === 'conflicts' || state === 'failed') return 'error'
  if (state === 'incomplete') return 'warning'
  return 'none'
}

/** One human-readable line per state, used as tooltip and modal heading. */
export function useCloudSyncStateLabels(): Record<SteamCloudSyncState, string> {
  const { t } = useTranslation()
  return {
    unknown: t('cloudSync.state.unknown', 'Steam Cloud saves — not synced yet'),
    ok: t('cloudSync.state.ok', 'Steam Cloud saves are up to date'),
    syncing: t('cloudSync.state.syncing', 'Syncing Steam Cloud saves…'),
    conflicts: t(
      'cloudSync.state.conflicts',
      'Steam Cloud saves conflict with this PC'
    ),
    incomplete: t('cloudSync.state.incomplete', 'Steam Cloud sync incomplete'),
    failed: t('cloudSync.state.failed', 'Steam Cloud sync failed')
  }
}