({
data,
status,
entity,
entityId,
}: {
data: Post;
status: ContentPreferenceStatus | null;
entityId: string;
entity: ContentPreferenceType;
})
| 552 | }; |
| 553 | |
| 554 | export const updatePostContentPreference = ({ |
| 555 | data, |
| 556 | status, |
| 557 | entity, |
| 558 | entityId, |
| 559 | }: { |
| 560 | data: Post; |
| 561 | status: ContentPreferenceStatus | null; |
| 562 | entityId: string; |
| 563 | entity: ContentPreferenceType; |
| 564 | }): Post => { |
| 565 | if (typeof status === 'undefined') { |
| 566 | return data; |
| 567 | } |
| 568 | |
| 569 | const newData = structuredClone(data); |
| 570 | |
| 571 | if (newData.author?.id === entityId) { |
| 572 | newData.author = updateAuthorContentPreference({ |
| 573 | data: newData.author, |
| 574 | status, |
| 575 | entity, |
| 576 | }); |
| 577 | } |
| 578 | |
| 579 | if (newData.scout?.id === entityId) { |
| 580 | newData.scout = updateAuthorContentPreference({ |
| 581 | data: newData.scout, |
| 582 | status, |
| 583 | entity, |
| 584 | }); |
| 585 | } |
| 586 | |
| 587 | return newData; |
| 588 | }; |
| 589 | |
| 590 | export const updateCommentContentPreference = ({ |
| 591 | data, |
no test coverage detected