master
Colby Knox Publish 0.25.2 2aa6af7
// When is a studio's gate open? `approved` is the session's record of the
// last Generate and is never cleared, so "approved.page === page" alone
// read a re-posed gate as closed whenever that page had been generated
// earlier in the session (hero-studio#77: a second thread's pose then took
// over the live gate). The gate is open when it is posed and the last
// approval of that page came before the pose.
export function gateOpen(state) {
  if (!state || !state.verify || !state.page) return false;
  const a = state.approved;
  if (!a || a.page !== state.page) return true;
  const posed = Number(state.posedAt) || 0;
  const approvedAt = Number(a.ts) || 0;
  return posed > approvedAt;
}