fix(profile): handle blank dossier excerpt updates
Accept null content in updatePersonalExcerpt/updateIntelExcerpt and store null when the submitted excerpt is empty instead of an empty Lexical state, skipping the max-length check for blank submissions. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
33174572cc
commit
db02be7ce9
1 changed files with 8 additions and 6 deletions
|
|
@ -180,7 +180,7 @@ async function findProfileOwner(
|
|||
|
||||
export async function updatePersonalExcerpt(input: {
|
||||
profileId: number;
|
||||
content: LexicalStateValue;
|
||||
content: LexicalStateValue | null;
|
||||
}): Promise<ActionResult> {
|
||||
try {
|
||||
const { payload, user } = await authenticate();
|
||||
|
|
@ -194,7 +194,8 @@ export async function updatePersonalExcerpt(input: {
|
|||
return { success: false, error: "You can only edit your own personal excerpt." };
|
||||
}
|
||||
|
||||
if (lexicalPlaintextLength(input.content) > PERSONAL_EXCERPT_MAX_LENGTH) {
|
||||
const blank = !input.content || lexicalPlaintextLength(input.content) === 0;
|
||||
if (!blank && lexicalPlaintextLength(input.content) > PERSONAL_EXCERPT_MAX_LENGTH) {
|
||||
return {
|
||||
success: false,
|
||||
error: `Personal excerpt must be ${PERSONAL_EXCERPT_MAX_LENGTH} characters or fewer.`,
|
||||
|
|
@ -204,7 +205,7 @@ export async function updatePersonalExcerpt(input: {
|
|||
await payload.update({
|
||||
collection: "profiles",
|
||||
id: input.profileId,
|
||||
data: { dossier: { personalExcerpt: input.content } },
|
||||
data: { dossier: { personalExcerpt: blank ? null : input.content } },
|
||||
overrideAccess: true,
|
||||
});
|
||||
|
||||
|
|
@ -225,7 +226,7 @@ export async function updatePersonalExcerpt(input: {
|
|||
|
||||
export async function updateIntelExcerpt(input: {
|
||||
profileId: number;
|
||||
content: LexicalStateValue;
|
||||
content: LexicalStateValue | null;
|
||||
}): Promise<ActionResult> {
|
||||
try {
|
||||
const { payload, user } = await authenticate();
|
||||
|
|
@ -240,7 +241,8 @@ export async function updateIntelExcerpt(input: {
|
|||
return { success: false, error: "Profile not found." };
|
||||
}
|
||||
|
||||
if (lexicalPlaintextLength(input.content) > INTEL_EXCERPT_MAX_LENGTH) {
|
||||
const blank = !input.content || lexicalPlaintextLength(input.content) === 0;
|
||||
if (!blank && lexicalPlaintextLength(input.content) > INTEL_EXCERPT_MAX_LENGTH) {
|
||||
return {
|
||||
success: false,
|
||||
error: `Intelligence record must be ${INTEL_EXCERPT_MAX_LENGTH} characters or fewer.`,
|
||||
|
|
@ -250,7 +252,7 @@ export async function updateIntelExcerpt(input: {
|
|||
await payload.update({
|
||||
collection: "profiles",
|
||||
id: input.profileId,
|
||||
data: { dossier: { intelExcerpt: input.content } },
|
||||
data: { dossier: { intelExcerpt: blank ? null : input.content } },
|
||||
overrideAccess: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue