feat(bot,frontend,backend): add integration with external collaborative solver
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
import PhotoPreview from '$lib/components/PhotoPreview.svelte';
|
||||
import DraftBadge from '$lib/components/DraftBadge.svelte';
|
||||
import SilentCapture from '$lib/components/SilentCapture.svelte';
|
||||
import IncomingSheetsPanel from '$lib/components/IncomingSheetsPanel.svelte';
|
||||
|
||||
const usePolling = getContext<boolean>('convex-use-polling') ?? false;
|
||||
let mnemonic = $derived(page.params.mnemonic);
|
||||
@@ -193,6 +194,38 @@
|
||||
const photoDraft = $derived(usePolling ? photoDraftPoll! : photoDraftWs!);
|
||||
const draftPhotos = $derived(photoDraft.data?.photos ?? []);
|
||||
|
||||
const incomingSheetsWs = usePolling
|
||||
? null
|
||||
: useQuery(api.incomingSheets.listForChat, () =>
|
||||
chatId ? { chatId, status: 'preview' as const } : 'skip'
|
||||
);
|
||||
const incomingSheetsPoll = usePolling
|
||||
? usePollingQuery(api.incomingSheets.listForChat, () =>
|
||||
chatId ? { chatId, status: 'preview' as const } : 'skip'
|
||||
)
|
||||
: null;
|
||||
const incomingSheetsQ = $derived(usePolling ? incomingSheetsPoll! : incomingSheetsWs!);
|
||||
const incomingSheetItems = $derived(incomingSheetsQ.data ?? []);
|
||||
|
||||
const acceptSheetPoll = usePolling ? usePollingMutation(api.incomingSheets.accept) : null;
|
||||
const dismissSheetPoll = usePolling ? usePollingMutation(api.incomingSheets.dismiss) : null;
|
||||
|
||||
function handleAcceptSheet(id: Id<'incomingSheets'>) {
|
||||
if (usePolling && acceptSheetPoll) {
|
||||
acceptSheetPoll({ id });
|
||||
} else if (clientWs) {
|
||||
clientWs.mutation(api.incomingSheets.accept, { id });
|
||||
}
|
||||
}
|
||||
|
||||
function handleDismissSheet(id: Id<'incomingSheets'>) {
|
||||
if (usePolling && dismissSheetPoll) {
|
||||
dismissSheetPoll({ id });
|
||||
} else if (clientWs) {
|
||||
clientWs.mutation(api.incomingSheets.dismiss, { id });
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
const req = captureNowRequest.data;
|
||||
if (req && hasCamera && !processedCaptureNowIds.has(req._id)) {
|
||||
@@ -611,6 +644,13 @@
|
||||
{#if draftPhotos.length > 0}
|
||||
<DraftBadge photos={draftPhotos} onremove={handleRemoveDraftPhoto} />
|
||||
{/if}
|
||||
{#if incomingSheetItems.length > 0}
|
||||
<IncomingSheetsPanel
|
||||
sheets={incomingSheetItems}
|
||||
onaccept={handleAcceptSheet}
|
||||
ondismiss={handleDismissSheet}
|
||||
/>
|
||||
{/if}
|
||||
<ChatInput onsubmit={sendMessage} allowEmpty={draftPhotos.length > 0} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user