({
data,
status,
entity,
entityId,
}: {
data: Post;
status: ContentPreferenceStatus | null;
entityId: string;
entity: ContentPreferenceType;
})
| 516 | }; |
| 517 | |
| 518 | export const updatePostContentPreference = ({ |
| 519 | data, |
| 520 | status, |
| 521 | entity, |
| 522 | entityId, |
| 523 | }: { |
| 524 | data: Post; |
| 525 | status: ContentPreferenceStatus | null; |
| 526 | entityId: string; |
| 527 | entity: ContentPreferenceType; |
| 528 | }): Post => { |
| 529 | if (typeof status === 'undefined') { |
| 530 | return data; |
| 531 | } |
| 532 | |
| 533 | const newData = structuredClone(data); |
| 534 | |
| 535 | if (newData.author?.id === entityId) { |
| 536 | newData.author = updateAuthorContentPreference({ |
| 537 | data: newData.author, |
| 538 | status, |
| 539 | entity, |
| 540 | }); |
| 541 | } |
| 542 | |
| 543 | if (newData.scout?.id === entityId) { |
| 544 | newData.scout = updateAuthorContentPreference({ |
| 545 | data: newData.scout, |
| 546 | status, |
| 547 | entity, |
| 548 | }); |
| 549 | } |
| 550 | |
| 551 | return newData; |
| 552 | }; |
| 553 | |
| 554 | export const updateCommentContentPreference = ({ |
| 555 | data, |
no test coverage detected