diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-09-27 15:59:30 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-09-27 15:59:30 +0200 |
commit | a9840fdd6415add9d9364a3f784b3d7b30cd7244 (patch) | |
tree | 384425642008791fd87a2d5d583507741a85f0ab /src | |
parent | 5501624f8f45c9427c1942c8674df7a38ed516cd (diff) |
Fix Importing state reset
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/Settings/SettingsImportContacts.vue | 2 | ||||
-rw-r--r-- | src/store/addressbooks.js | 2 | ||||
-rw-r--r-- | src/store/importState.js | 20 |
3 files changed, 18 insertions, 6 deletions
diff --git a/src/components/Settings/SettingsImportContacts.vue b/src/components/Settings/SettingsImportContacts.vue index 881308ae..d7a17044 100644 --- a/src/components/Settings/SettingsImportContacts.vue +++ b/src/components/Settings/SettingsImportContacts.vue @@ -98,6 +98,8 @@ export default { let self = this reader.onload = function(e) { self.$store.dispatch('importContactsIntoAddressbook', { vcf: reader.result, addressbook: selectedAddressbook }) + // reset input + event.target.value = '' } reader.readAsText(file) } diff --git a/src/store/addressbooks.js b/src/store/addressbooks.js index 185a6465..8d93594b 100644 --- a/src/store/addressbooks.js +++ b/src/store/addressbooks.js @@ -363,7 +363,7 @@ const actions = { }) Promise.all(requests).then(() => { - // context.commit('changeStage', 'default') + context.commit('changeStage', 'default') }) }, diff --git a/src/store/importState.js b/src/store/importState.js index 313c8d6d..b5adafc7 100644 --- a/src/store/importState.js +++ b/src/store/importState.js @@ -77,11 +77,17 @@ const mutations = { */ changeStage(state, stage) { state.importState.stage = stage - if (stage === 'default') { - state.accepted = 0 - state.denied = 0 - state.total = 0 - } + }, + + /** + * Reset to the default state + * + * @param {Object} state the store data + */ + resetState(state) { + state.importState.total = 0 + state.importState.accepted = 0 + state.importState.denied = 0 } } @@ -130,12 +136,16 @@ const actions = { /** * Change stage to the indicated one + * and reset if the parsing starts * * @param {Object} context the store mutations * @param {String} stage the name of the stage ('default', 'importing', 'parsing') */ changeStage(context, stage) { context.commit('changeStage', stage) + if (stage === 'parsing') { + context.commit('resetState') + } } } |