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

Function updatePostContentPreference

packages/shared/src/lib/query.ts:561–595  ·  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

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

Callers 2

usePostByIdFunction · 0.90

Calls 1

Tested by

no test coverage detected