const RATED_SESSIONS_KEY = 'rf-rated-sessions'

export function getRatedSessions(): string[] {
  try {
    return JSON.parse(localStorage.getItem(RATED_SESSIONS_KEY) || '[]')
  } catch {
    return []
  }
}

export function markSessionRated(sessionId: string) {
  const rated = getRatedSessions()
  rated.push(sessionId)
  localStorage.setItem(RATED_SESSIONS_KEY, JSON.stringify(rated.slice(-100)))
}

export function hasBeenRated(sessionId: string): boolean {
  return getRatedSessions().includes(sessionId)
}
