Hiyve Components - v1.0.0
    Preparing search index...
    • Hook for Q&A session persistence with auto-save.

      Parameters

      Returns UseQAPersistenceResult

      Persistence state and controls

      This hook provides automatic saving of Q&A sessions to file storage. It uses the Hiyve client's file upload/modify APIs to persist data to S3.

      Features:

      • Auto-save after a configurable interval (default: 3 seconds)
      • Deduplication of questions before saving
      • Saves on unmount to prevent data loss
      • Handles first save vs subsequent saves automatically
      function QAWithPersistence() {
      const [questions, setQuestions] = useState<Question[]>([]);
      const { client, room } = useRoom();
      const { localUserId } = useParticipants();

      const {
      fileId,
      isSaving,
      hasUnsavedChanges,
      save,
      markUnsaved,
      } = useQAPersistence({
      client,
      enabled: true,
      userId: localUserId,
      roomName: room?.name,
      onSave: (id) => console.log('Saved to:', id),
      });

      // Mark unsaved when questions change
      useEffect(() => {
      markUnsaved();
      }, [questions, markUnsaved]);

      return <QAPanel onQuestionsChange={setQuestions} />;
      }