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';
|
import INSTRUMENT_FRAGMENT from '@/graphql/gql/fragments/instrumentParts.gql';
|
||||||
|
|
||||||
const getBlockType = id => atob(id).split(':')[0];
|
const getBlockType = id => atob(id).split(':')[0];
|
||||||
|
const compareUuid = note => element => element.uuid === note.content;
|
||||||
|
|
||||||
export const constructNoteMutation = (n) => {
|
export const constructNoteMutation = (n) => {
|
||||||
let update = () => {
|
let update = () => {
|
||||||
|
|
@ -22,9 +23,7 @@ export const constructNoteMutation = (n) => {
|
||||||
|
|
||||||
const bookmarks = data.contentBlock.bookmarks;
|
const bookmarks = data.contentBlock.bookmarks;
|
||||||
|
|
||||||
let index = bookmarks.findIndex(element => {
|
let index = bookmarks.findIndex(compareUuid(n));
|
||||||
return element.uuid === n.content;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
let el = bookmarks[index];
|
let el = bookmarks[index];
|
||||||
|
|
@ -49,9 +48,7 @@ export const constructNoteMutation = (n) => {
|
||||||
|
|
||||||
const bookmarks = data.bookmarks;
|
const bookmarks = data.bookmarks;
|
||||||
|
|
||||||
let index = bookmarks.findIndex(element => {
|
let index = bookmarks.findIndex(compareUuid(n));
|
||||||
return element.uuid === n.content;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
let el = bookmarks[index];
|
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 CONTENT_BLOCK_QUERY from '@/graphql/gql/contentBlockQuery.gql';
|
||||||
import INSTRUMENT_FRAGMENT from '@/graphql/gql/fragments/instrumentParts.gql';
|
import INSTRUMENT_FRAGMENT from '@/graphql/gql/fragments/instrumentParts.gql';
|
||||||
|
|
||||||
|
const compareUuid = uuid => element => element.uuid === uuid;
|
||||||
|
|
||||||
export const constructContentComponentBookmarkMutation = (uuid, bookmarked, parent, root) => {
|
export const constructContentComponentBookmarkMutation = (uuid, bookmarked, parent, root) => {
|
||||||
let mutation = {};
|
let mutation = {};
|
||||||
|
|
||||||
|
|
@ -33,9 +35,7 @@ export const constructContentComponentBookmarkMutation = (uuid, bookmarked, pare
|
||||||
__typename: 'ContentBlockBookmarkNode'
|
__typename: 'ContentBlockBookmarkNode'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let index = bookmarks.findIndex(element => {
|
let index = bookmarks.findIndex(compareUuid(uuid));
|
||||||
return element.uuid === uuid;
|
|
||||||
});
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
bookmarks.splice(index, 1);
|
bookmarks.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
@ -84,9 +84,7 @@ export const constructContentComponentBookmarkMutation = (uuid, bookmarked, pare
|
||||||
__typename: 'InstrumentBookmarkNode'
|
__typename: 'InstrumentBookmarkNode'
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let index = bookmarks.findIndex(element => {
|
let index = bookmarks.findIndex(compareUuid(uuid));
|
||||||
return element.uuid === uuid;
|
|
||||||
});
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
bookmarks.splice(index, 1);
|
bookmarks.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue