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