Created
July 28, 2016 00:00
-
-
Save mvanlonden/b93bb5d083bb348b0aec59fba583778e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function moveModuleIntoBoard(module, board) { | |
return new Promise((resolve, reject) => { | |
const mutation = ` | |
{ | |
moveModuleToBoard(input: { | |
clientMutationId: "${new Date().getTime()}", | |
boardId: "${board.id}", | |
moduleId: "${module.id}" | |
}) { | |
viewer { | |
id | |
} | |
} | |
} | |
` | |
client.mutate(mutation) | |
.then(result => { | |
return resolve(result) | |
}); | |
}) | |
} |
Author
mvanlonden
commented
Jul 28, 2016
async function getLocalBoards() {
return new Promise( (resolve, reject) => {
chrome.storage.sync.get('boards', ({boards}) => {
resolve(boards)
})
})
}
async function getBoardForModule() {
const boards = await getLocalBoards()
if (boards.length > 0) {
return boards[boards.length - 1]
}
// if no boards in extension storage, create one!
const mutation = `
{
addBoard(input: {
clientMutationId: "${new Date().getTime()}"
}) {
boardEdge {
node {
id,
name
}
}
}
}
`
const board = await client.mutate(mutation)
chrome.storage.sync.set({ boards: [board]})
return board
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment