release-notes.ts

2.3 KB · raw

1/**2 * Build-time release notes for the "what's new" screen.3 *4 * The screen appears once after unlock when the build version differs from the5 * last version the user acknowledged. `__PEACH_VERSION__` is injected by Vite6 * from package.json at build time. When `CURRENT_NOTES` is empty the screen is7 * skipped entirely — no content, no interruption.8 *9 * To ship a new changelog: bump the version in package.json (which Vite injects10 * as `__PEACH_VERSION__`), then add entries to `CURRENT_NOTES` below. The11 * version mismatch triggers the screen on next unlock; "Continue" stores the12 * version and suppresses it until the next bump.13 */1415declare const __PEACH_VERSION__: string;1617export interface ReleaseNote {18  heading: string;19  body: string;20  breaking?: boolean;21}2223export const PEACH_VERSION: string = typeof __PEACH_VERSION__ !== "undefined"24  ? __PEACH_VERSION__25  : "0.0.0";2627export const CURRENT_NOTES: ReleaseNote[] = [28  {29    heading: "Passphrases & long passwords",30    body: "Peach now supports passphrases and passwords up to 256 characters. Existing vaults remain fully readable.",31  },32  {33    heading: "Update your Android app first",34    body: "Vault V4 is not readable by Peach Android before v2.15.3. Open Peach on Android → Settings → Update, or visit peachpasswords.com to download the latest version. Export a backup on Android before updating.",35    breaking: true,36  },37];3839export function hasReleaseNotes(): boolean {40  return CURRENT_NOTES.length > 0;41}4243const WHATS_NEW_SEEN_KEY = "peach_whats_new_seen";4445export async function shouldShowWhatsNew(): Promise<boolean> {46  if (!hasReleaseNotes()) return false;47  try {48    const seen = await chrome.storage.local.get(WHATS_NEW_SEEN_KEY);49    const last = seen[WHATS_NEW_SEEN_KEY];50    // A fresh install has no stored version — there is nothing to catch up51    // on, so the screen never appears. It only fires on an upgrade from a52    // previously-seen version. Mirrors Android's WhatsNewScreen gate.53    if (last === undefined) return false;54    return last !== PEACH_VERSION;55  } catch {56    return false;57  }58}5960export async function markWhatsNewSeen(): Promise<void> {61  try {62    await chrome.storage.local.set({ [WHATS_NEW_SEEN_KEY]: PEACH_VERSION });63  } catch {64    // best-effort — the screen just won't reshow, which is the lesser evil65  }66}