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