Skip to content

Commit

Permalink
refactor: use here new api for template
Browse files Browse the repository at this point in the history
  • Loading branch information
lifesign committed Jul 26, 2020
1 parent fb3f040 commit bdd65a4
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const net = require("net")
function updateData() {
const LIMIT = 10

here.setMiniWindow({ title: "Updating…" })
here.miniWindow.set({ title: "Updating…" })

here.parseRSSFeed("{{rssFeedUrl}}")
.then((feed) => {
if (feed.items.length <= 0) {
return here.setMiniWindow({ title: "No item found." })
return here.miniWindow.set({ title: "No item found." })
}

if (feed.items.length > LIMIT) {
Expand All @@ -18,18 +18,22 @@ function updateData() {

const topFeed = feed.items[0]

let popOvers = _.map(feed.items, (item, index) => {
return {
title: `${index + 1}. ${item.title}`,
onClick: () => { if (item.link != undefined) { here.openURL(item.link) } },
}
})

// Mini Window
here.setMiniWindow({
here.miniWindow.set({
onClick: () => { if (topFeed.link != undefined) { here.openURL(topFeed.link) } },
title: topFeed.title,
detail: "{{miniDetail}}",
popOvers: _.map(feed.items, (item, index) => {
return {
title: `${index + 1}. ${item.title}`,
onClick: () => { if (item.link != undefined) { here.openURL(item.link) } },
}
})
})

//popover
here.popover.set(popOvers)
})
.catch((error) => {
console.error(`Error: ${JSON.stringify(error)}`)
Expand Down

0 comments on commit bdd65a4

Please sign in to comment.