Clean up code

This commit is contained in:
Ramon Wenger 2020-01-16 14:10:16 +01:00
parent 66ed01c1d7
commit e92412cf21
2 changed files with 7 additions and 12 deletions

View File

@ -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];

View File

@ -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);
}