Clean up code
This commit is contained in:
parent
66ed01c1d7
commit
e92412cf21
|
|
@ -5,6 +5,7 @@ import MODULE_QUERY from '@/graphql/gql/moduleByIdQuery.gql';
|
|||
import INSTRUMENT_FRAGMENT from '@/graphql/gql/fragments/instrumentParts.gql';
|
||||
|
||||
const getBlockType = id => atob(id).split(':')[0];
|
||||
const compareUuid = note => element => element.uuid === note.content;
|
||||
|
||||
export const constructNoteMutation = (n) => {
|
||||
let update = () => {
|
||||
|
|
@ -22,9 +23,7 @@ export const constructNoteMutation = (n) => {
|
|||
|
||||
const bookmarks = data.contentBlock.bookmarks;
|
||||
|
||||
let index = bookmarks.findIndex(element => {
|
||||
return element.uuid === n.content;
|
||||
});
|
||||
let index = bookmarks.findIndex(compareUuid(n));
|
||||
|
||||
if (index > -1) {
|
||||
let el = bookmarks[index];
|
||||
|
|
@ -49,9 +48,7 @@ export const constructNoteMutation = (n) => {
|
|||
|
||||
const bookmarks = data.bookmarks;
|
||||
|
||||
let index = bookmarks.findIndex(element => {
|
||||
return element.uuid === n.content;
|
||||
});
|
||||
let index = bookmarks.findIndex(compareUuid(n));
|
||||
|
||||
if (index > -1) {
|
||||
let el = bookmarks[index];
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import UPDATE_INSTRUMENT_BOOKMARK from '@/graphql/gql/mutations/updateInstrument
|
|||
import CONTENT_BLOCK_QUERY from '@/graphql/gql/contentBlockQuery.gql';
|
||||
import INSTRUMENT_FRAGMENT from '@/graphql/gql/fragments/instrumentParts.gql';
|
||||
|
||||
const compareUuid = uuid => element => element.uuid === uuid;
|
||||
|
||||
export const constructContentComponentBookmarkMutation = (uuid, bookmarked, parent, root) => {
|
||||
let mutation = {};
|
||||
|
||||
|
|
@ -33,9 +35,7 @@ export const constructContentComponentBookmarkMutation = (uuid, bookmarked, pare
|
|||
__typename: 'ContentBlockBookmarkNode'
|
||||
});
|
||||
} else {
|
||||
let index = bookmarks.findIndex(element => {
|
||||
return element.uuid === uuid;
|
||||
});
|
||||
let index = bookmarks.findIndex(compareUuid(uuid));
|
||||
if (index > -1) {
|
||||
bookmarks.splice(index, 1);
|
||||
}
|
||||
|
|
@ -84,9 +84,7 @@ export const constructContentComponentBookmarkMutation = (uuid, bookmarked, pare
|
|||
__typename: 'InstrumentBookmarkNode'
|
||||
})
|
||||
} else {
|
||||
let index = bookmarks.findIndex(element => {
|
||||
return element.uuid === uuid;
|
||||
});
|
||||
let index = bookmarks.findIndex(compareUuid(uuid));
|
||||
if (index > -1) {
|
||||
bookmarks.splice(index, 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue