Merge branch 'hotfix/duplicate-and-delete-content-blocks-cachee' into develop
This commit is contained in:
commit
264f0abc27
|
|
@ -159,13 +159,14 @@ const { mutate: duplicateContentBlock } = useMutation(DUPLICATE_CONTENT_BLOCK_MU
|
|||
}
|
||||
) => {
|
||||
const id = props.parent.id;
|
||||
const contentBlockId = props.contentBlock.id;
|
||||
if (contentBlock) {
|
||||
const query = CHAPTER_QUERY;
|
||||
const variables = {
|
||||
id,
|
||||
};
|
||||
const { chapter }: any = store.readQuery({ query, variables });
|
||||
const index = chapter.contentBlocks.findIndex((contentBlock: ContentBlock) => contentBlock.id === id);
|
||||
const index = chapter.contentBlocks.findIndex((contentBlock: ContentBlock) => contentBlock.id === contentBlockId);
|
||||
const contentBlocks = insertAtIndex(chapter.contentBlocks, index, contentBlock);
|
||||
const data = {
|
||||
chapter: {
|
||||
|
|
@ -199,8 +200,11 @@ const { mutate: doDeleteContentBlock } = useMutation(DELETE_CONTENT_BLOCK_MUTATI
|
|||
};
|
||||
const { chapter }: any = store.readQuery({ query, variables });
|
||||
const index = chapter.contentBlocks.findIndex(
|
||||
(contentBlock: ContentBlock) => contentBlock.id === props.parent.id
|
||||
(contentBlock: ContentBlock) => contentBlock.id === props.contentBlock.id
|
||||
);
|
||||
if (index < 0) {
|
||||
throw Error('ContentBlock not found');
|
||||
}
|
||||
const contentBlocks = removeAtIndex(chapter.contentBlocks, index);
|
||||
const data = {
|
||||
chapter: {
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ const helloEmailVar = makeVar('');
|
|||
|
||||
const idToRefFactory =
|
||||
(__typename) =>
|
||||
(_, { args, toReference }) => {
|
||||
log.debug(`Referencing ${__typename} with ${args.id}`);
|
||||
return toReference({
|
||||
__typename,
|
||||
id: args.id,
|
||||
});
|
||||
};
|
||||
(_, { args, toReference }) => {
|
||||
log.debug(`Referencing ${__typename} with ${args.id}`);
|
||||
return toReference({
|
||||
__typename,
|
||||
id: args.id,
|
||||
});
|
||||
};
|
||||
|
||||
const typePolicies = {
|
||||
ProjectNode: {
|
||||
|
|
@ -27,6 +27,16 @@ const typePolicies = {
|
|||
RoomNode: {
|
||||
keyFields: ['slug'],
|
||||
},
|
||||
ChapterNode: {
|
||||
fields: {
|
||||
contentBlocks: {
|
||||
merge(_existing, incoming) {
|
||||
// always replace the whole array
|
||||
return incoming;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ModuleNode: {
|
||||
fields: {
|
||||
inEditMode: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue