diff --git a/src/store/actions.js b/src/store/actions.js index aa78b12..966aeb8 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -16,16 +16,9 @@ export const saveDefaultOptions = ({ commit }, payload) => { commit(types.SET_DEFAULT_OPTIONS, payload); }; -export const passwordGenerated = ({ commit }) => { - commit(types.PASSWORD_GENERATED); -}; - export const loadBestPasswordProfile = ({ commit }) => { urlParser.getSite().then(site => { - if (site) { - commit(types.SET_SITE, { site }); - commit(types.LOAD_PASSWORD_PROFILE, { site }); - } + commit(types.LOAD_PASSWORD_PROFILE, { site }); }); }; @@ -64,12 +57,13 @@ export const logout = ({ commit }) => { export const getPasswords = ({ commit, state }) => { if (state.authenticated) { - Password.all(state) - .then(response => { - commit(types.SET_PASSWORDS, { passwords: response.data.results }); - }) - .then(() => loadBestPasswordProfile({ commit })); + return Password.all(state).then(response => { + const passwords = response.data.results; + commit(types.SET_PASSWORDS, { passwords }); + return passwords; + }); } + return Promise.resolve([]); }; export const saveOrUpdatePassword = ({ commit, state }) => { diff --git a/src/store/index.js b/src/store/index.js index 8a9aa45..75d5dcd 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -13,7 +13,6 @@ const state = { password: defaultPassword, passwords: [], defaultPassword: defaultPassword, - lastUse: null, showOptions: false, token: null, baseURL: "https://lesspass.com" diff --git a/src/store/mutation-types.js b/src/store/mutation-types.js index 99d758e..9ae9f72 100644 --- a/src/store/mutation-types.js +++ b/src/store/mutation-types.js @@ -1,6 +1,5 @@ export const LOGOUT = "LOGOUT"; export const LOGIN = "LOGIN"; -export const PASSWORD_GENERATED = "PASSWORD_GENERATED"; export const SET_BASE_URL = "SET_BASE_URL"; export const SET_DEFAULT_OPTIONS = "SET_DEFAULT_OPTIONS"; export const SET_MESSAGE = "SET_MESSAGE"; diff --git a/src/store/mutations.js b/src/store/mutations.js index 81a6d70..85f2e20 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -16,9 +16,6 @@ export default { [types.SET_PASSWORD](state, { password }) { state.password = { ...password }; }, - [types.PASSWORD_GENERATED](state) { - state.lastUse = new Date().getTime(); - }, [types.SET_DEFAULT_OPTIONS](state, { options }) { state.defaultPassword = Object.assign({}, state.defaultPassword, options); }, @@ -45,9 +42,8 @@ export default { state.password.site = site; }, [types.LOAD_PASSWORD_PROFILE](state, { site }) { - const oneMinuteAgo = new Date().getTime() - 60 * 1000; - const siteDontMatch = !(site && site.endsWith(state.password.site)); - if (state.lastUse < oneMinuteAgo || siteDontMatch) { + const siteDontMatch = site && !site.endsWith(state.password.site); + if (siteDontMatch) { state.password = { ...state.defaultPassword }; } const passwords = state.passwords || []; diff --git a/src/views/PasswordGenerator.vue b/src/views/PasswordGenerator.vue index 106e6d7..13a948a 100644 --- a/src/views/PasswordGenerator.vue +++ b/src/views/PasswordGenerator.vue @@ -45,7 +45,7 @@
-