From 194c4cf3d7fa9532561eb1bab0207f146257cc7e Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Wed, 1 Aug 2018 19:29:39 +0200 Subject: [PATCH] Misc fixes with vibrate and sound --- package.json | 1 + src/components/ReportCard.vue | 24 +++++++++++++++++------- src/store/actions.js | 14 ++++++++++---- src/views/Onboarding.vue | 6 ++++++ yarn.lock | 4 ++++ 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 3809ca4..b25a2b1 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ }, "dependencies": { "es6-promise": "^4.2.4", + "howler": "^2.0.14", "isomorphic-fetch": "^2.2.1", "leaflet": "^1.3.1", "leaflet-tracksymbol": "^1.0.8", diff --git a/src/components/ReportCard.vue b/src/components/ReportCard.vue index ee564b5..6b30bbe 100644 --- a/src/components/ReportCard.vue +++ b/src/components/ReportCard.vue @@ -50,6 +50,7 @@ diff --git a/src/store/actions.js b/src/store/actions.js index 02948b2..45c8ddc 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -25,8 +25,11 @@ import { export function fetchReports({ commit }) { commit(IS_LOADING); return api.getActiveReports() - .then(reports => commit(STORE_REPORTS, { reports })) - .finally(() => commit(IS_DONE_LOADING)); + .then((reports) => { + commit(STORE_REPORTS, { reports }); + commit(IS_DONE_LOADING); + }) + .catch(() => commit(IS_DONE_LOADING)); } export function downvote({ commit }, { id }) { @@ -46,8 +49,11 @@ export function upvote({ commit }, { id }) { export function saveReport({ commit }, { type, lat, lng }) { commit(IS_LOADING); return api.saveReport(type, lat, lng) - .then(report => commit(PUSH_REPORT, { report })) - .finally(() => commit(IS_DONE_LOADING)); + .then((report) => { + commit(PUSH_REPORT, { report }); + commit(IS_DONE_LOADING); + }) + .catch(() => commit(IS_DONE_LOADING)); } export function saveUnsentReport({ commit }, { report }) { diff --git a/src/views/Onboarding.vue b/src/views/Onboarding.vue index 03404f8..fd21149 100644 --- a/src/views/Onboarding.vue +++ b/src/views/Onboarding.vue @@ -65,9 +65,15 @@ export default { }, methods: { goToMap() { + // Eventually vibrate, to ensure permission is prompted before driving + if (this.$store.state.settings.hasVibratePermission && navigator.vibrate) { + navigator.vibrate(1); + } + if (!this.$store.state.settings.skipOnboarding) { this.$store.dispatch('setSetting', { setting: 'skipOnboarding', value: true }); } + this.$router.push({ name: 'Map' }); }, }, diff --git a/yarn.lock b/yarn.lock index 1ae7ae2..f7da4fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3831,6 +3831,10 @@ hosted-git-info@^2.1.4: version "2.6.0" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.6.0.tgz#23235b29ab230c576aab0d4f13fc046b0b038222" +howler@^2.0.14: + version "2.0.14" + resolved "https://registry.yarnpkg.com/howler/-/howler-2.0.14.tgz#28e37800fea002fea147a3ca033660c4f1288a99" + hpack.js@^2.1.6: version "2.1.6" resolved "https://registry.yarnpkg.com/hpack.js/-/hpack.js-2.1.6.tgz#87774c0949e513f42e84575b3c45681fade2a0b2"