mirror of
https://github.com/block/buzz.git
synced 2026-11-01 23:11:58 +00:00
Give project agents the visible page context and shared thread presentation, while aligning list metadata and detail communication actions with the active workspace. Signed-off-by: Thomas Petersen <thomasp@squareup.com>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import * as React from "react";
|
|
|
|
import { useAppNavigation } from "@/app/navigation/useAppNavigation";
|
|
import {
|
|
loadDraftEntry,
|
|
saveDraftEntry,
|
|
} from "@/features/messages/lib/useDrafts";
|
|
import {
|
|
mergeSelectionDiscussDraft,
|
|
projectSelectionDiscussContent,
|
|
type ProjectSelectionItem,
|
|
} from "@/features/projects/lib/projectSelection";
|
|
|
|
export function useProjectDiscussInChannel(items: ProjectSelectionItem[]) {
|
|
const { goChannel } = useAppNavigation();
|
|
|
|
return React.useCallback(
|
|
(channelId: string) => {
|
|
const now = new Date().toISOString();
|
|
const existing = loadDraftEntry(channelId);
|
|
const content = mergeSelectionDiscussDraft(
|
|
existing?.content,
|
|
projectSelectionDiscussContent(items),
|
|
);
|
|
saveDraftEntry(channelId, {
|
|
channelId,
|
|
content,
|
|
createdAt: existing?.createdAt ?? now,
|
|
mentionRefs: existing?.mentionRefs ?? [],
|
|
pendingImeta: existing?.pendingImeta ?? [],
|
|
selectionEnd: content.length,
|
|
selectionStart: content.length,
|
|
spoileredAttachmentUrls: existing?.spoileredAttachmentUrls ?? [],
|
|
status: "active",
|
|
updatedAt: now,
|
|
});
|
|
void goChannel(channelId);
|
|
},
|
|
[goChannel, items],
|
|
);
|
|
}
|