Skip to content

Commit

Permalink
Put logic for formatting Alfred items in one module.
Browse files Browse the repository at this point in the history
  • Loading branch information
C. Thomas Bailey committed Jan 5, 2017
1 parent be92ffc commit 0105ed5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 58 deletions.
2 changes: 1 addition & 1 deletion handle-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const input = JSON.parse(alfy.input)
const notify = (title, message) => notifier.notify({ title, message })

if (input.action === 'create') {
postCard(input.card)
postCard(input.data)
.then(() => notify('It worked ⚡️', "Your card's now on Trello."))
.catch(reason => notify('Oops 🌧', `Hit a problem: ${reason}`))
} else if (input.action === 'show') {
Expand Down
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const alfy = require('alfy')
const config = require('./config')

const userPermissionToken = alfy.config.get('userPermissionToken')
const developerKey = alfy.config.get('developerKey')
const boardId = alfy.config.get('boardId')
if (config.complete()) {

}
// TODO: finish this module. Should prompt user to provide userPermissionToken
// etc. if not present. Otherwise, should call show-lists module.
4 changes: 2 additions & 2 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@
<key>queuedelaymode</key>
<integer>1</integer>
<key>queuemode</key>
<integer>2</integer>
<integer>1</integer>
<key>runningsubtext</key>
<string>Thinking...</string>
<key>script</key>
<string>./node_modules/.bin/run-node show-actions.js "$1"</string>
<string>./node_modules/.bin/run-node show-cards "$1"</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
Expand Down
29 changes: 0 additions & 29 deletions show-actions.js

This file was deleted.

17 changes: 7 additions & 10 deletions show-cards.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
const alfy = require('alfy')
const { getCards } = require('./trello')
const alfred = require('./alfred')

const formatCard = ({ id, name, url }) => ({
title: name,
arg: url,
quicklookurl: url
})
const { listId } = process.env
const gotCards = alfred.getCards(listId)
const gotCreateCard = alfred.getCreateCard(alfy.input, listId)

const listId = process.env.listId
getCards(listId).then(cards => {
const items = cards.map(formatCard)
alfy.output(items)
Promise.all([gotCards, gotCreateCard]).then(([cardItems, createCardItem]) => {
cardItems.unshift(createCardItem)
alfy.output(cardItems)
})
14 changes: 2 additions & 12 deletions show-lists.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
const alfy = require('alfy')
const { getLists } = require('./trello')
const alfred = require('./alfred')

const formatList = ({ id, name, icon, uid }) => ({
title: name,
arg: id,
icon,
uid
})

getLists().then(lists => {
var items = lists.map(formatList)
alfy.output(items)
})
alfred.getLists().then(listItems => alfy.output(listItems))

0 comments on commit 0105ed5

Please sign in to comment.