From 0956fdb28d41fd346fc2edc3222a7bea29989e6d Mon Sep 17 00:00:00 2001 From: Robin Mitra Date: Sun, 23 Jun 2019 01:57:15 +0100 Subject: [PATCH 1/3] Update 'movies' category key to be 'movie', to be inline with the API. --- src/menu/components/category.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/menu/components/category.js b/src/menu/components/category.js index 79b327b..a3cca18 100644 --- a/src/menu/components/category.js +++ b/src/menu/components/category.js @@ -36,11 +36,11 @@ const menuItem = new MenuItem({ checked: isChecked('inspirational') }, { - id: 'movies', - label: 'Movies', + id: 'movie', + label: 'Movie', type: 'checkbox', click: updateCategory, - checked: isChecked('movies') + checked: isChecked('movie') }, { id: 'programming', From 48226fe8579246c65f70c60f6387b1e37f0464d3 Mon Sep 17 00:00:00 2001 From: Robin Mitra Date: Sun, 23 Jun 2019 01:58:06 +0100 Subject: [PATCH 2/3] Gracefully handle the scenario if random quote is undefined. --- src/menu/menu.js | 3 ++- src/quoteService.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/menu/menu.js b/src/menu/menu.js index 0963c1e..c59438c 100644 --- a/src/menu/menu.js +++ b/src/menu/menu.js @@ -17,11 +17,12 @@ const clearSchedule = () => clearInterval(intervalId); const showQuote = () => { const { quote, author, year } = quoteService.getRandom(store.getState().category); + if (!quote) return; (new Notification({ title: author, body: quote, subtitle: year, - silent: store.getState().silent + silent: store.getState().silent, })).show(); }; diff --git a/src/quoteService.js b/src/quoteService.js index 9b0b2cf..9500a5b 100644 --- a/src/quoteService.js +++ b/src/quoteService.js @@ -36,7 +36,7 @@ exports.getRandom = categories => { } logger.log('Remaining quotes', remainingQuotes); const randomIndex = Math.floor(Math.random() * (remainingQuotes.length - 1)); - const randomQuote = remainingQuotes[randomIndex]; + const randomQuote = remainingQuotes[randomIndex] ? remainingQuotes[randomIndex] : {}; remainingQuotes.splice(randomIndex, 1); logger.info('Returning random quote', randomQuote); return randomQuote; From 21878247608911542dcc71f477277ebb4a862868 Mon Sep 17 00:00:00 2001 From: Robin Mitra Date: Sun, 23 Jun 2019 01:58:17 +0100 Subject: [PATCH 3/3] Bump version to 0.2.4. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index e423553..1a6e5f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "gimme-quote", - "version": "0.2.3", + "version": "0.2.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 280c0b0..c2af0b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gimme-quote", - "version": "0.2.3", + "version": "0.2.4", "description": "A minimal desktop app for getting your dose of famous quotes.", "main": "main.js", "scripts": {