From ecbac671f06bb7fa464bf26e06d3b28d90532726 Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Mon, 16 Oct 2017 22:11:09 +0200 Subject: [PATCH] load site directly on password generator component --- src/store/actions.js | 14 ++------------ src/views/PasswordGenerator.vue | 6 ++++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/store/actions.js b/src/store/actions.js index 3c66614..79b5e33 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -16,10 +16,8 @@ export const saveDefaultOptions = ({ commit }, payload) => { commit(types.SET_DEFAULT_OPTIONS, payload); }; -export const loadBestPasswordProfile = ({ commit }) => { - urlParser.getSite().then(site => { - commit(types.LOAD_PASSWORD_PROFILE, { site }); - }); +export const loadPasswordProfile = ({ commit }, { site }) => { + commit(types.LOAD_PASSWORD_PROFILE, { site }); }; export const getPasswordFromUrlQuery = ({ commit }, { query }) => { @@ -37,14 +35,6 @@ export const resetPassword = ({ commit, state }) => { commit(types.RESET_PASSWORD); }; -export const getSite = ({ commit }) => { - urlParser.getSite().then(site => { - if (site) { - commit(types.SET_SITE, { site }); - } - }); -}; - export const login = ({ commit }, payload) => { commit(types.SET_BASE_URL, payload); commit(types.SET_TOKEN, payload); diff --git a/src/views/PasswordGenerator.vue b/src/views/PasswordGenerator.vue index a7d9c66..b8af76c 100644 --- a/src/views/PasswordGenerator.vue +++ b/src/views/PasswordGenerator.vue @@ -120,6 +120,7 @@ import {showTooltip} from '../services/tooltip'; import message from '../services/message'; import Awesomplete from 'awesomplete'; + import * as urlParser from "../services/url-parser"; export default { name: 'password-generator-view', @@ -136,8 +137,9 @@ this.$store .dispatch('getPasswords') .then(() => { - this.$store.dispatch('loadBestPasswordProfile'); - this.$store.dispatch('getSite'); + urlParser.getSite().then(site => { + this.$store.dispatch('loadPasswordProfile', {site}); + }); this.$store.dispatch('getPasswordFromUrlQuery', {query: this.$route.query}); }); },