mirror of
https://github.com/block/buzz.git
synced 2026-10-28 04:51:40 +00:00
Signed-off-by: Will Pfleger <pfleger.will@gmail.com> Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
23 lines
881 B
TypeScript
23 lines
881 B
TypeScript
/**
|
|
* Resolves the sentDraftKey to pass to sendMessageWithMentionFlow at submit
|
|
* time.
|
|
*
|
|
* Returns the key when a draft was actually persisted in the store before the
|
|
* send fired (so the active draft should be cleared on send), or null when no
|
|
* entry exists (fast / never-persisted send — no active draft to clear).
|
|
*
|
|
* This is a pure function with no dependencies so it can be imported and
|
|
* exercised directly in Node .mjs tests without a React renderer.
|
|
*
|
|
* @param effectiveDraftKey - the draft key captured synchronously at submit time
|
|
* @param loadDraft - synchronous O(1) store read; returns undefined when absent
|
|
*/
|
|
export function resolveSentDraftKey(
|
|
effectiveDraftKey: string | null | undefined,
|
|
loadDraft: (key: string) => unknown,
|
|
): string | null {
|
|
return effectiveDraftKey && loadDraft(effectiveDraftKey)
|
|
? effectiveDraftKey
|
|
: null;
|
|
}
|