Vibrate at opening of the Map rather than upon leaving Onboarding, ensure the notification should be displayed and seen by user

This commit is contained in:
Lucas Verney 2018-08-13 20:18:14 +02:00
parent 0b086c2fce
commit 77433bcab5
5 changed files with 19 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import * as constants from '@/constants';
import i18n from '@/i18n';
import {
HAS_VIBRATED_ONCE,
INTRO_WAS_SEEN,
INTRO_WAS_UNSEEN,
IS_DONE_LOADING,
@ -91,6 +92,10 @@ export function setSetting({ commit }, { setting, value }) {
return commit(SET_SETTING, { setting, value });
}
export function markHasVibratedOnce({ commit }) {
return commit(HAS_VIBRATED_ONCE);
}
export function markIntroAsSeen({ commit }) {
return commit(INTRO_WAS_SEEN);
}

View File

@ -1,3 +1,4 @@
export const HAS_VIBRATED_ONCE = 'HAS_VIBRATED_ONCE';
export const INTRO_WAS_SEEN = 'INTRO_WAS_SEEN';
export const INTRO_WAS_UNSEEN = 'INTRO_WAS_UNSEEN';
export const IS_DONE_LOADING = 'IS_DONE_LOADING';

View File

@ -84,6 +84,7 @@ if (storageAvailable('localStorage')) {
export const initialState = {
hasGoneThroughIntro: false,
hasVibratedOnce: false,
isLoading: false,
location: {
error: null,
@ -120,6 +121,9 @@ export const initialState = {
};
export const mutations = {
[types.HAS_VIBRATED_ONCE](state) {
state.hasVibratedOnce = true;
},
[types.INTRO_WAS_SEEN](state) {
state.hasGoneThroughIntro = true;
},

View File

@ -222,6 +222,15 @@ export default {
} else {
this.$store.state.location.error = 1;
}
// Eventually vibrate, to ensure permission is prompted before cycling
if (this.$store.state.settings.hasVibratePermission
&& navigator.vibrate
&& !this.$store.state.hasVibratedOnce
) {
navigator.vibrate(100);
this.$store.dispatch('markHasVibratedOnce');
}
}
this.$store.dispatch('fetchReports').catch(() => {});
},

View File

@ -65,11 +65,6 @@ export default {
},
methods: {
goToMap() {
// Eventually vibrate, to ensure permission is prompted before driving
if (this.$store.state.settings.hasVibratePermission && navigator.vibrate) {
navigator.vibrate(100);
}
if (!this.$store.state.settings.skipOnboarding) {
this.$store.dispatch('setSetting', { setting: 'skipOnboarding', value: true });
}