Invite-only sign-up, present mode, series, handouts, templates, dictation, progress, sharing
Build and Push Docker Image / build-and-push (push) Successful in 6m47s
Build and Push Docker Image / build-and-push (push) Successful in 6m47s
- Admin: sign-up Open / Invite only / Closed with single-use invite links - Present mode for scripts (auto-scroll) and outlines (step through, pace vs planned minutes) - Series: group studies on the dashboard, filter by series, calendar file for a study's sessions - Lesson handout: printable page per session (passage, outline, questions, writing lines) - Save a chunk's notes as your own study template (synced) - Voice dictation for notes and scripts (browser speech recognition) - Reading progress: map of the 66 books and a calendar of days read, synced and merged across devices - Export highlights and bookmarks as Markdown or Word, grouped by named colour - Verse of the day push to the ntfy topic (needs IQBIBLE_API_KEY) - Sharing: co-teacher editing via single-use invite links; read-only links can expire and take a passcode Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
88bc59bac0
commit
54cb1c217d
73 files changed
+2739
-134
No files matched your search
@@ -1,18 +1,23 @@
|
||||
// Read-only share link for the open project: status, enable, revoke, copy.
|
||||
// Read-only share link for the open project: status, enable, change its rules (expiry, passcode), revoke, copy.
|
||||
import { useEffect, useState } from 'react';
|
||||
import { disableSharing, enableSharing, getShareStatus } from '../syncService.js';
|
||||
|
||||
export function useShareLink(projectId) {
|
||||
const [shareToken, setShareToken] = useState(null);
|
||||
const [expiresAt, setExpiresAt] = useState(null);
|
||||
const [hasPasscode, setHasPasscode] = useState(false);
|
||||
const [shareBusy, setShareBusy] = useState(false);
|
||||
const [shareCopied, setShareCopied] = useState(false);
|
||||
const [shareError, setShareError] = useState('');
|
||||
|
||||
const apply = (data) => { setShareToken(data.shareToken ?? null); setExpiresAt(data.expiresAt ?? null); setHasPasscode(!!data.hasPasscode); };
|
||||
|
||||
useEffect(() => {
|
||||
setShareToken(null);
|
||||
if (!projectId) return;
|
||||
setShareToken(null); setExpiresAt(null); setHasPasscode(false); setShareError('');
|
||||
if (!projectId) return undefined;
|
||||
let active = true;
|
||||
getShareStatus(projectId).then((result) => {
|
||||
if (active && result.ok) setShareToken(result.data.shareToken);
|
||||
if (active && result.ok) apply(result.data);
|
||||
});
|
||||
return () => { active = false; };
|
||||
}, [projectId]);
|
||||
@@ -21,11 +26,14 @@ export function useShareLink(projectId) {
|
||||
? `${window.location.origin}${window.location.pathname}?share=${shareToken}`
|
||||
: '';
|
||||
|
||||
const enable = async () => {
|
||||
// Turns the link on, or changes its rules: { expiresInDays?: number | null, passcode?: string | null }
|
||||
const enable = async (options = {}) => {
|
||||
setShareBusy(true);
|
||||
const result = await enableSharing(projectId);
|
||||
setShareError('');
|
||||
const result = await enableSharing(projectId, options);
|
||||
setShareBusy(false);
|
||||
if (result.ok) setShareToken(result.data.shareToken);
|
||||
if (result.ok) apply(result.data); else setShareError(result.error ?? 'Could not save the link settings.');
|
||||
return result.ok;
|
||||
};
|
||||
|
||||
const revoke = async () => {
|
||||
@@ -33,7 +41,7 @@ export function useShareLink(projectId) {
|
||||
setShareBusy(true);
|
||||
const result = await disableSharing(projectId);
|
||||
setShareBusy(false);
|
||||
if (result.ok) setShareToken(null);
|
||||
if (result.ok) apply({});
|
||||
};
|
||||
|
||||
const copy = () => {
|
||||
@@ -44,5 +52,5 @@ export function useShareLink(projectId) {
|
||||
});
|
||||
};
|
||||
|
||||
return { shareToken, shareUrl, shareBusy, shareCopied, enable, revoke, copy };
|
||||
return { shareToken, shareUrl, expiresAt, hasPasscode, shareBusy, shareCopied, shareError, enable, revoke, copy };
|
||||
}
|
||||
Reference in new issue
Block a user