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