()
| 31 | import { safeRemTextToString } from '../lib/pdfUtils'; |
| 32 | import { getRemReadPoint } from '../lib/remReadPoint'; |
| 33 | import { startIncRemEngagement, endIncRemEngagement } from '../lib/queue_session'; |
| 34 | import { useIESettingOptional } from '../lib/settings'; |
| 35 | |
| 36 | type ViewMode = 'isolated' | 'context'; |
| 37 | |
| 38 | export function QueueComponent() { |
| 39 | const plugin = usePlugin(); |
| 40 | const [viewMode, setViewMode] = useState<ViewMode | undefined>(undefined); |
| 41 | const [sourceDocName, setSourceDocName] = useState<string | undefined>(); |
| 42 | const [showSpark, setShowSpark] = useState(false); |
| 43 | |
| 44 | const ctx = useRunAsync( |
| 45 | async () => plugin.widget.getWidgetContext<WidgetLocation.Flashcard>(), |
| 46 | [] |
| 47 | ); |
| 48 | |
| 49 | // All hooks must run before any early return — keep this block above the |
| 50 | // `if (!ctx?.remId) return null` guard further down. |
| 51 | const remAndType = useTrackerPlugin( |
| 52 | async (rp) => { |
| 53 | if (!ctx?.remId) return undefined; |
| 54 | const rem = await rp.rem.findOne(ctx.remId); |
| 55 | if (!rem) { |
| 56 | console.log('[QueueComponent] remAndType: rem not found for', ctx.remId); |
| 57 | return null; |
| 58 | } |
| 59 | const result = await remToActionItemType(rp, rem); |
| 60 | console.log('[QueueComponent] remAndType resolved:', { |
| 61 | ctxRemId: ctx.remId, |
| 62 | type: result?.type, |
| 63 | remId: result?.rem?._id, |
| 64 | hasExtract: !!(result as any)?.extract, |
| 65 | }); |
| 66 | return result; |
| 67 | }, |
| 68 | [ctx?.remId] |
| 69 | ); |
| 70 | |
| 71 | // Optional form on purpose: the effect that turns this into `viewMode` runs |
| 72 | // once and never revisits (it bails on `viewMode !== undefined`), so seeing the |
| 73 | // default during the loading frame would lock in the wrong view. |
| 74 | const isolatedMode = useIESettingOptional(isolatedQueueModeId); |
| 75 | const isolatedDefaultForHighlight = isolatedMode === 'highlights' || isolatedMode === 'both'; |
| 76 | const isolatedDefaultForRem = isolatedMode === 'rems' || isolatedMode === 'both'; |
| 77 | |
| 78 | // Hybrid IncRems (a full-document PDF/HTML reading source AND their own outline |
| 79 | // content): offer a Reader ↔ Outline toggle when the IncRem also has a read |
| 80 | // point set on one of its descendants. This lets the user flip to the outline |
| 81 | // (with read-point emphasis + auto-scroll) without leaving the queue or |
| 82 | // re-tagging. The `#extractviewer` tag remains the explicit way to default a |
| 83 | // hybrid to the ExtractViewer instead. |
| 84 | const incRemRem = useTrackerPlugin( |
| 85 | async (rp) => (ctx?.remId ? await rp.rem.findOne(ctx.remId) : null), |
| 86 | [ctx?.remId] |
| 87 | ); |
| 88 | const offerOutlineToggle = useTrackerPlugin( |
| 89 | async (rp) => { |
| 90 | if (!ctx?.remId) return false; |
nothing calls this directly
no test coverage detected