export function GetIssueReadingTimestamp(issueId: number): number {
  const value = window.localStorage.getItem(getKey(issueId));
  return value ? Number(value) : 0;
}

export function SetIssueReadingTimestamp(issueId: number): number {
  const now = new Date().getTime();
  window.localStorage.setItem(getKey(issueId), String(now));
  return now;
}

export function SetIssuesReadingTimestamp(issueIds: number[]): number {
  const now = new Date().getTime();
  for (let i = 0; i < issueIds.length; i++) {
    const issueId = issueIds[i];
    window.localStorage.setItem(getKey(issueId), String(now));
  }
  return now;
}

function getKey(issueId: number): string {
  return `issue_read_${issueId}`;
}
