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