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