MCPcopy Create free account
hub / github.com/dailydotdev/apps / updatePostContentPreference

Function updatePostContentPreference

packages/shared/src/lib/query.ts:548–582  ·  view source on GitHub ↗
({
  data,
  status,
  entity,
  entityId,
}: {
  data: Post;
  status: ContentPreferenceStatus | null;
  entityId: string;
  entity: ContentPreferenceType;
})

Source from the content-addressed store, hash-verified

546};
547
548export 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
584export const updateCommentContentPreference = ({
585 data,

Callers 2

usePostByIdFunction · 0.90

Calls 1

Tested by

no test coverage detected