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