MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / mergeThreads

Function mergeThreads

apps/web/ui/ChannelView/index.tsx:454–491  ·  view source on GitHub ↗
({ from, to }: { from: string; to: string })

Source from the content-addressed store, hash-verified

452 }
453
454 const mergeThreads = ({ from, to }: { from: string; to: string }) => {
455 const source = threads.find((thread) => thread.id === from);
456 const target = threads.find((thread) => thread.id === to);
457
458 setThreads((threads) => {
459 if (!source || !target) {
460 return threads;
461 }
462 return threads
463 .map((thread) => {
464 if (thread.id === from) {
465 return null;
466 }
467 if (thread.id === to) {
468 return {
469 ...thread,
470 messages: [...thread.messages, ...source.messages].sort(
471 (a, b) => {
472 return (
473 new Date(a.sentAt).getTime() - new Date(b.sentAt).getTime()
474 );
475 }
476 ),
477 };
478 }
479 return thread;
480 })
481 .filter(Boolean) as SerializedThread[];
482 });
483 if (!source || !target) {
484 return Promise.resolve();
485 }
486 return api.mergeThreadsRequest({
487 from: source.id,
488 to: target.id,
489 communityId: currentCommunity.id,
490 });
491 };
492
493 const moveMessageToThread = ({
494 messageId,

Callers 1

onThreadDropFunction · 0.85

Calls 2

mapMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected